Jump to content

Recommended Posts

Posted

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.

Posted

(0 . "Polyline")

or for both

(0 . "*POLYLINE")

 

(setq pllist ((ssget '((8 . "AM_0") (0 . "Polyline")))

Posted

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

Posted
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 ?

Posted
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.

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

Posted

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.

Posted (edited)

You could always use QSELECT also... Just saying. :wink:

 

hey.snoopy.i'm.bringing.sexy.back.jpg

hey-snoopy-im-bringing-sexy-back.jpg

Edited by BlackBox
Posted

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

Posted

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:

Posted

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?

Posted

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

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