Jump to content

Recommended Posts

Posted

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?

Posted

in the block editor has the "Allow Exploding" parameter been set to "no"?

Posted

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

Allow Exploding.jpg

Posted

Ok I don't know how to write code -- but -- what is wrong with using the (explode command) that came with the program?

Posted

All of them are able to explode. I just select them and explode manually for now.

Posted

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 :)

Posted

Why code it if it's a native AutoCAD command?

 

Explode on insert is an option in the insert block command.

Explode Block.png

Posted

Can I modify the following line of code:

 

(command "insert" path "S" "1" "R" "0")

 

To explode the same as that?

Posted

Sorry I responded, I forgot I was in the coding forum.

Posted
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")

Posted
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.

Posted
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 .

Posted

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?

Posted
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.

Posted

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!

Posted

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.

Posted

Hmmm, that one shows me the preview of the block before picking the insertion point, but does not explode the block.

Posted

So with all these examples you can chose the one that suits your needs. :)

 

Good Luck.

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...