Applies To
PPGLayout object
Description
This example demonstrates how to use the PPGLayout object.
Code
/* This example demonstrates a typical use of a custom pset with custom layout as a way of collecting some information from the user. */ // Step 1: Create a custom pset and define the data on it var oPSet=ActiveSceneRoot.AddProperty("CustomProperty",false,"Demo") ; // Color is made up of 4 components oPSet.AddParameter3( "MyR", siDouble ) ; oPSet.AddParameter3( "MyG", siDouble ) ; oPSet.AddParameter3( "MyB", siDouble ) ; oPSet.AddParameter3( "MyA", siDouble ) ; oPSet.AddParameter3( "EnumCtrl", siInt4, 4 ) ; // Step 2: Put the items on the layout with a custom UI var oPPGLayout = oPSet.PPGLayout ; oPPGLayout.AddGroup( "Pick a Color" ) ; var oItem = oPPGLayout.AddColor( "MyR", "",true ) ; oItem.SetAttribute("NoLabel", true ) ; oPPGLayout.EndGroup() ; oPPGLayout.AddEnumControl( "EnumCtrl", new Array( "item 1", 4, "item 2", 6 ), "Choice", siControlCombo ) ; // Step 3: Show the user the dialog. They can change the // parameter values and then click OK or Cancel try { InspectObj( oPSet, "", "Check out this layout created from scripting", siModal ); // Step 4: Read the values and do something with them. Normally this // would be where you call a custom command which does the operation Application.LogMessage( "User picked the color (" + oPSet.Parameters("MyR").Value + "," + oPSet.Parameters("MyG").Value + "," + oPSet.Parameters("MyB").Value + "," + oPSet.Parameters("MyA").Value + ")" ) ; if ( oPSet.Parameters( "EnumCtrl" ).Value == 4 ) { Application.LogMessage( "User selected item 1" ) ; } else { Application.LogMessage( "User selected item 2" ) ; } } catch( e ) { // Tip: rather than using try/catch, you can specify false // as the 5th argument to InspectObj and it will not throw an exception Application.LogMessage( "User Cancelled" ); } //Step 5: Remove the pset now that we are done with it DeleteObj( oPSet ) ;
Related Examples
Keywords
PPGLayout AddButton AddColor AddEnumControl AddFCurve AddGroup AddItem AddRow AddSpacer AddStaticText AddString AddTab Clear Delete EndGroup EndRow GetAttribute SetAttribute Count Item Language Logic
Autodesk Softimage 2011