[Closed] noob question about simulations through scripting
I’m kind of new to maxscript, but I think I’ve got the basics down, especially for the things I want to do.
It’s usually about automation, so I use the listener to see what a specific command looks like in scripting language.
So far so good.
My problem is that some commands don’t show at all in the listener, and I have thus no idea where to look to invoke the command through scripting.
For instance the ‘record’ function of the point cache modifier. – or some ‘start simulation’ options for plugins like Phoenix.
How do I find how to do this in maxscript, or is it simply impossible?
Everything in Max has a Class, you can find out what class your object is by typing the following into your listener with the object selected.
Classof $
To find out the class of a modifier for example you can do this…
Classof $.modifiers[1]
Where 1 is the top most modifier in the stack
With this Class information you can then use the ShowProperties() fucntion to see what is accessible via maxscript.
Showproperties (Point_cache())
(Note the brackets)
Result
.filename : filename
.recordStart (Record_Start) : float
.recordEnd (Record_End) : float
.sampleRate (Sample_Rate) : float
.strength : float
.relativeOffset (Relative_Offset) : boolean
.playbackType (Playback_Type) : integer
.playbackStart (Playback_Start) : float
.playbackEnd (Playback_End) : float
.playbackORTbefore (Playback_Out_Of_Range_Before) : integer
.playbackORTafter (Playback_Out_Of_Range_After) : integer
.playbackFrame (Playback_Frame) : float
.interpolationType (Interpolation_Type) : integer
.applyMeshToSpline (Apply_To_Spline) : boolean
.preLoadCache (PreLoad_Cache) : boolean
.clampGraph (Clamp_Graph) : boolean
.forceUncPath (Force_UNC_Path) : boolean
.loadType (Load_Type) : integer
.applyToWholeObject (Apply_To_Whole_Object) : boolean
.loadTypeSlave (Load_Type_Slave) : integer
For something like the Point_Cache modifier you can use ShowInterfaces() to see the ‘actions’ you can perform.
Showinterfaces (Point_Cache())
Result
Interface: pointCache
Properties:
Methods:
<void>record()
<void>setCache()
<void>enableMods()
<void>disableMods()
Actions:
I can’t seem to get the record() function to work right now, but your next stop of call (and mine) is the 3dsmax maxscript reference which points to the Cacheops struct…
[b][b][b]cacheOps Struct[/b][/b][/b]
[left][b][b]cacheOps[/b][/b].[b][b]DisableBelow[/b][/b] <PointCacheModifier>
[/left]
[left]Disables all modifiers below the Point Cache modifier.
[/left]
[left][b][b]cacheOps[/b][/b].[b][b]EnableBelow[/b][/b] <PointCacheModifier>
[/left]
[left]Enables all modifiers below the Point Cache modifier.
[/left]
[left][b][b]cacheOps[/b][/b].[b][b]RecordCache[/b][/b] <PointCacheModifier>
[/left]
[left]Records the cache data of the given Point Cache modifier to disk.
[/left]
So then to record the Point_cache you need to do the following…
cacheOps.RecordCache $.modifiers[1]
But it would probably be best to define the pointcache modifier at the start of your script so you don’t have to keep referencing it, or rely on having it selected.
thePC = $Plane01.modifiers[[color=maroon]"Point Cache"[/color]]
thePC.filename = "C:\ emp\\PC.pc2"
cacheOps.RecordCache thePC
Hopefully that gives you a bit of a breakdown on how to work things out for yourself in maxscript. Failing all that, google is your friend!
thanks for the useful breakdown, very helpful indeed.
I’ll try if I can get it to work like this. Again, thanks a lot!
cheers mate,
it works like a charm, this solves my problem – i’ve been having for about 24 hours now – completely.
Also thanks for the reasoning behind the problem, this will help my solve future problems as well!