Michaels Posted February 19, 2011 Posted February 19, 2011 hello . I wonder why these codes are changing all circles in my dwg to color 1 and not only these in blocks , although that I included them within the Block definition only ? (vlax-for blocks (vla-get-blocks (setq M:cad (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for o blocks (if (wcmatch (vla-get-objectname o) "AcDbCircle") (vla-put-color o 1)) ) ) (vla-regen M:cad acActiveViewport) Thanks in Advance. Quote
pBe Posted February 19, 2011 Posted February 19, 2011 hello . I wonder why these codes are changing all circles in my dwg to color 1 and not only these in blocks , although that I included them within the Block definition only ? (vlax-for blocks (vla-get-blocks (setq M:cad (vla-get-activedocument (vlax-get-acad-object)))) (vlax-for o blocks (if (wcmatch (vla-get-objectname o) "AcDbCircle") (vla-put-color o 1)) ) ) (vla-regen M:cad acActiveViewport) Thanks in Advance. This is included in the process: # # Try something like this (vlax-for blocks (vla-get-blocks (setq M:cad (vla-get-activedocument (vlax-get-acad-object)))) [color=blue](if (not (wcmatch (vla-get-name blocks) "*Paper*,*Model*"))[/color] (vlax-for o blocks (if (wcmatch (vla-get-objectname o) "AcDbCircle") (vla-put-color o 1)) ) ) [color=blue])[/color] Quote
Lee Mac Posted February 19, 2011 Posted February 19, 2011 Another way to check would be: (vlax-for block (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object) ) ) (if (and (eq :vlax-false (vla-get-isLayout block)) (eq :vlax-false (vla-get-isXref block)) ) (vlax-for obj block (if (eq "AcDbCircle" (vla-get-objectname obj)) (vla-put-color obj 1) ) ) ) ) Quote
Michaels Posted February 19, 2011 Author Posted February 19, 2011 So nice , Thank you pBe and Lee . So I should have excluded the paper and Model spaces while trying to change the entities in block's definitions only. Right ? Appreciated. Quote
Lee Mac Posted February 19, 2011 Posted February 19, 2011 So I should have excluded the paper and Model spaces while trying to change the entities in block's definitions only. Right ? Correct (I would also exclude Xrefs too). The ModelSpace/PaperSpace objects are also included in the Blocks collection, containing all the objects in Model space and Paper space respectively, hence by iterating through these block definitions you are iterating through all the objects in Model and Paper space. Lee Quote
pBe Posted February 20, 2011 Posted February 20, 2011 Correct (I would also exclude Xrefs too). The ModelSpace/PaperSpace objects are also included in the Blocks collection, containing all the objects in Model space and Paper space respectively, hence by iterating through these block definitions you are iterating through all the objects in Model and Paper space. Lee Thats right, learned that the hard way too Quote
Lee Mac Posted February 20, 2011 Posted February 20, 2011 Thats right, learned that the hard way too At least you'll never forget it now :wink: 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.