Jump to content

exporting 3d coordinates from a 3d polyline?


Recommended Posts

Posted

hello everybody

 

i got the attached lisp file from somewhere.

 

the purpose of this file is it will extract x,y coordinates from the polyline and will export to a notepad file.

 

can anyone modify this file so that it has to export Z coordinate also from a 3d polyline?

PLATE.txt

Posted

Thanks for the plug tagkelas :)

 

That LISP will also add a point to each vertex of the polyline/lwpolyline, but that can be easily taken out.

 

Lee

Posted

Since a 3D PLINE can only be the old style heavy POLYLINE, maybe something like this for a single entity:

 

[b][color=BLACK]([/color][/b]defun c:ex3dpl [b][color=FUCHSIA]([/color][/b]/ odz ss wf en vn vp[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq odz [b][color=NAVY]([/color][/b]getvar [color=#2f4f4f]"DIMZIN"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setvar [color=#2f4f4f]"DIMZIN"[/color] 8[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not ss[b][color=MAROON])[/color][/b]
            [b][color=MAROON]([/color][/b]> [b][color=GREEN]([/color][/b]sslength ss[b][color=GREEN])[/color][/b] 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSelect 3D Polyline To Export..."[/color][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"POLYLINE"[/color][b][color=BLUE])[/color][/b]
                          [b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"<OR"[/color][b][color=BLUE])[/color][/b]
                            [b][color=BLUE]([/color][/b]70 . 8[b][color=BLUE])[/color][/b]
                            [b][color=BLUE]([/color][/b]70 . 9[b][color=BLUE])[/color][/b]
                          [b][color=BLUE]([/color][/b]-4 . [color=#2f4f4f]"OR>"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
[b][color=FUCHSIA]([/color][/b]setq wf [b][color=NAVY]([/color][/b]open [color=#2f4f4f]"point.txt"[/color] [color=#2f4f4f]"w"[/color][b][color=NAVY])[/color][/b]
      en [b][color=NAVY]([/color][/b]ssname ss 0[b][color=NAVY])[/color][/b]
      vn [b][color=NAVY]([/color][/b]entnext en[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
[b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]/= [color=#2f4f4f]"SEQEND"[/color] [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 0 [b][color=BLUE]([/color][/b]entget vn[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
       [b][color=NAVY]([/color][/b]setq vp [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 10 [b][color=BLUE]([/color][/b]entget vn[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
       [b][color=NAVY]([/color][/b]write-line [b][color=MAROON]([/color][/b]strcat [b][color=GREEN]([/color][/b]rtos [b][color=BLUE]([/color][/b]car vp[b][color=BLUE])[/color][/b] 2 15[b][color=GREEN])[/color][/b] [color=#2f4f4f]","[/color]
                           [b][color=GREEN]([/color][/b]rtos [b][color=BLUE]([/color][/b]cadr vp[b][color=BLUE])[/color][/b] 2 15[b][color=GREEN])[/color][/b] [color=#2f4f4f]","[/color]
                           [b][color=GREEN]([/color][/b]rtos [b][color=BLUE]([/color][/b]caddr vp[b][color=BLUE])[/color][/b] 2 15[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] wf[b][color=NAVY])[/color][/b]
       [b][color=NAVY]([/color][/b]setq vn [b][color=MAROON]([/color][/b]entnext vn[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
[b][color=FUCHSIA]([/color][/b]close wf[b][color=FUCHSIA])[/color][/b]
[b][color=FUCHSIA]([/color][/b]setvar [color=#2f4f4f]"DIMZIN"[/color] odz[b][color=FUCHSIA])[/color][/b]
[b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

-David

  • 2 months later...
Posted
Since a 3D PLINE can only be the old style heavy POLYLINE, maybe something like this for a single entity:

 

(setq ss (ssget '((0 . "POLYLINE")

(-4 . "

(70 . 8)

(70 . 9)

(-4 . "OR>")))))

 

You *could* miss some 3d polylines doing it that way...

Safer to do this...

 

(ssget '((0 . "POLYLINE")(-4 . "&")(70 . ))

Posted

Yes, you could miss a Spline curved but then it would export the control points which wouldn't be of much use to most users. But then anything is possible -David

Posted

You could miss the the 3d polylines which line type generation is on too (128 bit code).

 

Here's another way to get the vertices WCS coordinates list of any polyline type.

 

;;; Poly-Pts (gile)
;;; Returns the vertices WCS coordinates list of a polyline (all types)
;;;
;;; Argument
;;; pl : the polyline (ename or vla-object)

(defun poly-pts    (pl / n p l)
 (vl-load-com)
 (setq n (fix (vlax-curve-getEndParam pl)))
 (or (vlax-curve-IsClosed pl) (setq n (1+ n)))
 (while (setq p (vlax-curve-getPointAtParam pl (setq n (1- n))))
   (setq l (cons p l))
 )
)

Posted
You could miss the the 3d polylines which line type generation is on too (128 bit code).
I don't believe that the 128 bit and the 8 bit can be set together (at least by AutoCAD), since 3D polylines do not display linetypes. Neither PEDIT or PROPS give you the option of turning on this flag, and even if PLINEGEN is set to 1, a newly constructed 3d polyline does not include the 128 bit.

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