Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

HELP! - Need script that exports Vertex X,Y coordinates to textfile....

Anonymous

HELP! - Need script that exports Vertex X,Y coordinates to textfile....

Anonymous
Not applicable

Hello. I desperately need a script that can export vertex points X,Y coordinates to a textfile like .csv. Like the following...

 

1. Select a set of vertex points.

2. Run script.

3. Browse for a textfile output and name it.

4. A .csv file is created with two columns X and Y for each vertex coordinates in relation to grid 0, 0 position.

 

Could someone help me with this script?

 

Thank you.    

0 Likes
Reply
2,582 Views
5 Replies
Replies (5)

MedalHellWay
Collaborator
Collaborator

Ok, with more calm I have write a better script for stamp the selected Vertex Position of a ObjPoly.

 

Select The vertex and run script.

Save your file .csv with your name

Print the result in file .csv with separate columns for the x, y and z

 

I hope this can help you. 

 

0 Likes

RadioRahim
Collaborator
Collaborator

I tried running this and all I get is:

Name: Point001

X Y Z

with no coordinates.

I ran the script as instructed. Is this script supposed to create cooridnates in ths CSV file?

0 Likes

MedalHellWay
Collaborator
Collaborator

You have select the vertrex? The script work well...

 

Name: Box01  
     
X Y Z
     
-18.2595 -20.8713 0.0
18.2595 -20.8713 0.0
-18.2595 20.8713 0.0
18.2595 20.8713 0.0
-18.2595 -20.8713 27.0743
18.2595 -20.8713 27.0743
-18.2595 20.8713 27.0743
18.2595 20.8713 27.0743

 

Follow this step: Open Script, Save tha path with button "Path Save". Then Select the vertex and press "Stamp".

0 Likes

Anonymous
Not applicable

Script NOT work well,   try over and over.    works only sometimes??

 

 

Also how to get the vertex coordinate similar to the values found in the transform tool.   The api coordinates do not match.

 3dsmax-vertex-coords.jpg

 

transform tool values

x = -14.057

y = -1.286

 

values retrieved by script result for same vertex

x =-42.4729

y =-8.58307e-06

 

 

how can I get values shown in transform typein?      and why do I have to reset 3dsmax to get this script to run successfully a second time?

 

THanks,

 

Frustrated.

 

 

0 Likes

MedalHellWay
Collaborator
Collaborator

Yeah, you're right @Anonymous... The script is totally wrong and I do not understand how I did not control the error, Im sorry ... Test this if work for you:

 

try (destroydialog ::gvp) catch()

rollout gvp "Print Vertex Point"
(
Global obj, dir_path, outFile, sv
	
button c_path "Path Save"
button c "Stamp Vertex Pos. XY"
	
	
	on c_path pressed do
	(
		dir_path = getSaveFileName caption:"Name Save File" initialDir:(getDir #export) filename:"PositionVertex_XY.csv"
        outFile = createFile dir_path
	)
	
		on c pressed do
	(
		selection.count == 1 and classof selection[1].baseobject == Editable_Poly
			---
		obj = selection[1].baseobject 
		format "Name: %\n\n" (selection[1].name) to:outFile
		format "% % % % %\n\n" ("X") (";") ("Y") (";") ("Z") to:outFile
sv = for i in $.selectedVerts do 
(
	format "% % % % %\n" (i.pos.x) (";") (i.pos.y) (";") (i.pos.z) to:outFile
)
			close outFile
	)
								
)
createdialog gvp style:#(#style_titlebar, #style_sysmenu, #style_toolwindow, #style_sunkenedge)

Below an example:

 

 test.jpg

0 Likes