copy layer and sort, sometime
this code is for detailing by layer name the layer must all open/show, user select the all layer and give the place point, my problem with this code is, the layer is not sort by number (my layer is 01 02 03 04 and so on) and sometime double copy with same layer name.any solution plstq(defun dtr (a) (* pi (/ a 180.0)) )(defun c:detlay () (setq ppt1 (getpoint "\nPlace:"))(setq ssob (ssget))(setq ii 0)(setq dwqty 0)(while (setq obnum (cdr (assoc 8 (entget (ssname ssob ii)))))(setq lyr (tblsearch "LAYER" obnum)) (setq lnm (cdr (assoc 2 lyr))) (setq sellay (ssget "_X" (list (cons 8 obnum))))(command "_copy" sellay "" (polar ppt1 (dtr 270.0) dwqty)"")(setq ii (1+ ii))(setq dwqty (+ dwqty 50)) ) ) First of all. wrap your code using the button -> #
(read Sticky Thread: posting guidelines)
as it stands now:
(setq obnum (cdr (assoc 8 (entget (ssname ssob ii)))))
This will generate an error as this line will not issue a nil value for the while function.
better to use
(repeat (sslength ssob) (setq obnum....
This line is irrelevant
(setq lyr (tblsearch "LAYER" obnum))(setq lnm (cdr (assoc 2 lyr)))
Also make it a point localize your variable
(defun c:detlay (/ ppt1 ssob ii dwqty )
and since you're only going to use this oince
(defun dtr (a) (* pi (/ a 180.0)) )
(command "_copy" sellay "" (polar ppt1 (dtr 270.0) dwqty)"") the code you re-create it's was no error but the result is still same
with my old code, the selected object copy repeated with same layer name
i dont want like that, what i want only 1 time copy and place it to new location
let say: i have 3 different layer all opened with same place (overlap)
i want to copy each layer to other place with distance (setq dwqty (+ dwqty 50)) each other
so user can see the object of layer without crossing object with all layer
Well. i suggest you look at it againand i meant it to do the same thing as i dont know yet what you wanted in the first place
I see, so copy the layer to another location: 3 overlapping entities, different layers, make a copy of the 1st of 3 layers and place it at a given angle and distance after that the 2nd of 3 layers at the same angle and twice the distance as the 1st one, and so on. but limited only to the selected objects? is this correct? selected by user only
okidoki,
to clarify, make a copy and not move? (sort of separate)
user will make selection of object than coding will separate the each layer and copy layer to other place input by user
and repeat next layer till the layer finish
Not sure if this is want you want
try this one for now
(defun c:test(/ ppt1 ssob lys dwqty )(setvar 'cmdecho 0)(setq ppt1 (getpoint "\nPlace:")) (setq ssob (ssget)) (setq dwqty 0)(mapcar(function (lambda (j / k) (if (not (member (setq k (cdr (assoc 8 (entget j)))) lys)) (setq lys (cons k lys))) )) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ssob))) ) (foreach ln lys (sssetfirst nil ssob) (setq sellay (ssget "_p" (list (cons 8 ln)))) (command "_copy" sellay "" "" "_none" ppt1 (polar ppt1 (* pi (/ 45 180.0)) (setq dwqty (+ 50 dwqty))) ) ) )
I'm trying as much as possible not to deviate from your original code got error!
Point or option keyword required.; error: Function cancelledSpecify base point or displacement, or : *Cancel*
hmmmn wonder why.. thats the reason as much as possible i try to avoid using command functions
any other error message?
give me a minute, i think i'll just re-write everything..
页:
[1]
2