Spline from 100+ XYZ coordinates?

Hi!

I've been looking for a way to generate a spline in 3ds Max 2010
from a list of XYZ coordinates like this:

-633.899467 253.472601 -922.572420
-633.634657 253.328655 -922.612933
-633.424837 253.285432 -922.631823
-633.215333 253.320855 -922.725688
-633.008533 253.449184 -922.869686
-632.952400 253.733482 -922.965703
-632.982588 253.956076 -922.999394
-633.077269 254.217309 -922.978714

(it goes on for quite a while)

The XYZ coordinates could either be in a .txt file or an .xyz file

Would this be a lot of work for someone with scripting skills?

I've attached an example of a longer list as a .txt file.

Cheers/

Caspar

AttachmentSize
curve.txt4.18 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Caspar83's picture

.

Hey!

There were a few slightly strange things, but I found a quick solution:
The script seems to generate 3 vertices for each point and switching vertice attribute between corner, smooth, bezier et.c doesn't have any effect. By saving the spline as an OBJ and importing it back, things were back to normal and the duplicate vertices got welded automatically.

Thanks again Miauu, really appreciate it!

Will use this script in a new sculpture project.
If you're curious, check here some time from now!
---> casparforsberg (dot) com

miauu's picture

.

It realy creates 3 knots at the same position. The reason is that I had another idea to create knots, but then I change it with another way and forgot to remove the first one. Here the fixed code, so no need to export/import as obj.

(
	xyzFile = getOpenFileName()
 
	if xyzFile != undefined and doesFileExist xyzFile do
	(
 
		ss = splineShape()
		addNewSpline ss
		xyz = openFile xyzFile	
		while not eof xyz do
		(
			nextLine = filterString (readLine xyz) " "
			addKnot ss 1 #corner #line [(nextLine[1] as float),(nextLine[2] as float),(nextLine[3] as float) ]
		)
		updateShape ss
		CenterPivot ss
	)
)
miauu's picture

.

Try this:

(
	xyzFile = getOpenFileName()
 
	if xyzFile != undefined and doesFileExist xyzFile do
	(
 
		ss = splineShape()
		addNewSpline ss
		xyz = openFile xyzFile	
		while not eof xyz do
		(
			nextLine = filterString (readLine xyz) " "
			for i = 1 to 3 do
			(
				addKnot ss 1 #corner #line [(nextLine[1] as float),(nextLine[2] as float),(nextLine[3] as float) ]
			)
		)
		updateShape ss
                CenterPivot ss
	)
)
Caspar83's picture

Thank's a lot Miauu, I'll

Thank's a lot Miauu,
I'll give this a try!

Best regards/

Caspar

Caspar83's picture

.

Works great, thank you again so much!

Cheers/Caspar

miauu's picture

.

Glad to help. :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.