3DS Max - Capture Vertex World Space Data

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2013   #1
3DS Max - Capture Vertex World Space Data

Thank you.

Last edited by JohnAndersonArt : 02 February 2013 at 11:05 PM.
 
Old 02 February 2013   #2
What version of max and what geometry types are you trying to capture the positions of? Mesh, poly, patches splines, nurbs? If its patches, do you want to capture the patch vertice positions, or the resulting interior mesh vertex positions?

How do you want the results? Just printed to the maxscript listener, or to a text file?
 
Old 02 February 2013   #3
Here's a method for printing positions of editable poly object vertex positions line by line -


   for i in geometry where classof i == Editable_Poly do
  (
  	print (i.name + "'s" + " Vertice Positions:")
  	for j = 1 to (polyop.getNumVerts i) do print ("Vertex " + (j as string) + ": " + (polyop.getVert i j node:i as string))
  )
   


Without labels -

   for i in geometry where classof i == Editable_Poly do
  (
  	print (i.name + "'s" + " Vertice Positions:")
  	for j = 1 to (polyop.getNumVerts i) do print (polyop.getVert i j node:i as string)
  )
   


Obviously this can take a while, depending on your object and vertex counts. Here's a method for getting the positions horizontally in arrays which is much faster -


   for i in geometry where classof i == Editable_Poly do
  (
  	VertPosArray = #()
  	for j = 1 to (polyop.getNumVerts i) do append VertPosArray (polyop.getVert i j node:i)
  	print (i.name + "'s" + " Vertice Positions:")
  	print (VertPosArray as string)
  )
   


If you don't know how to run this, just copy this code into the maxscipt editor, and go to Tools - Evaluate All.

Keep in mind this method uses your current coordinate system, so remember to have it on world or view, if that's the space you want the positions in.

Last edited by Ian31R : 02 February 2013 at 03:25 AM.
 
Old 02 February 2013   #4
Ian31R,

Thank you so much for the response. I really don't know Max Script so I really appreciate it. I'm using 2012 currently and all models are editable polys. Is there any way to output to a text file or digital alternative rather than printing?

Thanks again,

John
 
Old 02 February 2013   #5
Well, I guess the next question is how do you want the data grouped and labeled? Do you want the data to look like -

Method 1 -
"Object's Vertice Positions:"
"Vert 1: [X,Y,Z]"
"Vert 2: [X,Y,Z]"
"Vert 3: [X,Y,Z]"
Method 2 -
"Object's Vertice Positions:"
"[X,Y,Z]"
"[X,Y,Z]"
"[X,Y,Z]"
Method 3 -
"Object's Vertice Positions:"
"Vert 1: [X,Y,Z],Vert 2: [X,Y,Z],Vert 3: [X,Y,Z]"
Method 4 -
"Object's Vertice Positions:"
"[X,Y,Z],[X,Y,Z],[X,Y,Z]"
Method 5 -
"[X,Y,Z],[X,Y,Z],[X,Y,Z]"
 
Old 02 February 2013   #6
I think method 3 is ok. If I'm reading it right, it identifies the objects and identifies the vert, then outputs the coordinates for that vert.
 
Old 02 February 2013   #7
Here's all the methods listed above, this will export the data to a text file "Vertex Position Data.txt" to the export folder in your 3dsmax documents folder.

Method 1 -

VertDataFile = createfile ((GetDir #export)+"/Vertex Position Data.txt")
for i in geometry where classof i == Editable_Poly do
(
	format "%" (i.name + "'s" + " Vertice Positions:") to:VertDataFile
	format "\n" to:VertDataFile
	for j = 1 to (polyop.getNumVerts i) do 
	(
		format "%" ("Vertex " + (j as string) + ": " + (polyop.getVert i j node:i as string)) to:VertDataFile
		format "\n" to:VertDataFile
	)
)
close VertDataFile

Method 2 -

VertDataFile = createfile ((GetDir #export)+"/Vertex Position Data.txt")
for i in geometry where classof i == Editable_Poly do
(
	format "%" (i.name + "'s" + " Vertice Positions:") to:VertDataFile
	format "\n" to:VertDataFile
	for j = 1 to (polyop.getNumVerts i) do 
	(
		format "%" (polyop.getVert i j node:i as string) to:VertDataFile
		format "\n" to:VertDataFile
	)
)
close VertDataFile

Method 3 -

VertDataFile = createfile ((GetDir #export)+"/Vertex Position Data.txt")
for i in geometry where classof i == Editable_Poly do
(
	format "%" (i.name + "'s" + " Vertice Positions:") to:VertDataFile
	format "\n" to:VertDataFile
	for j = 1 to (polyop.getNumVerts i) do format "%," ("Vertex " + (j as string) + ": " + (polyop.getVert i j node:i as string)) to:VertDataFile
	format "\n" to:VertDataFile
)
close VertDataFile

Method 4 -

VertDataFile = createfile ((GetDir #export)+"/Vertex Position Data.txt")
for i in geometry where classof i == Editable_Poly do
(
	format "%" (i.name + "'s" + " Vertice Positions:") to:VertDataFile
	format "\n" to:VertDataFile
	for j = 1 to (polyop.getNumVerts i) do format "%," (polyop.getVert i j node:i) to:VertDataFile
	format "\n" to:VertDataFile
)
close VertDataFile

Method 5 -

VertDataFile = createfile ((GetDir #export)+"/Vertex Position Data.txt")
for i in geometry where classof i == Editable_Poly do
(
	for j = 1 to (polyop.getNumVerts i) do format "%," (polyop.getVert i j node:i) to:VertDataFile
	format "\n" to:VertDataFile
)
close VertDataFile


Hope this helps!
 
Old 02 February 2013   #8
To change the path, change (GetDir #export) to whatever you want for example "C:\" with the quotes.
 
Old 02 February 2013   #9
Here's method 1 and method 3 that identifies the object and the vert in script files.
Attached Files
File Type: zip Export Vertex Data.zip (848 Bytes, 3 views)
 
Old 02 February 2013   #10
Perfect. Thanks so much. Worked like a charm. -- John
 
Old 02 February 2013   #11
NP, glad to help. Also if you're interested, here's how you get just the object's positions -
Method 3 -

ObjectDataFile = createfile ((GetDir #export)+"/Object Position Data.txt")
for i in geometry where classof i == Editable_Poly do
(
	format "%," (i.name + "'s Position:" + (i.pos as string)) to:ObjectDataFile
)
close ObjectDataFile
 
Old 02 February 2013   #12
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:17 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.