getVert -- runtime error

getVert -- runtime error

Anonymous
Not applicable
586 Views
2 Replies
Message 1 of 3

getVert -- runtime error

Anonymous
Not applicable
I have a problem with this practical example "How To ... Output Geometry Data To Text File - Part One"

http://docs.autodesk.com/3DSMAX/14/ENU/MAXScript%20Help%202012/files/GUID-38562330-1435-4112-9265-DE...

I draw a simple plane into the scene and while it is selected I click on my scripts button

mesh = snapshotAsMesh selection
out_name = ((GetDir #export)+"/testmesh.dat")
out_file = createfile out_name
num_verts = tmesh.numverts

for v = 1 to num_verts do
(
vert = getVert tmesh v
format "%," vert to:out_file
)

close out_file


this is very simplified part of the whole script I have but it suffices the purpose. Anyway when my command panel is on anything else than Modifiers tab this script throws an error:

maxscript rollout handler exception
-- runtime error: Mesh vertex index out of range: 8

If before running this script I switch to Modifiers list and then I run it it works fine. Why this is happening?
0 Likes
587 Views
2 Replies
Replies (2)
Message 2 of 3

Steve_Curley
Mentor
Mentor

(
thisMesh = snapshotAsMesh $Plane001
num_verts = thisMesh.numVerts

for v = 1 to num_verts do
(
thisVert = getVert thisMesh v
format "% %\n" v thisVert to:listener
)
)

"mesh" is a constructor for a new Mesh object - shouldn't be used as a varaiable name.
"tmesh" is undefined (on original line 4).

Removed the file handling as it's not relevent (in the context of the question being posed).
Forced the use of the object directly to remove any complications to with selections or the command panel. Always try reducing the code to the bare essentials when trying to debug a problem like this - the less code there is the less there is which can go wrong, which makes finding the problem much easier.

If you have a plane object (Plane001) in the scene, the above code works regardless of selection, command panel status etc, therefore simply changing the variable name (consistently) throughout that part of your script should fix the problem.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 3 of 3

Anonymous
Not applicable
I tried on very simple version of my script and it worked, so I it has to be something with my script anyway, I think I will go with obj exporter and will just make a parsing in my other software as this maxscript is extremely slow mesh with 8000 polys takes couple seconds to export...

thanks for your help
0 Likes