Jump to content

Polyline change fra layer AM_0 til 0


elfert

Recommended Posts

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.

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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 ?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)
                 )
           )
     )

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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. ;)

Link to comment
Share on other sites

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. :thumbsup:

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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))

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...