elfert 发表于 2022-7-6 08:23:40

Polyline change fra layer AM_0

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.

pBe 发表于 2022-7-6 08:33:31

(0 . "Polyline")
or for both
(0 . "*POLYLINE")
 
(setq pllist ((ssget '((8 . "AM_0") (0 . "Polyline")))

Sweety 发表于 2022-7-6 08:39:20

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

stevesfr 发表于 2022-7-6 08:44:22

 
Neither #2 or #3 works.(using A2008)   so ?

BlackBox 发表于 2022-7-6 08:47:22

 
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.

pBe 发表于 2022-7-6 08:53:38

 

(defun C:chgpllnul(/ pllist)   (setq pllist (ssget '((8 . "AM_0") (0 . "*Polyline"))))   (command "change" pllist "" "P" "LA" "0" "")))
 
from
 

(defun C:chgpllnul ( / pllist ) (setq pllist ((ssget '((8 . "AM_0") (0 . "Polyline")))(command "change" pllist "" "P" "LA" "0" "" ))))
 
 
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)               )         )   )

Dadgad 发表于 2022-7-6 09:00:35

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.

BlackBox 发表于 2022-7-6 09:02:33

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

http://img2.moonbuggy.org/imgstore/hey-snoopy-im-bringing-sexy-back.jpg

pBe 发表于 2022-7-6 09:10:06

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 usenative commands for such a task.

Dadgad 发表于 2022-7-6 09:14:06

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.
页: [1] 2
查看完整版本: Polyline change fra layer AM_0