Jump to content

Polyline question...


goldy2000

Recommended Posts

Hy everyone!!! I have a problem, I draw polyline (2D) and need lisp that ''reads'' my pline and extract ''pick points'' with coordinates (X,Y in this case there is no Z coordinate), so these points must extract to new file txt/csv/xls, or just to put points on that polyline... Maybe this question is solved in the past on this forum...but didn't find it...anybody????

Link to comment
Share on other sites

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • goldy2000

    7

  • VVA

    6

  • vitaminm

    5

  • ReMark

    1

Or look this

Export of coordinates of the specified points, the chosen objects: points, blocks, polylines, splines in a text file or Excel.

Text file — txt, or csv.

A rounding off of coordinates according to current adjustments of a command _UNITS (LUPREC system variable)

3 commands Are certain

COOR - export of coordinates

COORN-export of coordinates with numbering. Numbers of points are drawn by the text on the current layer, the current style, current height (TEXTSIZE)

COORT-export of coordinates with numbering where number considers the text nearest to a point

Link to comment
Share on other sites

Or look this

 

 

Thx for posting that, I already used that lisp, and it helped me...but is there a option when I draw pline, lisp puts dots on insertion places on that pline?? and after that I use COOR lisp and pick up all that coordinates :lol: (I need that because i need manually enter Z coord in that particular places)...THX for posting hyperlink..:roll:

Link to comment
Share on other sites

Give it a shot. It save on ".csv" format, separated by ","

 

 

(defun c:plex()
 (setq el (entget (car (entsel "\n Select the pline to extract: "))))
 (setq file (open (getfiled "Output file" "" "csv" 9) "w"))
 (repeat (setq i (length el))
   (if (= (car (setq l1 (nth (setq i (1- i)) el))) 10)
     (write-line (strcat (rtos (cadr l1)) "," (rtos (caddr l1))) file)
     )
   )
 (close file)
(princ)
)

 

 

 

Late.... =)

Link to comment
Share on other sites

goldy2000

If I have correctly understood, command COORNP is necessary to you

 

Hmmm, sounds good VVA, but can explain little bit more??:?

COORNP means coordinate numbering (COORN lisp helps here) and what is P meaning?? point?? or doting the exact place of polyline inflection?? hmmm...:roll:

Link to comment
Share on other sites

Are you looking to just extract the Vertex point of an LWPOLYLINE and write these to Excel?

 

Yep, the lisp that VVA posted is good, but I need one modification, just to put points in drawing on vertex places (points) and point numbers (lisp does it very good)...is it possible??:geek:

Link to comment
Share on other sites

Try it

