PDA

View Full Version : Moving existing data (ellipses) to new a newly created layer


Lions60
2006-07-20, 04:41 PM
I am trying to move existing ellipses in dxf drawings to a new layer so at a later time they can be distinguished and converted to polylines more easily. I do have some of the code written but can't quite figure out how to get the existing elipses moved on the new layer.

Here is the code maybe someone can help:

(defun ellp2nwlyr ( / ent ename elist)
(setq ent(ssget "X" ' ((0 . "ELLIPSE"))))
(setq numb(sslength ent))
(setq count 0)
(repeat count
(setq ename (cdr ent))
(setq elist (entget ename))
(if (= (cdr (assoc 0 elist)) "ELLIPSE") ;is that something a circle?
(progn
(if (tblsearch "layer" "ellipse")
(command "-layer" "s" "ellipse")
(command "-layer" "m" "ellipse" "c" "red" "ellipse" "")
);;end of if
);; end of progn
);; end of if
);; end of repeat
);; end of program

I do know this selects all ellipses in the drawing and it creates a new layer called "ellipse" but need some help getting the ellipses on this layer.

[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]

intergrupocr
2006-07-20, 05:05 PM
You have to change the association 8 of the selected entities, something like this:

(setq elist (subst (cons 8 "ELLIPSE") (assoc 8 elist) elist))
(entmod elist)

And you don't need this line: "(if (= (cdr (assoc 0 elist)) "ELLIPSE") " because you select only ellipses.

Let me know if this help you!!

miff
2006-07-20, 05:07 PM
Here are some thougts on this....

Here is the code maybe someone can help:
(defun ellp2nwlyr ( / ent ename elist)
(setq ent(ssget "X" ' ((0 . "ELLIPSE"))))
(setq numb(sslength ent))
(setq count 0)
(repeat count ;;;;no need to repeat, especially checking/setting/creating the layer, just use the ss in a command call
(setq ename (cdr ent))
(setq elist (entget ename))
(if (= (cdr (assoc 0 elist)) "ELLIPSE") ;is that something a circle? why this? you already filtered for only ellipses....
(progn
(if (tblsearch "layer" "ellipse")
(command "-layer" "s" "ellipse")
(command "-layer" "m" "ellipse" "c" "red" "ellipse" "")
);;end of if
);; end of progn
);; end of if
);; end of repeat
);; end of program

Here's how I'd do it:

(defun ellp2nwlyr ( / ent ename elist)
(if (setq ent (ssget "X" ' ((0 . "ELLIPSE"))))
(progn
(if (tblsearch "layer" "ellipse")
(command "-layer" "s" "ellipse")
(command "-layer" "m" "ellipse" "c" "red" "ellipse" "")
);;end of if
(command "_.chprop" ent "" "la" "ellipse" "")
)
)
);; end of program

HTH,
Jeff

Lions60
2006-07-20, 07:13 PM
Thanks for the help looks like I had most of the information there jsut not in the right order. Also learned a new command in the process( _.chprop). I appreciate the help and again thanks.