Get CV Curve Control points position

Hello, I need a script..a simple one i think but having no experience in MaxScript this is way over my head.I need it to save the position (x,y,z) of CV points of a CV_Curve to any file that i can read (txt,csv..or any).I will be forever grateful! Thank you.

Comments

Comment viewing options

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

thank you !

I am truly grateful.After one copy/pastes about 300 coordinates from one place to another one by one, you really start to appreciate having a script that is able to do this.

barigazy's picture

...

And for that reason knowing MXS is good. :)
I started to learn it because I had a similar probem

bga

arhshine's picture

YOU are my hero ! Thank you !

YOU are my hero ! Thank you !

barigazy's picture

...

And to write to .txt use next snippet (Change folder path if u want)

txtFile = createFile @"c:\Temp\CV_Poss.txt"
for c in selection where isKindOf c NURBSCurveshape do
( 
	nSet = getNURBSSet c
	for i = 1 to nSet.numObjects do
	(
		for p = 1 to nSet[i].numCVs do 
			format "Curve_name: % ; Curve_#No: % ; CV: % ; CV_Pos: %\n" c.name i p ((getCV nSet[i] p).pos*c.transform) to:txtFile
	)
)
close txtFile

bga

arhshine's picture

one more thing

If it`s not too much trouble, i was wondering, can the returned values be somehow formatted in the text file ? Right now they look like this ( example [44.0106,-31.4628,0] ). Unfortunately the application in which i need to bring them has the Y-axis as Up-axis and this means i have to edit them one by one to replace Z with the Y.Is there a solution to this ? Thank you.

barigazy's picture

...

Like this

txtFile = createFile @"c:\Temp\CV_Poss.txt"
for c in selection where isKindOf c NURBSCurveshape do
( 
	nSet = getNURBSSet c
	for i = 1 to nSet.numObjects do
	(
		for p = 1 to nSet[i].numCVs do 
			pos = ((getCV nSet[i] p).pos*c.transform)
			format "%\n" (point3 pos.x pos.z pos.y) to:txtFile
	)
)
close txtFile

bga

arhshine's picture

I might not be doing

I might not be doing something right.It doesn't work, i get this message "-- Unknown property: "x" in undefined"

barigazy's picture

...

Damn parentheses :). Try now

txtFile = createFile @"c:\Temp\CV_Poss.txt"
for c in selection where isKindOf c NURBSCurveshape do
( 
	nSet = getNURBSSet c
	for i = 1 to nSet.numObjects do
	(
		for p = 1 to nSet[i].numCVs do 
		(
			pos = ((getCV nSet[i] p).pos*c.transform)
			format "%\n" (point3 pos.x pos.z pos.y) to:txtFile
		)
	)
)
close txtFile

bga

arhshine's picture

Yep

That did it.It works ! Thank you once again.

barigazy's picture

...

I never played with this before.
To save position to .txt file is easy part but to find CV positions is not.
This is first part.
I created two CV_Curve and then attach. Anyway this is the code which will print some info in Listener

if selection.count != 0 do for c in selection where isKindOf c NURBSCurveshape do
( 
	nSet = getNURBSSet c
	for i = 1 to nSet.numObjects do
	(
		for p = 1 to nSet[i].numCVs do 
			format "Curve_name: % ; Curve_#No: % ; CV: % ; CV_Pos: %\n" c.name i p ((getCV nSet[i] p).pos*c.transform)
	)
)

bga

Comment viewing options

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