;;; PoLyline and spline Mark
;;;http://www.cadtutor.net/forum/showthread.php?p=245705#post245705
(defun C:PLMark	(/ ss ptLst Npt Step)
 (setvar "PDMODE" 35) ;_ Point Mode
 (defun group-by-num (lst num / ls ret)
   (if	(= (rem (length lst) num) 0)
     (progn (setq ls nil)
     (repeat (/ (length lst) num)
       (repeat num
	 (setq ls  (cons (car lst) ls)
	       lst (cdr lst)
	 )
       )
       (setq ret (append ret (list (reverse ls)))
	     ls	 nil
       )
     )
     )
   )
   ret
 )
 (defun PLCollect (SelSet / ret)
   (foreach lw	(mapcar
	  'vlax-ename->vla-object
	  (vl-remove-if 'listp (mapcar 'cadr (ssnamex SelSet)))
	)
     (cond ((wcmatch (vla-get-ObjectName lw) "*Polyline")
     (setq ret
	    (append ret
		    (group-by-num
		      (vlax-get lw 'Coordinates)
		      (if (= (vla-get-ObjectName lw) "AcDbPolyline")
			2
			3
		      )
		    )
	    )
     )
    )
    ((= (vla-get-ObjectName lw) "AcDbSpline")
     (setq
       ret (append
	     ret
	     (group-by-num
	       (vlax-safearray->list
		 (vlax-variant-value (vla-get-controlpoints lw))
	       )
	       3
	     )
	   )
     )
    )
    (t nil)
     )
   )
   ret
 )
 (defun text-entmake
 (txt pnt height rotation justification / ent_list)
   (setq ent_list (list '(0 . "TEXT")
		 '(100 . "AcDbEntity")
		 '(100 . "AcDbText")
		 (list 10 (car pnt) (cadr pnt) 0.0)
		 (cons 1 txt)
		 (cons 40 height)
		 (cons 7 (getvar "TEXTSTYLE"))
		 (if justification
		   (cond
		     ((= justification "C")
		      '(72 . 1)
		     )
		     ((= justification "R")
		      '(72 . 2)
		     )
		     ((= justification "A")
		      '(72 . 3)
		     )
		     ((= justification "M")
		      '(72 . 4)
		     )
		     ((= justification "F")
		      '(72 . 5)
		     )
		     (t
		      '(72 . 0)
		     )
		   ) ;_ end of cond
		   '(72 . 0)
		 ) ;_ end of if
		 (cons 50 rotation)
		 (list 11 (car pnt) (cadr pnt) 0.0)
	   ) ;_ end of list
   ) ;_ end of setq
   (setq ent_list (entmakex ent_list))
 )
 (vl-load-com)
 (if (not (setq ss (ssget "_I" '((0 . "*POLYLINE,SPLINE")))))
   (progn
     (princ "\nSelect polyline and press Enter ")
     (setq ss (ssget '((0 . "*POLYLINE,SPLINE"))))
   )
 )
 (if ss
   (setq ptLst (PLCollect ss))
 )
 (if (and ss (setq ptLst (PLCollect ss)))
   (progn
     (setq
Npt (getint "\nStart number of points <Don't mark> : ")
     )
     (setq Step 1)

     (if (numberp Npt)
(progn
  (princ "\nIncrement of number")
  (if (not (numberp ptcol:Step))
    (setq ptcol:Step 1)
  )
  (princ " <")(princ ptcol:Step)
  (princ ">: ")(setq Step (getint))
  (if (null Step)(setq Step ptcol:Step))
  (setq	ptcol:Step Step
	Npt (* Npt 1.0)
  )
)
     )
     (foreach pt ptLst
(if (numberp Npt)
  (progn
    (text-entmake
      (rtos Npt 2 0) ;_ Number
      (polar pt (* pi 0.25) 1.) ;_Point
      (getvar "TEXTSIZE") ;_Text Height
      0 ;_Angle of rotation
      nil ;_Left justification
    )
    (setq Npt (+ Npt Step))
  )
)
(entmakex (list (cons 0 "POINT") (cons 10 pt)))
     )
   )
 )
 (princ)
)

 

PS. After use PLMARK it is possible to use COORT for export of numbers and co-ordinates of points

Link to comment
Share on other sites

Thx VVA for the code, that is what I was looking for!! Can you make modification for point numbers to be situated (linked) to dot (point) place??

THX one more time for your cooperation and free time to make this lisp...

And I was thinking something, is it possible to make 3D points, so it will have Z coord??

Link to comment
Share on other sites

If I have correctly understood,

;;; PoLyline and spline Mark
;;;http://www.cadtutor.net/forum/showthread.php?p=245705#post245705
(defun C:PLMark	(/ ss ptLst Npt Step)
 (setvar "PDMODE" 35) ;_ Point Mode
 (defun group-by-num (lst num / ls ret)
   (if	(= (rem (length lst) num) 0)
     (progn (setq ls nil)
     (repeat (/ (length lst) num)
       (repeat num
	 (setq ls  (cons (car lst) ls)
	       lst (cdr lst)
	 )
       )
       (setq ret (append ret (list (reverse ls)))
	     ls	 nil))))
   ret)
 (defun PLCollect (SelSet / ret)
   (foreach lw	(mapcar
	  'vlax-ename->vla-object
	  (vl-remove-if 'listp (mapcar 'cadr (ssnamex SelSet)))
	)
     (cond ((wcmatch (vla-get-ObjectName lw) "*Polyline")
     (setq ret
	    (append ret
		    (group-by-num
		      (vlax-get lw 'Coordinates)
		      (if (= (vla-get-ObjectName lw) "AcDbPolyline")
			2
			3)))))
    ((= (vla-get-ObjectName lw) "AcDbSpline")
     (setq ret (append ret
	     (group-by-num
	       (vlax-safearray->list
		 (vlax-variant-value (vla-get-controlpoints lw))
	       )
	       3))))
    (t nil)))
   ret
 )
 (defun text-entmake
 (txt pnt height rotation justification / ent_list)
   (setq ent_list (list
     '(0 . "TEXT")
     '(100 . "AcDbEntity")
     '(100 . "AcDbText")
     (list 10 (car pnt) (cadr pnt) 0.0)
     (cons 1 txt)
     (cons 40 height)
     (cons 7 (getvar "TEXTSTYLE"))
     (if justification
       (cond
	 ((= justification "C")'(72 . 1))
                ((= justification "R")'(72 . 2))
                ((= justification "A")'(72 . 3))
                ((= justification "M")'(72 . 4))
                ((= justification "F")'(72 . 5))
                (t '(72 . 0))
              ) ;_ end of cond
     '(72 . 0)
     ) ;_ end of if
    (cons 50 rotation)
    (list 11 (car pnt) (cadr pnt) 0.0)
) ;_ end of list
   ) ;_ end of setq
   (setq ent_list (entmakex ent_list)))
 (vl-load-com)
 (if (not (setq ss (ssget "_I" '((0 . "*POLYLINE,SPLINE")))))
   (progn
     (princ "\nSelect polyline and press Enter ")
     (setq ss (ssget '((0 . "*POLYLINE,SPLINE"))))
   )
 )
 (if ss (setq ptLst (PLCollect ss)))
 (if (and ss (setq ptLst (PLCollect ss)))
   (progn
     (setq Npt (getint "\nStart number of points <Don't mark> : "))
     (setq Step 1)
     (if (numberp Npt)
(progn
  (princ "\nIncrement of number")
  (if (not (numberp ptcol:Step))
    (setq ptcol:Step 1)
  )
  (princ " <")(princ ptcol:Step)(princ ">: ")
  (setq Step (getint))
  (if (null Step)(setq Step ptcol:Step))
  (setq	ptcol:Step Step
	Npt	   (* Npt 1.0))
  )
     )
     (foreach pt ptLst
(if (numberp Npt)
  (progn
    (text-entmake
      (rtos Npt 2 0) ;_ Number
      [color="Red"]pt ;_was (polar pt (* pi 0.25) 1.) ;_Point[/color]
      (getvar "TEXTSIZE") ;_Text Height
      0 ;_Angle of rotation
      nil ;_Left justification
    )
    (setq Npt (+ Npt Step))
  )
)
(entmakex (list (cons 0 "POINT") (cons 10 pt)))
     )
   )
 )
 (princ)
)

And I was thinking something, is it possible to make 3D points, so it will have Z coord??

Certainly, but where to take co-ordinate Z?

Link to comment
Share on other sites

  • 2 years later...

Mr. Blackalnet yr list plex is good, but it only check for 1 (single) polyline, do you have a list of can check multililine (many lines) and including the 2D polyline too.

 

Thank you!

Link to comment
Share on other sites

Dear Mr. VVA your lisp is jz great for me, but can you give me a lisp with export to Excel with your lines, numubering with x&y coordiante together.

 

Thank you very much!

Link to comment
Share on other sites

Mr. VVA how to make your plmark text smaller? cause i need to manually change it everytime after run your lisp.

 

and can you improve it with differnt line with different colour numbering?

 

Thank you.

Link to comment
Share on other sites

Dear Mr. VVA your lisp is jz great for me, but can you give me a lisp with export to Excel with your lines, numubering with x&y coordiante together.

 

Thank you very much!

 

Try EcooE rev.6

 

Mr. VVA how to make your plmark text smaller? cause i need to manually change it everytime after run your lisp.

Found

(getvar "TEXTSIZE") ;_Text Height

or type TEXTSIZE in command line and set the height of the text which you wish

... and can you improve it with differnt line with different colour numbering?

I did not understand the meaning of this

Link to comment
Share on other sites

  • 1 month later...
Try EcooE rev.6

 

 

Found

(getvar "TEXTSIZE") ;_Text Height

or type TEXTSIZE in command line and set the height of the text which you wish

 

I did not understand the meaning of this

 

 

Thank for your reply Mr. VVA,

 

"and can you improve it with differnt line with different colour numbering? "

 

I mean or what I want is, the output of the vertices instead of now all combine together, and i want it to be seperated.

 

I mean that one entity say a polyline have 3 vertice (point (x,x,z) have 4 data without Z, or 6 data with Z). and be seperate by this polyline entity.

 

The next entity say have 2 vertices, then list out the and seperate by this entity and list out vertice data.

 

and next entity list out the entity itself and vertices data, so on ....

 

thank you in advance.

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