neeboy74 Posted June 14, 2016 Share Posted June 14, 2016 (edited) AAAARGH!!! Everywhere I look, everyone wants to change the layer/color of ALL the elements in a block. I have the exact opposite condition, I need to reach into a block and change individual elements to different layers. Here's what I have: (defun C:test (/ ss e blk doc) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (if (setq ss (ssget ":L" '((0 . "INSERT")))) (repeat (setq i (sslength ss)) (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (setq blk (vla-item (vla-get-blocks doc) (vla-get-Effectivename e))) (vlax-for x blk (vla-put-layer x "MDUCT");your layer here ) ) ) (vla-regen doc acAllViewports) (princ) ) This routine will, unfortunately, change EVERYTHING in a block to a specified layer, and that's NOT what I need. I need to be able to, without opening the block editor, pick and change individual elements to different layers. If possible, I also need the objects to highlight themselves when picked, just like outside the editor in normal space as separate entities. Thanks in advance for any help! Edited June 14, 2016 by rkmcswain added [CODE] tags Quote Link to comment Share on other sites More sharing options...
tmelancon Posted June 14, 2016 Share Posted June 14, 2016 brackets please: [code](defun C:test (/ ss e blk doc) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (if (setq ss (ssget ":L" '((0 . "INSERT")))) (repeat (setq i (sslength ss)) (setq e (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (setq blk (vla-item (vla-get-blocks doc) (vla-get-Effectivename e))) (vlax-for x blk (vla-put-layer x "MDUCT");your layer here ) ) ) (vla-regen doc acAllViewports) (princ) ) Quote Link to comment Share on other sites More sharing options...
rkmcswain Posted June 14, 2016 Share Posted June 14, 2016 How do you want to "pick" the elements to change? By physically picking on the screen? Quote Link to comment Share on other sites More sharing options...
tmelancon Posted June 14, 2016 Share Posted June 14, 2016 Sounds like C:REFEDIT Quote Link to comment Share on other sites More sharing options...
neeboy74 Posted June 14, 2016 Author Share Posted June 14, 2016 Yes, I want to pick the elements individually on the screen. The routine would then drop them onto a layer predesignated in the code. Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted June 14, 2016 Share Posted June 14, 2016 Using nentsel is probably the only way to achieve this. But highlighting is not possible with that function. (defun c:test ( / doc enm) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (while (setq enm (car (nentsel))) (vla-put-layer (vlax-ename->vla-object enm) "MDUCT") (vla-regen doc acactiveviewport) ) (vla-regen doc acallviewports) (vla-endundomark doc) (princ) ) Quote Link to comment Share on other sites More sharing options...
neeboy74 Posted June 15, 2016 Author Share Posted June 15, 2016 GREAT!!! No problem about the highlighting thing, your routine will still save me a lot of time and grief! 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.