Steven P Posted September 13, 2022 Posted September 13, 2022 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) ) Quote
jim78b Posted September 13, 2022 Author Posted September 13, 2022 Thanks very much for you is very simply write code ...i think never learn . Quote
Steven P Posted September 13, 2022 Posted September 13, 2022 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 Quote
jim78b Posted September 13, 2022 Author Posted September 13, 2022 sorry i don't want I do not want to bother you Quote
jim78b Posted September 13, 2022 Author Posted September 13, 2022 sorry i tried again but give syntax error Quote
Steven P Posted September 13, 2022 Posted September 13, 2022 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) ) Quote
Recommended Posts
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.