Jest Posted August 10, 2021 Posted August 10, 2021 I need a lisp routine to explode block and preserve it's Object Data table values. Quote
BIGAL Posted August 11, 2021 Posted August 11, 2021 Bit hard with nothing to look at need sample dwg. 1 Quote
Jest Posted August 11, 2021 Author Posted August 11, 2021 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. Test.dwg Quote
mhupp Posted August 12, 2021 Posted August 12, 2021 (edited) what is the reason for expolding the block if you want to keep the data? Edited August 12, 2021 by mhupp Quote
tombu Posted August 12, 2021 Posted August 12, 2021 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. Quote
Jest Posted August 12, 2021 Author Posted August 12, 2021 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. Quote
tombu Posted August 12, 2021 Posted August 12, 2021 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. Quote
Jest Posted August 12, 2021 Author Posted August 12, 2021 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. Quote
ronjonp Posted August 12, 2021 Posted August 12, 2021 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) ) Quote
devitg Posted August 13, 2021 Posted August 13, 2021 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. Quote
ronjonp Posted August 13, 2021 Posted August 13, 2021 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 Quote
BIGAL Posted August 14, 2021 Posted August 14, 2021 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) ) Quote
Jest Posted September 21, 2021 Author Posted September 21, 2021 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. Quote
ronjonp Posted September 21, 2021 Posted September 21, 2021 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? Quote
Jest Posted September 21, 2021 Author Posted September 21, 2021 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! Quote
BIGAL Posted September 22, 2021 Posted September 22, 2021 Why would you not get the object data and make say Mtext then explode block. Quote
ronjonp Posted September 22, 2021 Posted September 22, 2021 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? 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.