Script Test 1


This sample shows the use of both class and instance level scripts. The scripts change the display name of the object they are implemented on. In order to script at this class leve, this sample has a custom type under Types, named "My Sphere".
ScriptTest1.xpkg

Click on the image to download the sample.

Script Test 1 - Blade3D
This type inherits from a regular Sphere, the difference is a single even script. The script is for the OnStartUChanged event. The script is as follows:

IObject startUProperty = context.Site.GetPropertyByName("StartU");



string val = context.Site.GetValueAsString(startUProperty);


context.Site.DisplayName = val;


This script gets the startU property value as a string, from the instance. It then sets this as the property grid display name for the instance.


Script Test 1 - Blade3D
There are two instances of MySphere in the scene. Their names are a numerical value. This is likely from the class level OnStartUChanged event script. However the first MySphere has an instance script. The script is for the OnRadiusChanged event, and is as follows:



IObject radiusProperty = context.Site.GetPropertyByName("Radius");


string val = context.Site.GetValueAsString(radiusProperty);



context.Site.DisplayName = val;

This script is almost the same as the class level script, except this instance script uses the radius value as its display name.


Try changing the Radius and StartU properties on the two spheres. The sample has two GUI sliders for this. The first slider modifies the first MySphere radius to activate the OnRadiusChanged event script. The second slider changes the second MySphere StartU to activate the class level OnStartUChanged event script.


X-Tatic
X-Tatic
Latest page update: made by X-Tatic , Jun 3 2007, 9:13 AM EDT (about this update About This Update X-Tatic Edited by X-Tatic


view changes

- complete history)
Keyword tags: None
More Info: links to this page
There are no threads for this page.  Be the first to start a new thread.