Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to modify this lsp to make the new inserted Blocks Explode?

6 REPLIES 6
Reply
Message 1 of 7
Patchy
381 Views, 6 Replies

How to modify this lsp to make the new inserted Blocks Explode?

Thanks for your help.

6 REPLIES 6
Message 2 of 7
Kent1Cooper
in reply to: Patchy

One way is to use the Block name with an asterisk at the beginning, which puts it in pre-exploded.  I don't know whether you can do that in the (vlax-invoke-method) approach, but if you use the Insert command, you can:

 

(command "_.insert" (strcat "*" bname) '(0 0 0) 1 0)

 

[I used 0,0,0 as described at the top of the file, rather than 35.5,0.5,0 as in the code -- use what you really want.]

 

Note that when you Insert something pre-exploded, you only get to give it one scale factor, not three.

 

Or, you can follow the insertion with an Exploding of the last object.

Kent Cooper, AIA
Message 3 of 7
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

.... 

(command "_.insert" (strcat "*" bname) '(0 0 0) 1 0)

.... 

Or, you can follow the insertion with an Exploding of the last object.


It occurred to me that one big advantage of Inserting something pre-exploded, as compared to Inserting it and then Exploding it, is that the former brings the pieces of the Block into the drawing, but does not bring in the Block definition.  So there's no memory consumed by that, and no need to purge all such Block definitions if you want to minimize the file size.

 

But what some might, under certain circumstances, consider a disadvantage is that if there's already a Block by that name in the drawing, it will not ask whether you want to redefine it.  If you want a definition from outside the drawing under those conditions, you would need to put the asterisk before the complete filepath and name, not just the Block name.

Kent Cooper, AIA
Message 4 of 7
Patchy
in reply to: Kent1Cooper

Thank you Kent1Cooper, I thought this would be a simple editing but it turned out not . I will search a little more for a lisp that explode last object on all layouts.

 

Message 5 of 7
Kent1Cooper
in reply to: Patchy


@Patchy wrote:

Thank you Kent1Cooper, I thought this would be a simple editing but it turned out not . I will search a little more for a lisp that explode last object on all layouts.


It might be possible with simple editing.  I'm not familiar enough with the (vlax-invoke-method) approach, but others can probably say.  It could be as simple as using (strcat "*" bname) in place of bname, if you can do a pre-exploded one with that method, or invoking Explode on each newblk after putting it in.

Kent Cooper, AIA
Message 6 of 7
pbejse
in reply to: Patchy

(progn
                        (setq blk (vla-get-block x))
                        (vla-explode
                              (vlax-invoke-method
                                    blk
                                    'insertblock
                                    (vlax-3d-point
                                          '(35.5 0.5 0.0))
                                    bname
                                    1.0
                                    1.0
                                    1.0
                                    0.0)))

 

Message 7 of 7
Patchy
in reply to: pbejse

Wonderful, It's working good.

Thank you pbejse and Kent  for your help.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost