LISP to select the biggest poyline

LISP to select the biggest poyline

Anonymous
Not applicable
1,182 Views
4 Replies
Message 1 of 5

LISP to select the biggest poyline

Anonymous
Not applicable

Hi guys,

 

I'm facing a problem here because within about 1.500 dwg files I need to find the biggest and smalest poyline of a specific layer and write its length!

I'm using QSELECT to do this but it's quite dumb because I have to try several times until find the biggest and smallest poylines!

 

Would be a way, using LISP, to help me out with this?

 

PS: Sorry about my terrible english! Smiley Indifferent

 

Regards

 

Rodrigo Abb

rodrigoabb@gmail.com

0 Likes
Accepted solutions (1)
1,183 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

@digo5150 wrote:

.... I need to find the biggest and smalest poyline of a specific layer and write its length!

.... 

Would be a way, using LISP, to help me out with this?

....


Welcome to these Forums!

 

Here's one [minimally tested] way to find the shortest and longest Polylines on a specific Layer.  It selects/highlights/grips both of them, and reports on their length at the Command line.  Whatever you mean by "write" its length [write out to a file of some kind, draw as Text in the drawing, etc.] can use the same (rtos (getlen....)) function [which reports in current Units settings -- add mode and precision arguments if you want a different format].  The whole thing could be defined into a command, or incorporated as a sub-routine in something larger, or whatever else you want to do with it [or parts of it].

 

(defun getlen (ent) (vla-get-length (vlax-ename->vla-object ent)))
(foreach pl (mapcar 'cadr (ssnamex (ssget "_X" '((0 . "LWPOLYLINE") (8 . "YourSpecificLayer")))))
  (cond
    ((not shortest) (setq shortest pl longest pl))
    ((< (getlen pl) (getlen shortest)) (setq shortest pl))
    ((> (getlen pl) (getlen longest)) (setq longest pl))
  ); cond
); foreach
(setq extremes (ssadd shortest) extremes (ssadd longest extremes))
(sssetfirst nil extremes)
(prompt
  (strcat
    "\nShortest Polyline is " (rtos (getlen shortest)) " long;"
    "\nLongest Polyline is " (rtos (getlen longest)) " long."
  ); strcat
); prompt
Kent Cooper, AIA
Message 3 of 5

patrick_35
Collaborator
Collaborator

Hi

 

For example

(ssget "X" '((0 . "LWPOLYLINE") (-4 . ">=") (40 . 10.0)))

@+

Message 4 of 5

Anonymous
Not applicable

Thank you so much for your help!

Helped a lot!!!!!!!

 

Regards!

0 Likes
Message 5 of 5

Anonymous
Not applicable
Also thanks for your atention!!
0 Likes