Export polyline data

Export polyline data

subasio21
Contributor Contributor
2,553 Views
8 Replies
Message 1 of 9

Export polyline data

subasio21
Contributor
Contributor

Hi, everyone!

I am searching for a lisp that can find all closed polylines in a drawing and export to excel their following information:

 

area, layer ,thickness , color, x-cordinate of area , y-cordinate of area , z-cordinate of area 

 

ı added a sample dwg 

 

if anyone can help me I would be gratfull

0 Likes
Accepted solutions (1)
2,554 Views
8 Replies
Replies (8)
Message 2 of 9

ВeekeeCZ
Consultant
Consultant

post a csv file with an example of 1 exported polyline to take a look at its structure.

0 Likes
Message 3 of 9

Kent1Cooper
Consultant
Consultant

And please define what you would mean by the X, Y and Z coordinates of an area.  Those of its centroid?  Of the middle of its bounding box?  For one with non-zero thickness, if you want the centroid, do you want the centroid of its drawing plane, or halfway up its thickness, or the top of its thickness?  Etc., etc.

Kent Cooper, AIA
0 Likes
Message 4 of 9

Sea-Haven
Mentor
Mentor

Is the area the face area baselength*thickness ? Add end areas ?

0 Likes
Message 5 of 9

subasio21
Contributor
Contributor

hi

 

sorry but ı dont know how to export polyline to csv

0 Likes
Message 6 of 9

subasio21
Contributor
Contributor

Hi

 

yes they are the center of its area , to calculate the weight center of all , I want the centroid of its  halfway up its thickness,

0 Likes
Message 7 of 9

subasio21
Contributor
Contributor

hi 

 

only face plane  area 

 

thanks all

0 Likes
Message 8 of 9

ronjonp
Mentor
Mentor
Accepted solution

Here's a quickie;

 

(defun c:foo (/ _f _c c f fn o s x)
  ;; RJP » 2021-04-01
  (defun _f (s)
    (strcat (cond ((= 'real (type s)) (vl-string-right-trim "0" (rtos s 2 15)))
		  ((= 'int (type s)) (itoa s))
		  ((vl-princ-to-string s))
	    )
	    ","
    )
  )
  (defun _c (o / a b)
    (if	o
      (progn (vla-getboundingbox o 'a 'b)
	     (mapcar 'set '(a b) (mapcar 'vlax-safearray->list (list a b)))
	     (mapcar '/ (mapcar '+ a b) '(2 2 2))
      )
    )
  )
  (cond	((and (setq s (ssget '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1))))
	      (setq f (open (setq fn (strcat (getvar 'dwgprefix) "Results.csv")) "w"))
	 )
	 (write-line "AREA,LAYER,THICKNESS,COLOR,X,Y,Z" f)
	 (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	   (setq c (_c (setq o (vlax-ename->vla-object e))))
	   (write-line
	     (apply 'strcat
		    (append (mapcar '(lambda (x) (_f (vlax-get o x))) '(area layer thickness color))
			    (mapcar '_f c)
		    )
	     )
	     f
	   )
	 )
	 (close f)
	 (alert fn)
	)
  )
  (princ)
)

 

 

0 Likes
Message 9 of 9

subasio21
Contributor
Contributor

thanks a lots

 

that's great !  

0 Likes