Home Technical Talk

need help fixing max script

polycounter lvl 5
Offline / Send Message
Busterizer polycounter lvl 5
I am following video tutorial on exporting animated mesh from max, but I appear to have a problem that isn't present in the video. Namely i have undefined variable in loop. Since I am new to maxscript I don't know how to fix this without possibly breaking stuff further.

jump to 4:48 for the problem I am having
http://vimeo.com/album/1514565/video/19782065
at the start of the loop max gives l is undefined, which is reasonable, but it isn't present in the video anywhere, and the thing works. :(

Replies

  • Mrfred
    Offline / Send Message
    Mrfred polycounter lvl 4
    I doubt the issue comes from the tutorial, could you please paste your code so we can see what's missing?
    "i" shoudnt be undefined as i == a number ranging from 1 to obj ( which you should have declared above) number of verts

    do you declare obj when running the function?
    ig: fn exportmesh $box001 ($box001 = obj) and so on...
  • Busterizer
    Offline / Send Message
    Busterizer polycounter lvl 5
    here is the complete code from the video
    what I meant was that lowercase "L" in "for i in l to obj.NumVerts do" appears to be undeclared.
    function exportMesh obj fileName origin:obj = 
    (
    	local file = createFile fileName, 
    	vertStore = #(), 
    	numFrames = (animationRange.end - animationRange.start).frame as integer
    	
    	format "%, numVerts = %, numFrames = %\n\n" obj.name obj.numVerts numFrames to:file
    	format "Frame, Vert #, Delta\n" to:file
    	
    	for f = animationRange.start to animationRange.end do
    	(
    		sliderTime = f
    		for i in l to obj.NumVerts do
    		(
    			local v = coordsys origin getVert obj i
    			local dv = if vertStore[i] == undefined then v else v - vertStore[i]
    			vertStore[i] = v
    			format "%, %, %\n" (f.frame as integer) (i - l) dv to:file
    		)
    	)
    	
    	close file
    	edit fileName
    )
    

    the output i get is this
    exportMesh $Box "c:\\test.model" origin:$point
    -- Error occurred in f loop; filename: C:\Program Files\Autodesk\3ds Max 2013\scripts\export_tutorial.ms; position: 679; line: 20
    --  Frame:
    --   l: undefined
    --   f: 0f
    --   called in ExportMesh(); filename: C:\Program Files\Autodesk\3ds Max 2013\scripts\export_tutorial.ms; position: 683; line: 21
    --  Frame:
    --   ORIGIN: undefined
    --   file: <File:c:\test.model>
    --   filename: "c:\test.model"
    --   obj: $Box
    --   vertStore: #()
    --   numframes: 20
    -- Unable to convert: undefined to type: Integer
    
  • Mrfred
    Offline / Send Message
    Mrfred polycounter lvl 4
    you misread the tutorial ;)

    it's suppose to be be for i in 1 to... 1 = one(the number) NOT the letter L

    so change it in the loop and change this
    format "%, %, %\n" (f.frame as integer) (i - l) dv to:file
    
    to
    format "%, %, %\n" (f.frame as integer) (i - 1) dv to:file
    
  • Busterizer
    Offline / Send Message
    Busterizer polycounter lvl 5
    thank you, i also had to change coordsys variable to local since origin as shown in tutorial isn't valid in max anymore. Is there any difference between local and grid settings for coordinate system? I didn't notice any change in data that got stored.
Sign In or Register to comment.