jjatho Posted July 14, 2015 Posted July 14, 2015 Here's the incomplete code I'm working on: (defun C:Crane() (initget 1 "Kobelco 777 888 999 LTR1100 1400 1600 1750 11000 11350 13000") (setq Crane (getkword "Select Crane [Kobelco/777/888/999/LTR 1100/1400/1600/1750/11000/11350/13000] : ")); (cond ((="Kobelco" Crane) ); ((="777" Crane) ); ((="888" Crane) ); ((="999" Crane) ); ((="LTR1100" Crane) (initget 1 "Elevation Plan") (setq BlockView (getkword "Select View [Elevation/Plan] : ")); (cond ((="Elevation" BlockView) (setq path "C:\\Dropbox\\Buckner Heavy Lift Cranes\\Technical Data\\Liebherr LTR 1100\\2D CAD Files\\Buckner Crane Block\\LTR 1100 Elevation.dwg") ); ((="Plan" BlockView) (setq path "C:\\Dropbox\\Buckner Heavy Lift Cranes\\Technical Data\\Liebherr LTR 1100\\2D CAD Files\\Buckner Crane Block\\LTR 1100 Plan.dwg") ); ) ); ((="1400" Crane) ); ((="1600" Crane) ); ((="1750" Crane) ); ((="11000" Crane) (initget 1 "Elevation Plan") (setq BlockView (getkword "Select View [Elevation/Plan] : ")); (cond ((="Elevation" BlockView) (setq path "C:\\Dropbox\\Buckner Heavy Lift Cranes\\Technical Data\\Liebherr LR 11000\\2D CAD Files\\Buckner Crane Block\\11000 Elevation.dwg") ); ((="Plan" BlockView) (setq path "C:\\Dropbox\\Buckner Heavy Lift Cranes\\Technical Data\\Liebherr LR 11000\\2D CAD Files\\Buckner Crane Block\\11000 Plan.dwg") ); ) ); ((="11350" Crane) (initget 1 "Elevation Plan") (setq BlockView (getkword "Select View [Elevation/Plan] : ")); (cond ((="Elevation" BlockView) (setq path "C:\\Dropbox\\Buckner Heavy Lift Cranes\\Technical Data\\Liebherr LR 11350\\2D CAD Files\\Buckner Crane Block\\11350 Elevation.dwg") ); ((="Plan" BlockView) (setq path "C:\\Dropbox\\Buckner Heavy Lift Cranes\\Technical Data\\Liebherr LR 11350\\2D CAD Files\\Buckner Crane Block\\11350 Plan.dwg") ); ) ); ((="13000" Crane) (initget 1 "Elevation Plan") (setq BlockView (getkword "Select View [Elevation/Plan] : ")); (cond ((="Elevation" BlockView) (setq path "C:\\Dropbox\\Buckner Heavy Lift Cranes\\Technical Data\\Liebherr LR 13000\\2D CAD Files\\Buckner Crane Block\\13000 Elevation.dwg") (setq name "13000 Elevation") ); ((="Plan" BlockView) (setq path "C:\\Dropbox\\Buckner Heavy Lift Cranes\\Technical Data\\Liebherr LR 13000\\2D CAD Files\\Buckner Crane Block\\13000 Plan.dwg") (setq name "13000 Plan") ); ) ); ) (command "insert" path "S" "1" "R" "0") (princ) ) ;End defun Crane After inserting the block, I have tried every single method I could find online to select that block, then explode it but I cannot seem to make it work. Could it be because I am inserting with a file path? Quote
MonkeyTurnip Posted July 14, 2015 Posted July 14, 2015 in the block editor has the "Allow Exploding" parameter been set to "no"? Quote
MonkeyTurnip Posted July 14, 2015 Posted July 14, 2015 Here is a screen shot inside the block editor properties. if this is set to no the block will not explode, if it is set to yes, the block will explode. this setting is individual to each block Quote
welldriller Posted July 14, 2015 Posted July 14, 2015 Ok I don't know how to write code -- but -- what is wrong with using the (explode command) that came with the program? Quote
jjatho Posted July 14, 2015 Author Posted July 14, 2015 All of them are able to explode. I just select them and explode manually for now. Quote
jjatho Posted July 14, 2015 Author Posted July 14, 2015 Efficiency. Why select manually and explode manually each time when I don't have to? The whole idea behind AutoLISP, to me, is to do things faster and easier Quote
RobDraw Posted July 14, 2015 Posted July 14, 2015 Why code it if it's a native AutoCAD command? Explode on insert is an option in the insert block command. Quote
jjatho Posted July 14, 2015 Author Posted July 14, 2015 Can I modify the following line of code: (command "insert" path "S" "1" "R" "0") To explode the same as that? Quote
RobDraw Posted July 14, 2015 Posted July 14, 2015 Sorry I responded, I forgot I was in the coding forum. Quote
Tharwat Posted July 14, 2015 Posted July 14, 2015 Can I modify the following line of code: (command "insert" path "S" "1" "R" "0") To explode the same as that? Maybe this should work with external inserted block (not tested before). (command "insert" (strcat "*" path) "S" "1" "R" "0") Quote
jjatho Posted July 14, 2015 Author Posted July 14, 2015 Maybe this should work with external inserted block (not tested before). (command "insert" (strcat "*" path) "S" "1" "R" "0") This sort of works, but it ignores the "S" "1" "R" "0" portion so I have to do that stuff manually, which actually takes longer than manually exploding. It does result in an exploded block though. Quote
Tharwat Posted July 14, 2015 Posted July 14, 2015 This sort of works, but it ignores the "S" "1" "R" "0" portion so I have to do that stuff manually, which actually takes longer than manually exploding. It does result in an exploded block though. Yeah , exploding the block would cancel the rest of the following option of the command and that give sense . Quote
jjatho Posted July 14, 2015 Author Posted July 14, 2015 Is it possible to stop the insert command after (strcat "*" path) to make it ask for an insertion point, then proceed to the "S" "1" "R" "0" after? Quote
Tharwat Posted July 14, 2015 Posted July 14, 2015 Is it possible to stop the insert command after (strcat "*" path) to make it ask for an insertion point, then proceed to the "S" "1" "R" "0" after? Try it this [UNTESTED] (if (and (setq p (getpoint "\nSpecify insertion point :")) (setq dlt (vla-insertblock (vla-get-block (vla-get-activelayout (vla-get-ActiveDocument (vlax-get-acad-object)) ) ) (vlax-3d-point p) path 1. 1. 1. 0. ) ) (null (vl-catch-all-error-p (vl-catch-all-apply 'vla-explode (list dlt)))) ) (vla-delete dlt) ) And add this (vl-load-com) at the end of the program to load the library of vla-* functions. Quote
jjatho Posted July 14, 2015 Author Posted July 14, 2015 That works! The only thing I kind of liked better about my way was that before picking the insertion point, you could see the block already in the drawing. This helped a bit when tyrying to find the best insert location, since this cranes are gigantic. I think I can live with it though. Thank you! Quote
Tharwat Posted July 14, 2015 Posted July 14, 2015 one more example . (setq pre:ent (entlast)) (command "_.-insert" path "S" "1" "R" "0") (if (and (not (eq pre:ent (setq new (entlast)))) (eq (cdr (assoc 0 (entget new))) "INSERT") ) (command "_.explode" new) ) NOTE: don't forget to localize the variables. Quote
jjatho Posted July 14, 2015 Author Posted July 14, 2015 Hmmm, that one shows me the preview of the block before picking the insertion point, but does not explode the block. Quote
Tharwat Posted July 14, 2015 Posted July 14, 2015 So with all these examples you can chose the one that suits your needs. Good Luck. 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.