Apache2k Posted September 1, 2015 Posted September 1, 2015 Hi folks. Have been trying to make s lisp code for a simple task but turned out that it might not be so easy. I found lots of information but not this one. So i'm asking if this is even possible to do. I have a block and it has many entities. The block has a name but all the (2-3) entities have different color. I'm trying to change the entity color without exploding the block and change the entity name. This part is ok and i even found a good solution for this. However the problem is that i have to rename also the main block regarding the selected color for the entity. I have 5-10 options for color. (112=blue, 113=red etc.) So the final block name should turn out as 123456-112. I know how to find the block name and change but when i go deep into entities then i dont have the DXF code for the original block name. So here i am in an endless loop. Can someone assist or show me some directions how to manage with this? Thanks. Quote
Lee Mac Posted September 1, 2015 Posted September 1, 2015 When you modify a block definition, the changes will affect all references of the block in the drawing. From your description, it sounds as though you are looking to rename individual references of a single block definition - this is not possible without duplicating the block definition for every new block name that you wish to create, however, if you do wish to pursue this route, my Copy or Rename Block Reference program will show you how. Alternatively, I would suggest changing the colour of the components in your block definition to ByBlock, and then changing the colour of each block reference to suit. Quote
Apache2k Posted September 1, 2015 Author Posted September 1, 2015 (edited) Thank you Lee for helping. Not sure if i got this right. The function i need will be used to modify existing blocks that are on the right location. My problem is that i can change the block by using rename but i must first be able to change the entity color and then rename the block as selected block name xxxxx-112 Our blocks are nested but don't have a names. Parts are modeled by using component colors. Also the block definition modify should change all the same blocks as mentioned. In my case the copy and rename is not needed. If i have five of these blocks in adwg and the color has been changed then its ok that all of the same blocks are renamed. Edited September 1, 2015 by Apache2k Quote
Apache2k Posted September 2, 2015 Author Posted September 2, 2015 Now i came so far that i am able to change the entity colors but how can i find out the entity main block name while using nentsel? Any tips? Quote
hmsilva Posted September 2, 2015 Posted September 2, 2015 Try (vl-load-com) (defun c:demo (/ nsel l ll) (if (and (princ "\nSelect a block entity: ") (setq nsel (nentsel)) (setq l (last nsel)) (setq ll (last l)) (= (type ll) 'ENAME) ) (progn (setq obj (vlax-ename->vla-object ll) name (vla-get-effectivename obj) ) (princ (strcat "\nThe block name is: " name)) ) (princ "\nThe selected object was not from a block...") ) (princ) ) I hope this helps. Henrique Quote
Apache2k Posted September 2, 2015 Author Posted September 2, 2015 Thank you thank you hmsilva works perfect. Well got just another question. I have found a function that is calling "(setq color (acad_colordlg 256))" However i have build a dcl where i give only 4-7 options to the color. what would be the preferred way to replace the dialog box? Now i got these: Changed (setq color (acad_colordlg 256)) to (setq color (def_function)) (setq width (dimx_tile "im1") height (dimy_tile "im1") ) (start_image "im1") (fill_image 0 0 width height 20) (end_image) and (action_tile "im1" "(setq la (itoa 20))") This gives me the error message: Command: ; error: bad argument type: stringp 20 Quote
hmsilva Posted September 2, 2015 Posted September 2, 2015 Thank you thank you hmsilva works perfect. You're welcome,Apache2k! Well got just another question. I have found a function that is calling "(setq color (acad_colordlg 256))" However i have build a dcl where i give only 4-7 options to the color. what would be the preferred way to replace the dialog box? ... This gives me the error message: Command: ; error: bad argument type: stringp 20 The error means 'the function expects a 'string' and is receiving a 20. But in that piece of code, i can't see what may be causing that error... Henrique Quote
Apache2k Posted September 3, 2015 Author Posted September 3, 2015 Figured out the problem. I was calling the wrong function from the wrong place. And sorry for the bad information, i did notice that it wont help anyone. I'll try next time be more specific. Quote
Apache2k Posted October 1, 2015 Author Posted October 1, 2015 One more question from the same project. ((1.0 0.0 0.0) (0.0 1.0 0.0) (0.0 0.0 1.0) (5400.0 -1800.0 0.0))(6571.82 -607.697 0.0) How can i force the lisp to select this only (6571.82 -607.697 0.0) from the list on top? Quote
hmsilva Posted October 1, 2015 Posted October 1, 2015 One more question from the same project.((1.0 0.0 0.0) (0.0 1.0 0.0) (0.0 0.0 1.0) (5400.0 -1800.0 0.0))(6571.82 -607.697 0.0) How can i force the lisp to select this only (6571.82 -607.697 0.0) from the list on top? perhaps something like this... (setq sel (nentselp (last '((1.0 0.0 0.0) (0.0 1.0 0.0) (0.0 0.0 1.0) (5400.0 -1800.0 0.0) (6571.82 -607.697 0.0))))) Henrique 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.