Carsten Trolle Posted July 6, 2010 Share Posted July 6, 2010 Hi, I have been struggling the past days trying to accomplish the following: I have an exisiting block definition (blockname could be: "ParentBlock1") in this block is inserted a another block (blockname could be "ChildBlockOld"). In the definition of ParenBlock1, I want to replace ChildBlokcOld with ChildBlockNew. I got some experience with good old AutoLisp but I don't think the "classic" functions for entity manipulation can do the job. The VisualLisp (vlax- & vla- stuff) and object apporach is unknown turf. Therefore I searched the web for inspiration and found 2 visual lisp routines, which seems to be made for this purpose (thanks to the guy who posted these originally) ax:deleteObjectFromBlock and ax:AddObjectsToBlock The "Delete-piece" works fine, and removes the ChildBlockOld from ParentBlock1, but I get all kind of error messages when I try to add the ChildBlockNew. It is possibly me doing sopmething wrong or missing the obvious. Are anybody familiar with these 2 routines or similar which will do the job, and can guide me in the right direction. B.R carsten Quote Link to comment Share on other sites More sharing options...
dbroada Posted July 6, 2010 Share Posted July 6, 2010 I have no idea how to do this using LISP but from AutoCAD you just need to insert the new definition file into the current drawing. -INSERT ChildBlokcOld=ChildBlockNew When AutoCAD asks if you want to redefine the block you say "yes" and its done. Doing it this way keeps the original block name so you will have to rename it. Quote Link to comment Share on other sites More sharing options...
Carsten Trolle Posted July 6, 2010 Author Share Posted July 6, 2010 Dave, Thanks for your repsonse. I followed your advice, but if I understand this feature correclty, it is not exactly what I am looking for. All block definitions in my sample lies within the current drawing and not from a separate .dwg file. Furthermore it is the definition of "parentBlock1" I want to modify (replace the "nested" or "inserted" ChildBlockOld with ChildBlockNew) but I still want to keep both the initial ChildBlock definitions in unchanged form. Did I miss out on something in your proposal? BR carsten Quote Link to comment Share on other sites More sharing options...
dbroada Posted July 6, 2010 Share Posted July 6, 2010 my suggestion modifys parentBlock1 by changing the definition of the block within it. If you want a collection of ParentBlock1s, some with ChildBlockOld and some with ChildBlockNew it cannot be done using standard blocks. You will eitehr require ParenBlock2 or a dynamic block. If however you want all ParentBlock1 to contain ChildBlockNew but still retain both child blocks then again that is easy using AutoCAD but beyond my LISP ability. Just open ParentBlock1 in BEDIT and swap ChildBlock definitions there. Quote Link to comment Share on other sites More sharing options...
Carsten Trolle Posted July 6, 2010 Author Share Posted July 6, 2010 I am looking for the second of the 2 alternatives in your reply (all instances of ParentBlock1 in the drawing should contain ChildBlockNew). I just tried to look at the block editor, forgive me for a stupid question, but how can "swap" the 2 childblocks from inside BEDIT. If I get the commands right, I may be able to automate it through the lisp (command "something" ..... ) functions. Carsten Quote Link to comment Share on other sites More sharing options...
dbroada Posted July 6, 2010 Share Posted July 6, 2010 erase ChildBlockOld, insert ChildBlockNew Quote Link to comment Share on other sites More sharing options...
Carsten Trolle Posted July 6, 2010 Author Share Posted July 6, 2010 Dave, Mission accomplished.Thanks a lot for your continous replies and getting me on the right track here. Sorry about the late reply, but I was without internet for some hours. I got it to work by firing lisp commands inside the block editor. Just wish I had made contact with you 3 days ago, before struggling with all this vla(x)-stuff, which I must admit is probably to hairy for me :-) Carsten Quote Link to comment Share on other sites More sharing options...
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.