ConStructOr
Version:
0.4
Date Updated:
01/05/2011 This is a WIP function collection to make the working with structs in maxScript easier.
It's kinda inspired by: 1.Garp's Primitive maker in that you can quickly reDefine structs and 2.the lack of functions provided by maxScript.
The only functions in it so far are:
- addVar - add a property to a struct
- gotProperty - the equivalent of hasProperty or isProperty functions for a struct
Let me know what kind of functions you'd like to see in here
Additional Info:
( clearlistener() struct constructorStr ( addVar = fn AddVar str var2Add val2Add name isGlobal:false = ( local name = if classOf name == string then name else "conStructorTempStr" local propNames = getPropNames str local temp = str() local props = for prop in propNames collect getProperty temp prop local stri = "" for i = 1 to propNames.count do ( case i of ( 1 : ( stri += "struct "+ name + "(\n" stri += propNames[i] as string + " = " + props[i] as string + ",\n" ) default : ( stri += propNames[i] as string + " = " + props[i] as string + ",\n" ) (propNames.count) : ( stri += propNames[i] as string + " = " + props[i] as string + ",\n" stri += var2Add as string + " = " + val2Add as string + ")\n" ) ) ) local tStruct = if not isGlobal then copy (execute stri) else execute stri if not isGlobal do execute (name + " = undefined") return tStruct ),--END addVar FN gotProperty = fn gotProperty str propName = ( local propNames = for o in (getPropNames str) collect o as string findItem propNames (propName as string) != 0 )--END gotProperty FN ) global constructor = constructorStr() /***************************************************************************************************************/ /***************************************************************************************************************/ struct personC ( age, sex, job ) local personClass = constructor.AddVar personC #skills #() "humanClass" local raphael = personClass age:23 sex:#male job:#TechnicalArtist skills:#(#MaxScript, #WorkflowImprovement, #Ect) print raphael format "personClass.gotProperty #skills % \n" (constructor.gotProperty personClass #skills) format "personClass.gotProperty #height % \n" (constructor.gotProperty personClass #height) OK )--END local