Jump to content

Recommended Posts

Posted

I need a lisp routine to explode block and preserve it's Object Data table values.

Posted

Sorry, I though it was clear.
Well, here is testing dwg, containing one block and this block has simple object data table. When I explode block, using explode or burst command, OD table is gone.
I want to keep it.

OD.JPG

Test.dwg

Posted (edited)

what is the reason for expolding the block if you want to keep the data?

Edited by mhupp
Posted

You can get the first Table assigned to an entity with ade_odgettables and get the field data using ade_odgetfield with the entity, table, and field get the value but there's no way to explode an entity and preserve it's Object Data table values.

 

Why would you want to explode a block anyway?

 

I've got an old lisp by Stephen Grisez that takes elevation Object Data from GIS contours and assigns that elevation to the contour lines. It would take a little work but you could add attributes to those blocks with those Object Data values.

 

I have to update my Object Data code here because our GIS folk keep changing how it's arraigned every few years.

Posted

This block with OD table in my drawing is just a simple one, making for test. I have more complex objects and tables in my drawings.
I have many reasons why explode block. I don't wish to explain them.
Maybe just this. I have got a lisp routine "Sel_By_OD" to search objects in drawing by specific OD table values. If block contains this data, it can't find it. That's one.
Anyway, I was just curious if that kind of exploding is possible in simple way. Obviously it is not at all.
If I have just one or two objects to explode, I can manage situation by making copy of this block, eksplode original, copy OD from  copyed one and then delet it. Plain procedure.
But If I wish to explode 50 blocks and more, than this process is very long and annoying.
Thanks for your response and help.

Posted

Had it been attached to a LWPOLYLINE you could have broken it in pieces and kept the Object Data https://forums.augi.com/showthread.php?172867-Lisp-needed-to-explode-break-a-closed-pline

Maybe you could talk to whoever is creating those blocks about their process.

 

Haven't tried it but it might work. Copy the blocks you wish to modify to a new drawing, then modify and rename them. If that preserves the Object Data you could replace the ones in the first drawing.

Posted
48 minutes ago, tombu said:

Had it been attached to a LWPOLYLINE you could have broken it in pieces and kept the Object Data https://forums.augi.com/showthread.php?172867-Lisp-needed-to-explode-break-a-closed-pline

Maybe you could talk to whoever is creating those blocks about their process.

 

Haven't tried it but it might work. Copy the blocks you wish to modify to a new drawing, then modify and rename them. If that preserves the Object Data you could replace the ones in the first drawing.

 

Thank you, but it's not working for me.
I don't want to modify all blocks with same name in drawing. I want  to transform some of them to plain objects, and the rest leave as block.

Transfering blocks to other drawing, editing and sending them back, seems to me too complicated process.
Even if I modify block in editor, explode to lines or polylines and save it, it keeps data, but it is still a block. If I want plain object I have to explode it.
I don't know any other options except exploding.

Posted
5 hours ago, Jest said:

 

Thank you, but it's not working for me.
I don't want to modify all blocks with same name in drawing. I want  to transform some of them to plain objects, and the rest leave as block.

Transfering blocks to other drawing, editing and sending them back, seems to me too complicated process.
Even if I modify block in editor, explode to lines or polylines and save it, it keeps data, but it is still a block. If I want plain object I have to explode it.
I don't know any other options except exploding.

Use something like this .. it will leave your block intact and give you the pieces for whatever you're using them for:

(defun c:foo (/ r s)
  ;; RJP » 2021-08-12
  (cond	((setq s (ssget ":L" '((0 . "insert"))))
	 (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   ;; Creates a list of lists of vla objects for whatever your task is
	   (setq r (cons (vlax-invoke (vlax-ename->vla-object e) 'explode) r))
	 )
	)
  )
  (princ)
)

 

Posted

Hi ronjonp, what's the difference between   (vla-explode  obj) and (vlax-invoke obj 'explode)?

As I know. 

For the first case I know it return a VARIANT , holding all BLOCK enty.  as OBJ 

 

Another fact , why not to use (setq  obj-ss (VLA-GET-ACTIVESELECTIONSET ADOC))

after a ent-ss by ssget , that way the obj-ss can be handle by VLAX-FOR obj obj-ss, no need to convert ent to obj 

 

Just an idea. 

 

 

 

 

 

Posted
1 hour ago, devitg said:

Hi ronjonp, what's the difference between   (vla-explode  obj) and (vlax-invoke obj 'explode)?

As I know. 

..

Vlax-invoke return a list of objects that can be easily manipulated. Vla-explode returns a variant that has to be converted to a list of objects. 

 

As far as the selection set goes it could be done as you describe but I prefer my slow method 😅

Posted

Thanks devitg this may be the answer to another post that was select first then make into selection set. Now where was it.

 

(setq  obj-ss (VLA-GET-ACTIVESELECTIONSET  (vla-get-activedocument (vlax-get-acad-object))))
(setq sel (ssadd))
(vlax-for obj obj-ss
(ssadd (vlax-vla-object->ename obj) sel)
)

 

  • 1 month later...
Posted
On 8/12/2021 at 7:56 PM, ronjonp said:

Use something like this .. it will leave your block intact and give you the pieces for whatever you're using them for:


(defun c:foo (/ r s)
  ;; RJP » 2021-08-12
  (cond	((setq s (ssget ":L" '((0 . "insert"))))
	 (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   ;; Creates a list of lists of vla objects for whatever your task is
	   (setq r (cons (vlax-invoke (vlax-ename->vla-object e) 'explode) r))
	 )
	)
  )
  (princ)
)

 

Hi
Sorry for my delay and thank you for reply...
I must tell, this lisp still not solving my problem.
Block contains Object data table ant it is not transfered to exploded object.
I must copy it from block after, and that is what I dont like, especially wheh exploded multiple blocks at one time.

Posted
8 hours ago, Jest said:

Hi
Sorry for my delay and thank you for reply...
I must tell, this lisp still not solving my problem.
Block contains Object data table ant it is not transfered to exploded object.
I must copy it from block after, and that is what I dont like, especially wheh exploded multiple blocks at one time.

Curious as to why you need to explode your blocks?

Posted
2 hours ago, ronjonp said:

Curious as to why you need to explode your blocks?

I don't want to explain....why I need to explode my block...
I am just asking, if it possible...
I finally believe it is not...thank you aniway!

Posted

Why would you not get the object data and make say Mtext then explode block. 

Posted
5 hours ago, Jest said:

I don't want to explain....why I need to explode my block...
I am just asking, if it possible...
I finally believe it is not...thank you aniway!

Cool the jets Jest 😉 it was a simple question. It is possible to explode the block as I've shown above. I don't use object data, but why is copying to the items after after such a hassle?

 

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