Extract Polylines - Layer Name, Area, Length and Handled Key (ID)

Extract Polylines - Layer Name, Area, Length and Handled Key (ID)

tb123CPD
Contributor Contributor
4,217 Views
20 Replies
Message 1 of 21

Extract Polylines - Layer Name, Area, Length and Handled Key (ID)

tb123CPD
Contributor
Contributor

Could anyone Please help me to create LISP programming or share links (if someone already have) as i wanted to Extract Polylines - Layer Name, Area, Length and Handled Key (ID) in a one time for multiple areas from a drawing. Is their any possibilities ?

0 Likes
Accepted solutions (1)
4,218 Views
20 Replies
Replies (20)
Message 2 of 21

ВeekeeCZ
Consultant
Consultant

Like this...

 

(defun c:PolylineProp (/ ss ent i)
  
  (if (setq ss (ssget '((0 . "LWPOLYLINE"))))
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (princ (strcat "\n"
		     (cdr (assoc 8 (entget ent))) ","
		     (rtos (getpropertyvalue ent "Length")) ","
		     (rtos (getpropertyvalue ent "Area")) ","
		     (cdr (assoc 5 (entget ent)))))))
  (princ)
  )
Message 3 of 21

tb123CPD
Contributor
Contributor

Thanks for your kind reply, but i cant able to extract into CSV file or in text file. Could u please help me.

0 Likes
Message 4 of 21

ВeekeeCZ
Consultant
Consultant
Accepted solution

There are plenty of examples on the site... search and learn!

 

(defun c:PolylineProp (/ *error* file ss ent i)
  
  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if file (close file))
    (princ))

  
  (if (and (setq ss (ssget '((0 . "LWPOLYLINE"))))
	   (setq file (open (strcat (getvar 'DWGPREFIX) "PolylineProp.csv") "a"))
	   (princ (strcat "Filepath: "(strcat (getvar 'DWGPREFIX) "PolylineProp.csv")))
	   (write-line "" file)
	   )
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (setq txt (strcat (cdr (assoc 8 (entget ent))) ","
			(rtos (getpropertyvalue ent "Length")) ","
			(rtos (getpropertyvalue ent "Area")) ","
			(cdr (assoc 5 (entget ent)))))
      (write-line txt file)
      (princ (strcat "\n" txt))))
  (princ)
  )
Message 5 of 21

tb123CPD
Contributor
Contributor

Thank you again for your reply, but i am not able to extract the same into text or CSV file. Please see attached screenshot, i am looking for the same. If you could help me that would be great. Thanks in advance

0 Likes
Message 6 of 21

tb123CPD
Contributor
Contributor

Is it possible if i wanted to track the handle key or highlight the handle key on plan drawing by using the same lisp programming. Thanks again if u could do this that would be great for me.

0 Likes
Message 7 of 21

ВeekeeCZ
Consultant
Consultant

HERE you go, just because I am too kind. 

 

 

 

Message 8 of 21

Sea-Haven
Mentor
Mentor

You would be better labelling the plines, as part of the routines and exporting that also.

Message 9 of 21

tb123CPD
Contributor
Contributor

And How to label the plines can u suugest please

0 Likes
Message 10 of 21

braudpat
Mentor
Mentor

Hello Mr @ВeekeeCZ 

 

I Like / Love your message Number 7 !! ... So KUDOS !!

 

Regards, Patrice

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 11 of 21

ВeekeeCZ
Consultant
Consultant

Thank you, Patrice, you french frog! I appreciate it. 🙂


Message 12 of 21

Sea-Haven
Mentor
Mentor

The choice is yours text, block, leader to suggest a couple. 

Message 13 of 21

tb123CPD
Contributor
Contributor

Hi Again, 

It helps me a lot thank you,

I just want to know is it possible, if  autocad lisp zoom and "SELECT" ent by handle and it will be clearly visible on large drawing. As the current LISP programming only shows ZOOM and it is not clearly get to know if 1000' s of Polyline are there.

 

Thank in Advance

0 Likes
Message 14 of 21

Sea-Haven
Mentor
Mentor

This will zoom, various ways to highlite the object, change the zoom scale to suit.

 

(setq ent "A1")
(setq nent (entget (handent ent)))
(setq pt (cdr (assoc 10 nent)))
(command "zoom" "C" pt 300)
Message 15 of 21

tb123CPD
Contributor
Contributor

Hi @Sea-Haven  can u please brief the program. As i m trying but not working.  

0 Likes
Message 16 of 21

devitg
Advisor
Advisor

Please show us the error text at the text screen 

 

 

Message 17 of 21

devitg
Advisor
Advisor

the value "A1" shall be a real and true HANDLE value 

So , from where do you get your Handle value.?

 

At my ACAD , the first Handle value es "274" for the first line I make. 

 

 

 

Message 18 of 21

Sea-Haven
Mentor
Mentor

This is example zooming in on a entity via its handle. You may need to change the 15 to suit your dwg.

 

;(defun c:step2 (handid / nent pt )
(defun c:step2 ( / ent nent pt ) (setq nent (entget (handent handid))) (setq pt (cdr (assoc 10 nent))) (command "zoom" "C" pt 15) ) (defun c:step1 ( / ) (setq ent (entget (car (entsel "Pick an object")))) (setq handid (cdr (assoc 5 ent))) (alert (strcat "handle id is " handid "\n Now zoom some where away from object\n Then type step2")) )
Message 19 of 21

tb123CPD
Contributor
Contributor

See below I am using the following LISP program  for searching handle key in Autocad, also please refer attached image for reference:-

  • (defun C:HANDLE ( / handle ent )
    (setq handle (getstring "\nEnter handle to search for: "))
    (setq ent (handent handle))
    (if ent
    (progn ;line added
    (sssetfirst nil (ssadd ent))
    (command "_zoom" "_Object");line added               
    );line added
    ;Else
    (ALERT "The handle you entered does not exist in this drawing!")
    )
    (princ)
    )

 

 

Now After entering command it shows  "Zoom" but i need  "zoom with SELECTED polyline" as it will be clearly visible. 

 

Thanks in advance.

0 Likes
Message 20 of 21

Sea-Haven
Mentor
Mentor
(setq handle (getstring "\nEnter handle to search for: "))
(setq ent (handent handle))
(command "zoom" "ob" ent "")
0 Likes