Jump to content

lisp to move largest room polyline to another layer for floor gross polyline


TheresaT

Recommended Posts

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.:unsure:

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)?

Link to comment
Share on other sites

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)
)
     )
   )
 )

Link to comment
Share on other sites

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
       )
     )
   )
 )
)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...