Lesson 11: What’s Bugging me? Part 2

According to my search engine page view requests it seems that lots of people are Googling these error messages so I thought I’d chuck a few more in to help people in their time of need.

viewport.setcamera = newCam
>> MAXScript Rollout Handler Exception: -- Unknown property: "SetCamera" in #Struct:viewport(

This is quite easy to do as it seems like you need to set a property to to tell the viewport which camera it should be, where as actually it’s a method function so you want to pass it an argument, see below how it should be.

viewport.setcamera newCam
fn myfunction arg
-- Error occurred in anonymous codeblock; filename: Y:\test.ms; position: 2023; line: 10
 -- Syntax error: at (, expected =
 -- In line: (

Another of the sometimes hard to trace bracket problems, it’s an easy mistake to make but can take bloody ages to spot why, when you’ve just missed out an = sign…. sigh…

fn myfunction arg =

doesfileexist (getdir #maxroot) + "plugins\\Test.dlx"
-- No ""+"" function for true

It can be quite easy to forget to bracket things in a way which leaves no confusion to a computer, in the example above it thinks it needs to evaluate doesfileexist and then add this to “plugins\\Test.dlx” not add (getdir #maxroot) to “plugins\\Test.dlx”. I’m always in favour of putting in extra brackets to make damn sure you know what order things will be processed in.

doesfileexist ((getdir #maxroot) + "plugins\Test.dlx")
ObjsIwant = for o in objNames where matchPattern o pattern:"*mesa*" collect o
mergeMAXFile "c:\\project\\ep002_background_02.max" Objsiwant

and this is the error:

-- Error occurred in anonymous codeblock; filename: c:\project\merge_pattern.ms; position: 203; line: 3
 -- No "map" function for undefined

No ‘Map’ for undefined means the for loop doesn’t know what it’s looking in, in this case objNames wasn’t defined beforehand., so instead of the for loop looking in an array the loop was trying to use an unknown value which wasn’t an array it was just ‘undefined’

show standardmaterial()
 -- Argument count error: show wanted 1, got 2

Whenever you want to call the Show (or ShowProperties) function remember if you’re creating an instance to get the properties of you need to encase it in brackets.

show (StandardMaterial())

It’s worth noting that you are creating instances doing this, this is quite obvious when you try using a node/object type.

show (Sphere())

You’ll now have a sphere in your scene at [0,0,0]

s = CREATE_XML_Xmesh_test_01_.MS
 -- Unknown property: "MS" in undefined

This can be a silly thing when you’ve simply forgotten to put quotation marks around a string value.

s = "CREATE_XML_Xmesh_test_01_.MS"

About davewortley

Somewhere between an artist and a programmer, I like technical things, but being creative. I love problem solving and coming up with elaborate solutions. This blog is where I shall share ideas, tips, tutorials and anything that amuses me.
This entry was posted in Lessons, MaxScript. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s