hosyn Posted June 4, 2020 Posted June 4, 2020 Hello guys im gonna to make code for selecting external block in my drawing and explode it. please any command and idea to help this. Quote
marko_ribar Posted June 4, 2020 Posted June 4, 2020 (defun c:blkinsexp ( / fn ) (setq fn (getfiled "\nSelect block DWG file..." "\\" "dwg" 16)) (vl-cmdf "_.-INSERT" (strcat "*" fn)) (while (< 0 (getvar 'cmdactive)) (vl-cmdf "\\") ) (princ) ) Pulled from this topic : https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/exploding-blocks-on-insert/td-p/6057810 Quote
hosyn Posted June 4, 2020 Author Posted June 4, 2020 (edited) hi marko I don know how i can appreciate of your helping, that s great what i need. one more qustion:: the command lisp ask us open window in cuerrent path or spescifed pass defined in code lisp. something like this : (defun c:blkinsexp ( / fn ) (setq fn (getfiled "\nSelect block DWG file..." "\\" "dwg" 16)) (setq pathinsert getstring "your external block in the current or in default path y/n") ( if y ---->> open window in current path n ---->> open window in d://my ex block// ) (vl-cmdf "_.-INSERT" (strcat "*" fn)) (while (< 0 (getvar 'cmdactive)) (vl-cmdf "\\") ) (princ) ) I have modified the above to :: (defun c:blkinsexp ( / fn ) (initget 1 "Y N") ; 1 = no null input (setq hide (getkword "\nCURRENTLY? [Y/N] ? <Y>")) ;Get the input (if (= hide "Y") ;If the user has entered the required key "Y" (setq e-path (getvar "dwgprefix")) (setq fn (getfiled "\nSelect block DWG file..." e-path "dwg" 16))) ( if (= hide "N") (setq fn (getfiled "\nSelect block DWG file..." "E://99/ "dwg" 16))) (vl-cmdf "_.-INSERT" (strcat "*" fn)) (while (< 0 (getvar 'cmdactive)) (vl-cmdf "\\") ) (princ) ) and i get the following error: Command: error: malformed string on input Cannot invoke (command) from *error* without prior call to (*push-error-using-command*). Converting (command) calls to (command-s) is recommended. Command: Edited June 5, 2020 by hosyn Quote
Dadgad Posted June 5, 2020 Posted June 5, 2020 You might also like to check out Lee Macs Upgraded Burst lisp. I've never used it, but I am sure there are those who WILL find it very helpful. Thanks Lee! Quote
hosyn Posted June 6, 2020 Author Posted June 6, 2020 hi marko I don know how i can appreciate of your helping, that s great what i need. one more qustion:: the command lisp ask us open window in cuerrent path or spescifed pass defined in code lisp. something like this : (defun c:blkinsexp ( / fn ) (setq fn (getfiled "\nSelect block DWG file..." "\\" "dwg" 16)) (setq pathinsert getstring "your external block in the current or in default path y/n") ( if y ---->> open window in current path n ---->> open window in d://my ex block// ) (vl-cmdf "_.-INSERT" (strcat "*" fn)) (while (< 0 (getvar 'cmdactive)) (vl-cmdf "\\") ) (princ) ) I have modified the above to :: (defun c:blkinsexp ( / fn ) (initget 1 "Y N") ; 1 = no null input (setq hide (getkword "\nCURRENTLY? [Y/N] ? <Y>")) ;Get the input (if (= hide "Y") ;If the user has entered the required key "Y" (setq e-path (getvar "dwgprefix")) (setq fn (getfiled "\nSelect block DWG file..." e-path "dwg" 16))) ( if (= hide "N") (setq fn (getfiled "\nSelect block DWG file..." "E://99/ "dwg" 16))) (vl-cmdf "_.-INSERT" (strcat "*" fn)) (while (< 0 (getvar 'cmdactive)) (vl-cmdf "\\") ) (princ) ) and i get the following error: Command: error: malformed string on input Cannot invoke (command) from *error* without prior call to (*push-error-using-command*). Converting (command) calls to (command-s) is recommended. Command: Quote
marko_ribar Posted June 6, 2020 Posted June 6, 2020 (edited) Try this mod... (defun c:blkinsexp ( / fn hide path ) (initget "Y N") (setq hide (getkword "\nCURRENTLY? [Y/N] ? <Y> : ")) (if (null hide) (setq hide "Y") ) (cond ( (= hide "Y") (setq fn (getfiled "\nSelect block DWG file..." (getvar 'dwgprefix) "dwg" 16)) ) ( (= hide "N") (if (not (vl-file-directory-p (setq path "E:\\99\\"))) (if (vl-file-directory-p "E:\\") (vl-mkdir (setq path "E:\\99\\")) (if (not (vl-file-directory-p (setq path "C:\\99\\"))) (vl-mkdir (setq path "C:\\99\\")) ) ) ) (setq fn (getfiled "\nSelect block DWG file..." path "dwg" 16)) ) ) (vl-cmdf "_.-INSERT" (strcat "*" fn)) (while (< 0 (getvar 'cmdactive)) (vl-cmdf "\\") ) (princ) ) Edited June 6, 2020 by marko_ribar 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.