Modify Parameter Blocks

You can edit an MCG tool's Custom UI property to extend the parameter block that is generated automatically, as well as override the parameter event handlers or create additional parameter blocks.

For example, you can add a parameter that is not present in the graph but is used elsewhere in your custom MAXScript code. You can also override the parameter event handlers, such as for list parameters in the graph.

To do this, you re-open the parameter block to make the needed modifications. Note that this does not override the previous block entirely. In particular, redefining an existing parameter will cause an error.

For example, this is the automatically generated parameter block for a graph with a single list parameter:

	parameters pblock rollout:params
	(
		MyList_Tab type:#floatTab tabSizeVariable:true
		on MyList_Tab tabChanged action index count do
		(
			if (paramsOpen) do mcgAPOps.FloatA_TabChanged action index count (this.params.MyList_UI) MyList_List MyList_Tab
		)
		on MyList_Tab set val index do
		(
			if (paramsOpen) do mcgAPOps.FloatA_TabSet val index (this.params.MyList_UI) MyList_List
		)
		_dummy type:#boolean -- this exists to enable easy invalidation of the object
		pluginGraph type:#filename assettype:#MaxCreationGraph readOnly:true enumAsAsset:true 
		pluginGraphDependencies type:#filenametab assettype:#MaxCreationGraph readOnly:true enumAsAsset:true tabSize:0 tabSizeVariable:true
	)

You can add a parameter and override the parameter events by editing the Custom UI property as follows:

 -- Reopen the parameter block
 parameters pblock rollout:params
 (

  -- Add to the parameter block
	 MyExtraParam default:0 type:#float

	 -- Override the event handler for adding or removing an item in MyList
  on MyList_Tab tabChanged action index count do
  (
 	 -- my custom code goes here
  )

	 -- Override the event handler for setting a value in MyList
  on MyList_Tab set val index do
  (
 	 -- my custom code goes here
	 )
 )

	rollout params "Parameters"
	(
  
  -- Restore the default rollout contents   
<<ParamUIDefs>>
<<RolloutParamsHandlers>>

  -- Add UI for added parameter if desired
  spinner MyExtraParam "My Pretty Name" range:[-100, 100, 0] type:#float


  -- Redefine the rollout event handlers (not included in ParamUIDefs)
		on params open do
		(
			paramsOpen = true			mcgAPOps.OneColParamsOpen MyList_UI MyList_Tab mcgAPOps.ToStringFunc #("MyList") selected:&MyList_selection
		)
		on params close do
		(
			mcgAPOps.OneColParamsClose MyList_UI selected:&MyList_selection			paramsOpen = false
		)
	)

If you define additional parameter blocks then remember that in any scripted plug-in, each parameter block can be associated with only one rollout, and two or more parameter blocks cannot be associated with the same parameter block.