Jump to content

change properties with macro help


jim78b

Recommended Posts

Sure if you look in the LISP there is a line (setq BlockName...  or something like that, setq to set a variable, BlockName.... gives a clue what variable that is....

Then a simple internet search to find out how to enter a string into a L:ISP (quite easy).. (getstring )

 

This should work with a couple of other tweaks

 

(defun c:chcol ( / MySS )
  (setq MySS (ssget))
  (command "chprop" MySS "" "C" "ByBlock" "")
  (setq BlockName (getstring "Enter Bloc Name: ")
  (c:blk MySS BlockName)
)


;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-create-block-insert-that-block/td-p/5431779
;;(defun c:blk (/ selectionset insertionpoint number Blockname)
(defun c:blk (selectionset MyBlock / insertionpoint number Blockname)
;;  (if (and (setq selectionset (ssget "_:L"))
           (setq insertionpoint (getpoint "\n Specify Block Insertion Point :"))
;;      )
    (progn
      (setq number    1
            Blockname MyBlock
      )
      (while (tblsearch "BLOCK" Blockname)
        (setq Blockname
               (strcat MyBlock (itoa (setq number (1+ number))))
        )
      )
      (command "_.-Block" Blockname insertionpoint selectionset "")
      (command "_.-insert" Blockname insertionpoint "" "" "")
    )
  )
  (princ)
)

 

Link to comment
Share on other sites

Ah yes I missed a ')' - updated the code above (often syntax error means I have forgotten a closing bracket ), and you just need to work through the code to find where it is)

 

Learning LISP is quite easy - take some time to work out what this does and you'll get there

Link to comment
Share on other sites

That's weird, it didn't update the code above, try this:

 

(defun c:chcol ( / MySS )
  (setq MySS (ssget))
  (command "chprop" MySS "" "C" "ByBlock" "")
  (setq BlockName (getstring "Enter Block Name: "))
  (c:blk MySS BlockName)
)


;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-create-block-insert-that-block/td-p/5431779
;;(defun c:blk (/ selectionset insertionpoint number Blockname)
(defun c:blk (selectionset MyBlock / insertionpoint number Blockname)
;;  (if (and (setq selectionset (ssget "_:L"))
           (setq insertionpoint (getpoint "\n Specify Block Insertion Point :"))
;;      ) ; end and
    (progn
      (setq number    1
            Blockname MyBlock
      )
      (while (tblsearch "BLOCK" Blockname)
        (setq Blockname
               (strcat MyBlock (itoa (setq number (1+ number))))
        )
      )
      (command "_.-Block" Blockname insertionpoint selectionset "")
      (command "_.-insert" Blockname insertionpoint "" "" "")
    ) ; end progn
;  ) ; end if
  (princ)
)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...