mugshot Posted October 17, 2018 Posted October 17, 2018 Hello guys... Is there any lisp that i could copy the layer inside a block straight away? Like i dont have to go inside the block, copy then match prop... Or explode the object. The reason is at least skip some steps... I did ask in general but i was instructed to ask in this section. Thanks in advance, cheers! Quote
dlanorh Posted October 17, 2018 Posted October 17, 2018 Post an example block in ACAD2010 version. It's relatively easy to get an object inside a block using (nentsel), get its layer property then assiugn that to another object. Quote
Emmanuel Delay Posted October 17, 2018 Posted October 17, 2018 Does this help? You get to select a subentity (with nentsel), it reads its layer, then sets that layer as current layer. Do you also need the color and linetype ... ? ;; Select Layer Inside Block (defun c:slib ( / lay) (setq lay (cdr (assoc 8 (entget (car (nentsel "\nSelect subentity: ")))))) (setvar 'clayer lay) (princ) ) Quote
Lee Mac Posted October 17, 2018 Posted October 17, 2018 If I've understood correctly, it sounds like the OP is describing NCOPY for all objects residing on a particular layer within a block. Quote
Jef! Posted October 17, 2018 Posted October 17, 2018 (edited) If I've understood correctly, the OP want to matchprop only the layer of other objects using a block sub entity as the source.... (defun c:lnmp ( / ent source sel) (if (and (setq ent (car (nentsel "\nSelect subentity: "))) (setq source (cdr (assoc 8 (entget ent)))) ) (while (setq sel (ssget)) (mapcar '(lambda (x) (vla-put-layer (vlax-ename->vla-object x) source) ) (vl-remove-if 'listp (mapcar 'cadr (ssnamex sel))) ) ) ) (princ) ) Edited October 17, 2018 by Jef! Quote
Tharwat Posted October 17, 2018 Posted October 17, 2018 @Jef! Your 'IF' function is useless in this case so try to select nothing to know why. Quote
Jef! Posted October 17, 2018 Posted October 17, 2018 @Tharwat You are totally right on the if not doing its job. No riddles here I was in a hurry so I just played it slacker on that one. Half question, half working half code (and half time wasted!). The final princ was also missing. I corrected it anyway. Now I'd bet a cold one on it that the next post will be "That is not what I need." Anyone? Quote
mugshot Posted October 18, 2018 Author Posted October 18, 2018 Thanks guys for the effort.. greatly appreciated, as in a lot. This will save my time at work... ...and may i add, or alter, if it possible to copy the layer at the same time the color? What i saw is that it corresponds to the layer, but not the color, (say layer zero but has a color green) like that... Thanks again... Quote
eldon Posted October 18, 2018 Posted October 18, 2018 I know that you want this done by lisp, but did you ever try inserting the block into your drawing and then erasing it? All the block layers appear in the drawing, complete with colour and linetype. Quote
Emmanuel Delay Posted October 18, 2018 Posted October 18, 2018 I expanded it to layer, color, linetype, line weight ;; Select Layer Inside Block (defun c:slib ( / ent lay col ltp lwght) (setq ent (entget (car (nentsel "\nSelect subentity: ")))) (setq lay (cdr (assoc 8 ent))) ;; layer (setq col (cdr (assoc 62 ent))) ;; color (setq ltp (cdr (assoc 6 ent))) ;; line type (setq lwght (cdr (assoc 370 ent))) ;; line weight (setvar 'clayer lay) ;; note: color, linetype, line weight might not be set if the subentity was on "ByLayer" ;; in that case we force it (and reset it) to "ByLayer" (if col (setvar 'cecolor (itoa col)) (setvar 'cecolor "BYLAYER") ) (if ltp (setvar 'celtype ltp) (setvar 'celtype "BYLAYER") ) (if (= nil lwght) (setvar 'celweight -1) ;; -1 = "ByLayer" (setvar 'celweight lwght) ) (princ) ) Quote
mugshot Posted October 18, 2018 Author Posted October 18, 2018 1 hour ago, eldon said: I know that you want this done by lisp, but did you ever try inserting the block into your drawing and then erasing it? All the block layers appear in the drawing, complete with colour and linetype. Yes sir. The thing is we used dynamic block... In extend are object, sort like that. Actually there are plenty of procedure, to which i want to skip those...maybe u can call me lazy bum... Quote
mugshot Posted October 18, 2018 Author Posted October 18, 2018 @Emmanuel sir... Thanks for the lisp... Greatly appreciated... This will help me work fast...(office requirement) and ill use this to my other project as well... This is a weird process but it help me a lot... Maybe to others as well. Kind regards... Cheers 1 Quote
mugshot Posted October 18, 2018 Author Posted October 18, 2018 @Emmanuel sir, is the second lisp does force to make layer to be default, then thats stops? I think the first works fine, because from source/entity to object, the second was nice too but theres no application to object from source. Quote
Recommended Posts
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.