TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Paul Munford on February 06, 2009, 12:21:28 PM
-
with thanks to all at this thread:
http://www.theswamp.org/index.php?topic=10992.0 (http://www.theswamp.org/index.php?topic=10992.0)
I've managed to hack together these two snippets. They work but they're not pretty!
It seems clunky to be converting Objects into entities and back again. I would be interested to know if you can come up with anything a bit more slick...
;;Put all the viewports on the standard layer, including clipped viewports and their clipping boundarys.
(foreach n Vportlist
(vlax-put-property n 'layer "VPORTS")
(if
(eq (vlax-get-property n 'clipped):vlax-true)
(progn
(setq ClipObject (assoc 340 (entget (vlax-vla-object->ename n))))
(vlax-put-property (vlax-Ename->Vla-Object (cdr ClipObject))'layer "VPORTS")
); end progn
);end if
);end foreach
;;Delete all the 'Ex' viewport layers, if they are not still in use.
(foreach n VPLayers
(if
(and
(/= "VPORTS" n)
(/= 64 (cdr (assoc 70 (entget (vlax-vla-object->ename(vla-item acadLayers n))))))
);end and
(vla-delete(vla-item acadLayers n))
);end if
);end foreach
-
This is how I'd do it....I don't think you need to check for clipped.
;;Put all the viewports on the standard layer, including clipped viewports and their clipping boundarys.
(foreach n vportlist
(vla-put-layer n "VPORTS")
(if (setq clipobject (assoc 340 (entget (vlax-vla-object->ename n))))
(vlax-put-property (vlax-ename->vla-object (cdr clipobject))
'layer
"VPORTS"
)
) ; end progn
) ;end foreach
;;purge unused layers
(repeat 2
(vla-purgeall
(vla-get-activedocument (vlax-get-acad-object))
)
)
-
Untested 8-)
;;Put all the viewports on the standard layer, including clipped viewports and their clipping boundarys.
(foreach obj Vportlist
(vlax-put-property obj 'layer "VPORTS")
(if (setq ent (assoc 340 (entget (vlax-vla-object->ename obj))))
(vla-put-layer (vlax-ename->vla-object (cdr ent)) "VPORTS")
)
) ;end foreach
;;Delete all the 'Ex' viewport layers, if they are not still in use.
(foreach n VPLayers
(vl-catch-all-apply 'vla-delete (list (vla-item acadLayers n)))
)
-
And my addition to CAB's remove layer code (not sure if it really helps though) :-D
(foreach n (vl-remove-if '(lambda (x) (wcmatch (vla-get-name x) "*|*"));;take out xref layers
vplayers
)
(vl-catch-all-apply 'vla-delete
(list (vla-item acadlayers n))
)
)
-
I love this place!
Thanks for your replies, definitely food for thought :-)