ScriptSpot

Forum topic · General Scripting

Unknown property... Please help, newbie issues -.-

By falconmick · 2012-09-06

Description

>> MAXScript Rollout Handler Exception:
-- Unknown property: "castShadow" in $Editable_Mesh:subMeshTest002 @ [-5.230925,6.493752,0.000000] <<
 "castShadow" in undefined <<
"castShadow" in Editable_mesh <<

I understand that Unknown property is a common problem.. But the reason why I'm posting about it is that I have make a check statement to see if the attribute exists.. and it's crashing because the attribute doesn't exist -,- which is counter intuitive. Also, for that object there was that custom attribute, so it didn't find it for some reason :(


if( objects[numNodes] == undefined) do continue

body = objects[numNodes] -- collision body to export

-- code emitted to save space

if body.castShadow != undefined then -- this right here is causing the exception.. but it's supposed to be checking for existance.. which non existance should be an acceptable outcome
(
--do stuff
)

the custom attribute is defined here:


newAttrib = attributes entityAttrib
(
	parameters posParam rollout:entParams
	(
		xPos type:#boolean ui:castShadow checked:false
	)
	

	rollout entParams "Entity Atributes"
	(
		checkbox castShadow "Casts Shadows?"
	)
)
custAttributes.add $ newAttrib

Maybe i'm doing this all wrong.. maybe somone can tell me the correct way to do the following:

I'm trying to add a rollout to object's to allow you to have custom properties which later my level (xml) exporter goes through all objects, it the attempts to see if each of the objects it is running through has the custom attribute, it will then add an xml node for that attribute if it existed... I might just resort to manually adding object properties, but that's not desirable and will also not solve the error mentioned at the start.

=========================================================
FULL SOLUTION:
=========================================================


newAttrib = attributes entityAttrib
(
	parameters posParam rollout:entParams
	(
		xPos type:#boolean ui:castShadow checked:false
	)
	

	rollout entParams "Entity Atributes"
	(
		checkbox castShadow "Casts Shadows?"
	)
)
custAttributes.add $ newAttrib

-- ---------------------------------------
-- THIS IS THE SOLUTION FOR ATTRIBUTES:!!!
-- ---------------------------------------
$.baseObject.entityAttrib.castShadow = on
isProperty $.baseObject #castShadow

and the solution for the exporter

change this:


if body.castShadow != undefined then
(
--do stuff
)

TO THIS


if isProperty body.baseObject #castShadow == true do			
(
     format "\t\t<castShadow> % </castShadow>\n" body.baseObject.entityAttrib.castShadow to:currentFile
)

=========================================================
FOR HELP LEARNING MAX SCRIPT:
=========================================================

EDIT: omited plausible illegal link
Also theses forums have many answered questions about maxscript
http://forums.cgsociety.org/forumdisplay.php?f=98
http://www.polycount.com/forum/
http://area.autodesk.com/forum/autodesk-3ds-max/maxscript/

Comments (8)

falconmick · 2012-09-06


if body.baseObject.entityAttrib.castShadow != undefined then					
(
     format "\t\t<castShadow> % </castShadow>\n" body.baseObject.entityAttrib.castShadow to:currentFile
)

is now causing this error:


>> MAXScript Rollout Handler Exception:
-- Unknown property: "castShadow" in entityAttrib:entityAttrib <<

barigazy · 2012-09-06

You need to use this

$.baseObject.entityAttrib.xPos = on
--or if you want to check it have the property use
isProperty $.baseObject #xpos
--true

falconmick · 2012-09-06

ok.. problem one fixed... my code is now this:


if isProperty body.baseObject #castShadow == true do			
(
     format "\t\t<castShadow> % </castShadow>\n" body.baseObject.entityAttrib.castShadow to:currentFile
)

still, the property does exist.. it's just not working

barigazy · 2012-09-06

If you want to use #castShadow property then you need to change
CA definition like this

newAttrib = attributes entityAttrib
(
parameters posParam rollout:entParams
(
castShadow type:#boolean ui:castShadow checked:false
)

rollout entParams "Entity Atributes"
(
checkbox castShadow "Casts Shadows?"
)
)
custAttributes.add $ newAttrib
--and then use >>
$.baseObject.entityAttrib.castShadow = on
isProperty $.baseObject #castShadow

falconmick · 2012-09-06

It worked.. Thank you very much... btw, if you were gonna try and solve problems what would u rely on other than the help file in 3ds or ur experience.. Like is there a good resource of examples?

by good, i mean, what would u use

falconmick · 2012-09-06

also, thanks for the fast and good replies.. A site like this with such good people on it is rare

barigazy · 2012-09-06

Yep.I share your opinion.
I also send you a mail
Cheers man!

kimarotta · 2012-09-06

Yeah Barigazy the best . =]