Notifications
Clear all

[Closed] Helium – Storing UI with custom Attribute?

Has anyone managed to get Helium to store it’s UI with a custom attribute? I’ve tried doing as it says in the documentation but it doesn’t work, and tried the example but get the same error regarding HeliumIO.

I’ve marked up where it errors below. You’ll need Helium installed to test it…

	struct heliumExampleStruct
  		(
  
  		function refresh rol control =
  			(
  			if heliumOps.targetControl != control then
  				(
  				heliumOps.targetRollout = rol
  				heliumOps.targetControl = control
  				heliumOps.useMousePos = false
  				)
  			),
  
  		function rolloutPreOpen ca rol control =
  			(
  			-- if you attach helium to a material, you must make sure that here the material editor is open:
  			-- max mtledit
  			print "preOpen"
  			),
  
  		function rolloutPostOpen ca rol control = (print "postOpen"),
  		function rolloutClose ca rol control = (print "Rollout close"),
  		function resized ca rol control size = (print "reSized"),
  		function rolledUp ca rol control state = (print "rolledUp"),
  
  
  		function lbuttondown ca rol control = 
  			(
  			print "lbuttondown"
  			refresh rol control
  			),
  
  		function lbuttonup ca rol control = (print "lbuttonup"),
  		function lbuttonDblclk ca rol control = (print "lbuttonDblclk"),
  		function mbuttonup ca rol control = (print "mbuttonup"),
  		function mbuttondown ca rol control = (print "mbuttondown"),
  		function rbuttondown ca rol control = (print "rbuttondown"),
  		function rbuttonup ca rol control = 
  			(
  			print "rbuttonup"
  			refresh rol control
  			popupmenu HeliumMenu pop:mouse.screenpos
  			),	
  
  		function mouseMoved ca rol control = (/*print "mouseMoved"*/),
  		function mouseScroll ca rol control = (print "mouseScroll"),
  
  		function nodeClicked ca rol control index = (print "nodeClicked"),
  		function nodesDeleted ca rol control = (print "nodesDeleted"),
  		function connectionChanged ca rol control sourceNode targetNode inSocket outSocket status connectionCount = (print "connectionChanged"),
  
  		endOfStruct
  		)
  
  
  
  
  
  -- example for adding helium UI to a custom attribute:
  
  heliumPar_string = 		( "parameters helium_pBlock rollout:heliumRollout 
")
  append heliumPar_string ( "		(
" )
  append heliumPar_string ( "		heliumIO type:#float animatable:true default:0.0 
" )
  append heliumPar_string ( "		heliumStruct type:#string 
" )
  append heliumPar_string ( "		)
" )
  
  
  append heliumPar_string ( "rollout heliumRollout \"Helium\" 
")
  append heliumPar_string ( "		(
" )
  append heliumPar_string ( "		schematicControl s \"\" height:300 
" )
  
  append heliumPar_string ( "		on heliumRollout open do 
")
  append heliumPar_string ( "			( 
")
  append heliumPar_string ( "			if hStruct == undefined then hStruct = execute(heliumStruct) 
")
  append heliumPar_string ( "			if (isProperty hStruct \"rolloutPreOpen\") then hStruct.rolloutPreOpen this heliumRollout s 
")
  append heliumPar_string ( "			s.storageContainer = heliumIO.controller
")	-- this is essential for being able to load the data from the max scene into the schematic
  append heliumPar_string ( "			if (isProperty hStruct \"rolloutPostOpen\") then hStruct.rolloutPostOpen this heliumRollout s 
")
  append heliumPar_string ( "			) 
")
  
  append heliumPar_string ( "		on heliumRollout close do ( if (isProperty hStruct \"rolloutClose\") then hStruct.rolloutClose this heliumRollout s ) 
")
  append heliumPar_string ( "		on heliumRollout resized size do ( if (isProperty hStruct \"resized\") then hStruct.resized this heliumRollout s size )  
")
  append heliumPar_string ( "		on heliumRollout rolledUp state do ( if (isProperty hStruct \"rolledUp\") then hStruct.rolledUp this heliumRollout s state )  
")
  
  
  append heliumPar_string ( "		on s lbuttondown do ( if (isProperty hStruct \"lbuttondown\") then hStruct.lbuttondown this heliumRollout s )  
")
  append heliumPar_string ( "		on s lbuttonup do ( if (isProperty hStruct \"lbuttonup\") then hStruct.lbuttonup this heliumRollout s )  
")
  append heliumPar_string ( "		on s lbuttonDblclk do ( if (isProperty hStruct \"lbuttonDblclk\") then hStruct.lbuttonDblclk this heliumRollout s )  
")
  append heliumPar_string ( "		on s mbuttondown do ( if (isProperty hStruct \"mbuttondown\") then hStruct.mbuttondown this heliumRollout s )  
")
  append heliumPar_string ( "		on s mbuttonup do ( if (isProperty hStruct \"mbuttonup\") then hStruct.mbuttonup this heliumRollout s )  
")
  append heliumPar_string ( "		on s rbuttondown do ( if (isProperty hStruct \"rbuttondown\") then hStruct.rbuttondown this heliumRollout s )  
")
  append heliumPar_string ( "		on s rbuttonup do ( if (isProperty hStruct \"rbuttonup\") then hStruct.rbuttonup this heliumRollout s )  
")
  
  append heliumPar_string ( "		on s mouseMoved do ( if (isProperty hStruct \"mouseMoved\") then hStruct.mouseMoved this heliumRollout s )  
")
  append heliumPar_string ( "		on s mouseScroll do ( if (isProperty hStruct \"mouseScroll\") then hStruct.mouseScroll this heliumRollout s )  
")
  
  append heliumPar_string ( "		on s nodeClicked index do ( if (isProperty hStruct \"nodeClicked\") then hStruct.nodeClicked this heliumRollout s index )  
")
  append heliumPar_string ( "		on s nodesDeleted do ( if (isProperty hStruct \"nodesDeleted\") then hStruct.nodesDeleted this heliumRollout s )  
")
  append heliumPar_string ( "		on s connectionChanged sourceNode targetNode inSocket outSocket status connectionCount do ( if (isProperty hStruct \"connectionChanged\") then hStruct.connectionChanged this heliumRollout s sourceNode targetNode inSocket outSocket status connectionCount )  
")
  
  append heliumPar_string ( "		)
" )
  
  
  
  --create CA string:
  heliumCA_string = ""
  append heliumCA_string "MCA = attributes heliumCA
"
  append heliumCA_string "(
"
  append heliumCA_string "local unusedDummyVar
"			-- prevent a bug in old max versions
  append heliumCA_string "local hStruct 
"
  append heliumCA_string heliumPar_string
  append heliumCA_string ")
"
  myheliumCA = execute(heliumCA_string)
  
  
  
  
  
  
  if selection.count > 0 then
  	(
  
  	custAttributes.add $ myHeliumCA #unique
  	$.heliumIO.controller = helium_Controller() -- ERRORS HERE "helium_Controller: undefined"
  	$.heliumStruct = "heliumExampleStruct()"
  
  	)
  -- end selection.count
  
  
  
  
  /*
  -- if you want to add it somewhere, code like below is required:
  max mtledit	-- for some reason material editor must be open before we can assign controllers below:
  custAttributes.add meditMaterials[1] myHeliumCA #unique
  meditMaterials[1].heliumIO.controller = helium_Controller()
  meditMaterials[1].heliumCA.prol.s.controller = meditMaterials[1].heliumIO.controller
  */
  
  /*
  -- if you want to assign to another material, be sure to re-execute so the CA is truly unique:
  max mtledit	-- for some reason material editor must be open before we can assign controllers below:
  custAttributes.add meditMaterials[2] myHeliumCA #unique
  meditMaterials[2].heliumIO.controller = helium_Controller()
  meditMaterials[2].heliumCA.prol.s.controller = meditMaterials[2].heliumIO.controller
  */