Create 3D polyline with many points

Create 3D polyline with many points

Anonymous
Not applicable
4,145 Views
8 Replies
Message 1 of 9

Create 3D polyline with many points

Anonymous
Not applicable

Hello, I want to create a closed 3d polyline from list of 3d points by AutoLisp code.

 

entmake function takes dxf codes from 10 to 39 for 3d points, so it seems taking at most 30 points for drawing polyline.

 

So I have two questions.
1. Can I make closed 3d polyline with about 1000 points?
2. Would 3d polyline be drawn in order of 3d point list?

 

If there are some example codes, I'm very appreciated.

 

Thanks in advance 🙂

 

0 Likes
Accepted solutions (2)
4,146 Views
8 Replies
Replies (8)
Message 2 of 9

Sea-Haven
Mentor
Mentor

You can start the 3dpoly command and then read say a csv file x,y,z as points, does that not work ? Dont have 1000 pts to test.

 

(setq fo (open "d:\\acadtemp\\3d.csv" "R"))
(command "_3dpoly")
(while (= (getvar "cmdactive") 1 )
(while
(command (read-line fo))
)
(command "")
)
(close fo)

 

1,1,1
2,2,3
10,23,45
12,56,87
0 Likes
Message 3 of 9

Kent1Cooper
Consultant
Consultant

All the vertices in 3D Polylines [as well as "heavy" 2D ones] get their own entity names, so while there may be some limit to the number, it's not a function of dxf code number range, and it's far more than 30.  I've encountered LWPolylines with over 1000 vertices, so I expect 3D Polylines can have as many, but I don't know what the limit may be.

 

In what form do you have information about the points?  If it's in a .csv file, I agree with @Sea-Haven 's suggestion that it's far simpler code-wise to do it in a (command) function, stepping through the lines of the file [though I expect the CMDACTIVE check isn't necessary], rather than to try to construct the entity data list with (entmake) and all the follow-on entity data lists to assemble the overall object.  It's possible that AutoLisp would reach a limit on how long a list it can manage, before AutoCAD reached a limit on how many vertices a 3DPolyline can have.

 

If the information is in some other form, what is that?

Kent Cooper, AIA
0 Likes
Message 4 of 9

Anonymous
Not applicable

Ah, thanks for reply. I'm going to make 3d point list in the Autolisp code. So if there are N points, the list would have 3*N float numbers.

0 Likes
Message 5 of 9

Anonymous
Not applicable

Thank you! But I'm not going to read csv file but create the 3d point list at my AutoLisp code.

In this case, is the code similar to yours?

0 Likes
Message 6 of 9

john.uhden
Mentor
Mentor

Umm, Alan,

(while (command <anything>)) won't get very far since (command ...) returns nil.

Maybe it's time to trade in that Fosters for some Wengerd, or

trade in those prawns for some shrimp.

BTW, I've decided to make shrimp francaise for two for Christmas for everyone in my office (which is only 12 including myself).  They'll have to cook their own linguini.

John F. Uhden

0 Likes
Message 7 of 9

john.uhden
Mentor
Mentor
Accepted solution

For a while now, I have preferred the (vlax-put object 'Coordinates <flatlist>) method.

When you have a list of points, say plist, as in '((x1 y1 z1)(x2 y2 z2)(xn yn zn))

then your flatlist is created simply by (apply 'append plist).

At least with 3DPolylines you don't have to deal with bulges.

John F. Uhden

0 Likes
Message 8 of 9

Sea-Haven
Mentor
Mentor

Not a problem write points to a file, if you want to stop and start for some reason there is the "A" append option this will add to a file. 

0 Likes
Message 9 of 9

Sea-Haven
Mentor
Mentor
Accepted solution

Tried 1500 points

 

(setq fo (open "d:\\acadtemp\\3d.csv" "w"))
(setq x 0 y 0 z 0)
(repeat 1500
(write-line (strcat (rtos (setq x (+ x 1)) 2) ",2,2") fo)
)
(close fo)




(setvar 'osmode 0)
(setq fo (open "d:\\acadtemp\\3d.csv" "R"))
(command "_3dpoly")

(while (setq nline (read-line fo))
(if (= nline "")
(princ)
(command nline)
)
)
(command "")

(close fo)
0 Likes