Results 1 to 4 of 4

Thread: Block command in an AutoLISP script.

  1. #1
    Member
    Join Date
    2010-08
    Location
    Seattle
    Posts
    15
    Login to Give a bone
    0

    Post Block command in an AutoLISP script.

    Hey all,

    I'm relatively new to the AutoLISP thing, and i'm a bit stuck on a flex-duct script I am trying to write. I want my script to draw a line, then make that line into a block with the insertion point at the midpoint of the line. For some reason I cannot get the script to make my block and insert it into the drawing. Can anybody point out what I could be doing wrong, or where I can find some information on using the "block" command in AutoLISP?

    I have attached the script I am working on for anybody to poke through.

    FlexDuct2.lsp

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Block command in an AutoLISP script.

    Things like this ... ?

    Code:
    (defun c:Test (/ i p1 p2 l Blockname mid)
      (setq i 1)
      (if (setq p1 (getpoint "\n Specify point :"))
        (while
          (setq p2 (getpoint p1 "\n Next point :"))
           (setq l (entmakex (list '(0 . "LINE") (cons 10 p1) (cons 11 p2))))
           (while (tblsearch "BLOCK" (setq Blockname (strcat "Line" (itoa i))))
             (setq i (1+ i))
           )
           (command "_.-block" Blockname (setq mid (mapcar (function (lambda (p1 p2) (/ (+ p1 p2) 2.)))
                                      p1
                                      p2
                              )
                    )
                    l
                    ""
           )
           (command "_.-insert" Blockname mid "" "" "")
           (setq p1 p2)
        )
        (princ)
      )
      (princ)
    )

  3. #3
    Member
    Join Date
    2010-08
    Location
    Seattle
    Posts
    15
    Login to Give a bone
    0

    Default Re: Block command in an AutoLISP script.

    Exactly! There are a lot of bits and syntax's in here that I don't quite understand, but the script works great and looks like it will plug into my code real well.

  4. #4
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Block command in an AutoLISP script.

    Happy to hear that

Similar Threads

  1. 2013: cal command in a script file
    By JWagner-V6 in forum AutoCAD LT - General
    Replies: 5
    Last Post: 2014-11-07, 10:49 AM
  2. Cal command in a script file
    By JWagner-V6 in forum AutoLISP
    Replies: 0
    Last Post: 2014-08-14, 07:29 PM
  3. cancel or escape command in a script or menu command?!
    By jcooke96119 in forum AutoCAD Customization
    Replies: 7
    Last Post: 2007-10-31, 01:28 PM
  4. Dimension style text color not updating after AutoLisp script
    By thomas.glasgow in forum AutoCAD General
    Replies: 12
    Last Post: 2007-07-17, 10:28 PM
  5. AutoLISP command causes script to stop...
    By FWSchreck in forum AutoLISP
    Replies: 4
    Last Post: 2007-01-20, 12:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •