elfert Posted January 21, 2012 Share Posted January 21, 2012 I am trying to make a routine that could change all polylines in a drawing from layer AM_0 to 0. But i can't get i to work. (defun C:chgpllnul ( / pllist ) (setq pllist ((ssget '((8 . "AM_0") (0 . "Polyline"))) (command "change" pllist "" "P" "LA" "0" "" ))) ) Please help! Thx in advance. Quote Link to comment Share on other sites More sharing options...
pBe Posted January 21, 2012 Share Posted January 21, 2012 (0 . "Polyline") or for both (0 . "*POLYLINE") (setq pllist ((ssget '((8 . "AM_0") (0 . "Polyline"))) Quote Link to comment Share on other sites More sharing options...
Sweety Posted January 21, 2012 Share Posted January 21, 2012 I think this work (defun C:chgpllnul (/ pllist slen sname entlst) (if (setq pllist (ssget '((8 . "AM_0") (0 . "*Polyline")))) (repeat (setq slen (sslength pllist)) (setq sname (ssname pllist (setq slen (1- slen)))) (entmod (subst (cons 8 "0") (assoc 8 (setq entlst (entget sname))) entlst ) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
stevesfr Posted January 21, 2012 Share Posted January 21, 2012 I think this work (defun C:chgpllnul (/ pllist slen sname entlst) (if (setq pllist (ssget '((8 . "AM_0") (0 . "*Polyline")))) (repeat (setq slen (sslength pllist)) (setq sname (ssname pllist (setq slen (1- slen)))) (entmod (subst (cons 8 "0") (assoc 8 (setq entlst (entget sname))) entlst ) ) ) ) (princ) ) Neither #2 or #3 works. (using A2008) so ? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted January 21, 2012 Share Posted January 21, 2012 Neither #2 or #3 works. (using A2008) so ? Without testing #3 myself (nothing jumps out to me as to why it wouldn't work?), you could always iterate the VLA ActiveSelectionSet Object, and use vla-put-layer Method as an alternative. Quote Link to comment Share on other sites More sharing options...
pBe Posted January 22, 2012 Share Posted January 22, 2012 Neither #2 or #3 works. (using A2008) so ? (defun C:chgpllnul (/ pllist) (setq pllist (ssget '((8 . "AM_0") (0 . [b][color=darkolivegreen]"*Polyline"))))[/color][/b] (command "change" pllist "" "P" "LA" "0" "")) ) from (defun C:chgpllnul ( / pllist ) (setq pllist [b][color=#0000ff]([/color][/b](ssget '((8 . "AM_0") (0 . [b]"[/b][color=blue][b]Polyline"[/b])))[/color] (command "change" pllist "" "P" "LA" "0" "" ))[b][color=blue])[/color][/b] ) and while we're at it (defun C:chgpllnul (/ pllist (if (ssget '((8 . "AM_0") (0 . "*Polyline"))) (progn (vlax-for itm (setq pllist (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (vla-put-layer itm "0") ) (vla-delete pllist) ) ) ) Quote Link to comment Share on other sites More sharing options...
Dadgad Posted January 22, 2012 Share Posted January 22, 2012 You could do this very easily with your action recorder, if you have your quick properties palette turned on to provide the POLYLINE filter selection, then just change the layer on the quick properties palette. Not sexy, but it would work. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted January 22, 2012 Share Posted January 22, 2012 (edited) You could always use QSELECT also... Just saying. :wink: Edited January 22, 2012 by BlackBox Quote Link to comment Share on other sites More sharing options...
pBe Posted January 22, 2012 Share Posted January 22, 2012 Point taken guys... In fairness to the OP, he did ask for help why he cant get his code to work .. but then again it wouldnt hurt to know you can use native commands for such a task. Quote Link to comment Share on other sites More sharing options...
Dadgad Posted January 22, 2012 Share Posted January 22, 2012 You make a good point RenderMan. I have never used it before, have used FILTER though, looks pretty similar. I always use my quick properties palette, so get an awful lot of handy information and limited selectivity there, but I will definitely start using this, good tool, I've seen it mentioned a lot, thanks. Quote Link to comment Share on other sites More sharing options...
elfert Posted January 23, 2012 Author Share Posted January 23, 2012 Year i know that it possible to filter out using quick select. Just one problem we sometimes have a lot sheet metal cuts geometry that has to be a polyline and layer 0. So i need to write a routine ´that could easy find all Poly lines that is laying on AM_0 and move it to 0. Thx any way. I am thing about to make it more advance so it don't look only for layer AM_0 but any poly line that is different from layer 0. Any suggestion? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted January 24, 2012 Share Posted January 24, 2012 Give this a try :wink:: (defun c:FOO ( / ss) (if (setq ss (ssget "_x" (list '(0 . "*POLYLINE") '(8 . "AM_0") (cons 410 (getvar 'ctab))))) (sssetfirst nil ss)) (princ)) 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.