Lee Mac Posted November 30, 2009 Posted November 30, 2009 Thats not LISP, just what you can do with the command Here is a much faster version of the LISP that FreeRefill wrote (defun c:ftoo (/ lays lLst i ss ent obj nl) (vl-load-com) (setq lays (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (setq i -1 ss (ssget "_:L" '((8 . "* - FUTURE")))) (while (setq ent (ssname ss (setq i (1+ i)))) (setq l (vla-get-Layer (setq obj (vlax-ename->vla-object ent)))) (or (tblsearch "LAYER" (setq nl (substr l 1 (- (strlen l) 9)))) (vla-add lays nl)) (vla-put-layer obj nl))) (princ)) Quote
Archiman86 Posted November 30, 2009 Author Posted November 30, 2009 Wow, that works great. Is there a faster way for the first command he wrote as well. It seems to go kind of slow when I selct 100's of objects. Maybe I am being too greedy. Thanks in advance! Quote
Archiman86 Posted November 30, 2009 Author Posted November 30, 2009 yes, that one seems to take some time as well, if I select a large number of objects. If not, its no big deal. Like I said, it works, thats whats most important. Quote
Lee Mac Posted November 30, 2009 Posted November 30, 2009 yes, that one seems to take some time as well, if I select a large number of objects. If not, its no big deal. Like I said, it works, thats whats most important. Its due to the way Freerefil converts the SelectionSet into a list, and also using the command calls - both are extremely slow methods... along with the numerous calls to vlax-get-acad-object - which is very bad practice. But I shall see what I can do when I get a minute Quote
Lee Mac Posted November 30, 2009 Posted November 30, 2009 Give this a go; (defun c:obtol (/ lays i ss ent l obj nl) (vl-load-com) (setq lays (vla-get-layers (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (setq i -1 ss (ssget "_:L")) (while (setq ent (ssname ss (setq i (1+ i)))) (setq l (vla-get-layer (setq obj (vlax-ename->vla-object ent)))) (or (tblsearch "LAYER" (setq nl (strcat l " - FUTURE"))) (vla-add lays nl)) (vla-put-layer obj nl))) (princ)) Quote
Archiman86 Posted November 30, 2009 Author Posted November 30, 2009 Thanks a lot for the quick response. One problem that we ran into before is the fact that if the layer already exists, I dont want it to make another one with the suffix "- FUTURE - FUTURE". This seems to happen... Quote
Lee Mac Posted November 30, 2009 Posted November 30, 2009 Sorry, I was just following the code in the first page... will modify it for you Quote
Lee Mac Posted November 30, 2009 Posted November 30, 2009 (defun c:obtol (/ lays i ss ent l obj nl) (vl-load-com) (setq lays (vla-get-layers (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (setq i -1 ss (ssget "_:L")) (while (setq ent (ssname ss (setq i (1+ i)))) (setq l (vla-get-layer (setq obj (vlax-ename->vla-object ent)))) (and (not (wcmatch l "* - FUTURE")) (or (tblsearch "LAYER" (setq nl (strcat l " - FUTURE"))) (vla-add lays nl)) (vla-put-layer obj nl)))) (princ)) Quote
Archiman86 Posted November 30, 2009 Author Posted November 30, 2009 That works great! Thank you soo much. I really appreciate it. You truly are a MASTER! Regards. Quote
Lee Mac Posted November 30, 2009 Posted November 30, 2009 That works great! Thank you soo much. I really appreciate it. You truly are a MASTER! Regards. Many thanks Lee Quote
Archiman86 Posted January 20, 2010 Author Posted January 20, 2010 Lee, Is there a way to incorporate this into your faster version? I just noticed that it does not add these properties after creating the layer. (works great otherwise) That works great thanks. Now is there a way to set the properties for the layer when it creates it. Namely I would like to set the color to 252 and the linetype to "hidden" Thanks again! Quote
Lee Mac Posted January 20, 2010 Posted January 20, 2010 Lee, Is there a way to incorporate this into your faster version? I just noticed that it does not add these properties after creating the layer. (works great otherwise) Try this: (defun c:obtol (/ lays i ss ent l obj nl) (vl-load-com) (setq lays (vla-get-layers (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (setq i -1 ss (ssget "_:L")) (while (setq ent (ssname ss (setq i (1+ i)))) (setq l (vla-get-layer (setq obj (vlax-ename->vla-object ent)))) (and (not (wcmatch l "* - FUTURE")) (or (tblsearch "LAYER" (setq nl (strcat l " - FUTURE"))) (and (setq nlay (vla-add lays nl)) (mapcar (function (lambda (property value) (vlax-put-property nlay property value))) '(Linetype Color) '("HIDDEN" 252)))) (vla-put-layer obj nl)))) (princ)) Quote
Archiman86 Posted January 20, 2010 Author Posted January 20, 2010 Great, that is EXACTLY what I needed. Thanks Again. Quote
ronjonp Posted January 24, 2010 Posted January 24, 2010 Lee, You could make it even faster by filtering out the objects already on a future layer like so: (ssget "_:L" '((8 . "~* - FUTURE"))) Quote
Lee Mac Posted January 24, 2010 Posted January 24, 2010 Nice idea Ron! (defun c:obtol (/ lays i ss ent l obj nl) (vl-load-com) (setq lays (vla-get-layers (vla-get-ActiveDocument (vlax-get-acad-object)))) (if (setq i -1 ss (ssget "_:L" '((8 . "~* - FUTURE")))) (while (setq ent (ssname ss (setq i (1+ i)))) (setq l (vla-get-layer (setq obj (vlax-ename->vla-object ent)))) (or (tblsearch "LAYER" (setq nl (strcat l " - FUTURE"))) (and (setq nlay (vla-add lays nl)) (mapcar (function (lambda (property value) (vlax-put-property nlay property value))) '(Linetype Color) '("HIDDEN" 252)))) (vla-put-layer obj nl))) (princ)) Quote
ronjonp Posted January 24, 2010 Posted January 24, 2010 Speed difference is probably minimal....but just another way to skin the cat. 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.