TheresaT Posted August 25, 2010 Share Posted August 25, 2010 I need a autolisp routine to search an existing layer of room closed polylines (A-AREA) and pick out the largest one, create a new layer for this and then move this object to this new layer (A-AREA-GROSS). Is this possible? Thanks in advance for any help. Quote Link to comment Share on other sites More sharing options...
jammie Posted August 25, 2010 Share Posted August 25, 2010 Welcome to the forum! That should be possible to do. Have you any code written that you could post? Or even thoughts about how you would like to achieve it? Regards Jammie Quote Link to comment Share on other sites More sharing options...
TheresaT Posted August 25, 2010 Author Share Posted August 25, 2010 Jammie - I haven't a clue how to approach this as it's been years since I created any lisp routines. Any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
jammie Posted August 25, 2010 Share Posted August 25, 2010 No problem Is there a possibility that there could be multiple polylines of the same area? That more then one polyine will need to be placed on layer (A-AREA-GROSS)? Quote Link to comment Share on other sites More sharing options...
jammie Posted August 25, 2010 Share Posted August 25, 2010 Not heavily tested but as a starting point maybe (defun c:test (/ selectionFilter targetLayer tempSelectionSet layerCollection maxArea i object objectArea tempObjectList) (vl-load-com) (setq selectionFilter (list (cons 0 "*POLYLINE")(cons 8 "A-AREA")) targetLayer "A-AREA-GROSS") (if (Setq tempSelectionSet (ssget "x" selectionFilter)) (progn (if (not (tblsearch "layer" targetLayer)) (progn (setq layerCollection (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))) (vla-add layerCollection targetLayer))) (setq i 0 maxArea 0.0) (repeat (sslength tempSelectionSet) (setq object (vlax-ename->vla-object (ssname tempSelectionSet i)) i (1+ i)) (setq objectArea (vla-get-area object)) (cond ((> objectArea maxArea)(setq maxArea objectArea tempObjectList (list object ))) ((equal objectArea maxArea 1e-6)(setq tempObjectList (append tempObjectList (list object ))))) ) (foreach <object> tempObjectList (vla-put-layer <object> targetLayer) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
TheresaT Posted August 25, 2010 Author Share Posted August 25, 2010 That's exactly what we needed! Many thanks. It works just fine. Quote Link to comment Share on other sites More sharing options...
alanjt Posted August 25, 2010 Share Posted August 25, 2010 One more example - which will only select closed LWPolylines... (defun foo (search new / ss) ;; eg. (foo "Layer1" "NewLayer") ;; Alan J. Thompson, 08.25.10 (if (setq ss (ssget "_X" (list '(0 . "LWPOLYLINE") '(-4 . "<OR") '(70 . 1) '(70 . 129) '(-4 . "OR>") (cons 8 search) ) ) ) ((lambda (layer / a v l) (vlax-for x (setq ss (vla-get-activeselectionset *AcadDoc*)) (or (> v (setq a (vla-get-area x))) (setq v a)) (setq l (cons (cons a x) l)) ) (vla-delete ss) (foreach x l (and (equal v (car x)) (vl-catch-all-apply (function vla-put-layer) (list (cdr x) layer))) ) ) (vla-get-name (vla-add (vla-get-layers (cond (*AcadDoc*) ((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object)))) ) ) new ) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
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.