Notifications
Clear all

[Closed] Newbie – TreeView rootNode check

I use TreeView ActiveX with checkboxes
use on Nodecheck function and i want to separate action for Root Node checking.
My code:
[i]
on treeView NodeCheck theNode do
(
theSceneNode = (getNodeByName theNode.text)

                   if theSceneNode != undefined do theSceneNode.Enable_Particles = theNode.checked                     

[/i]
How i can catch rootnode checking?
I know that it must be somehow with index but my developing knowledge isn’t so good… 🙁
THANKS in advance…

4 Replies
1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

If theNode is the root of the tree, its parent property is undefined.

[i] on treeView NodeCheck theNode do
(
if theNode.parent == undefined then
print “You clicked the root!”
else
print “You clicked a tree leaf…”
)

[/i]

Very thank you for reply, now i got understand this ;).

I want to create script that can quickly turn off and turn on specific particle flow or afterburn system(i share this to cg particles community).
But now i have another problem with environments…

rollout AB_rollout "Afterburn" category:1
  	(
  	
  		activeXControl ABtv "MSComctlLib.TreeCtrl" width:160 height:180 align:#center 
  	
  			fn ABinitTreeView ABtv ilTv=
  		(
  			ABtv.Indentation = 40*10
  			ABtv.LineStyle = #tvwRootLines		    
  			ABtv.LabelEdit = #tvwManual
  			ABtv.checkboxes = true
  		)
  		
  		
  		fn ABaddChildren ABtv theNode theChildren =
  		(
  			for c in theChildren do
  			(
  			    newNode = ABtv.Nodes.add theNode.index 4 "" c.name 0   --Error here
  				ABaddChildren ABtv newNode c.children
  			)
  		)
  		
  				
  		fn ABfillInTreeView ABtv =
  			(
  				theRoot = ABtv.Nodes.add()
  				theRoot.text = "Environments:"
  				theRoot.expanded = true
  			--	theRoot.checked = not hideByCategory.helpers
  				
  				
  				rootNodes = for i in 1 to numAtmospherics collect (getAtmospheric i).name
  				ABaddChildren ABtv theRoot rootNodes 	
  			)
  
  
  		on AB_rollout open do 
  			(
  			ABinitTreeView ABtv ilTv
  			ABfillInTreeView ABtv			
  			)
  				
  	)
  
  rf = newRolloutFloater "FX Control v1" 180 250
  addRollout AB_rollout rf 
  

Error – Unknown property: “name” in “Afterburn”

If someone have a little time to look at this, i will be VERY thankful

P.S. in environments must be some atmospheric added…

Thanks again

The code you were using as template was written to work with hierarchies of scene nodes. You cannot expect it to work with atmospherics without modifications



 (
 rollout AB_rollout "Afterburn" category:1
 (
 	  
 		  activeXControl ABtv "MSComctlLib.TreeCtrl" width:160 height:180 align:#center 
 	  
 		  fn ABinitTreeView ABtv ilTv=
 		  (
 			  ABtv.Indentation = 40*10
 			  ABtv.LineStyle = #tvwRootLines	    	
 			  ABtv.LabelEdit = #tvwManual
 			  ABtv.checkboxes = true
 		  )
 		  
 		  
 		  fn ABaddChildren ABtv theNode theChildren =
 		  (
 			  for c in theChildren do
 			  (
 			  	newNode = ABtv.Nodes.add theNode.index 4 "" c.name 0  
 				newNode.checked = isActive c
 				  --ABaddChildren ABtv newNode c.children
 			  )
 		  )
 		  
 				  
 		  fn ABfillInTreeView ABtv =
 		  (
 		    	ABtv.Nodes.clear() --clear the tree view before populating
 				  theRoot = ABtv.Nodes.add()
 				  theRoot.text = "Environments:"
 				  theRoot.expanded = true
 			  	rootNodes = for i in 1 to numAtmospherics collect (getAtmospheric i)
 		    	--check the root only if there is at least one active atmospheric: 
 		    	theRoot.checked = (for i in rootNodes where isActive i collect i).count > 0
 			  	ABaddChildren ABtv theRoot rootNodes 	
 		  )
 		
 		on ABtv NodeCheck theNode do 
 		(
 			if theNode.index == 1 then --if the root was checked...
 			(
 				--set all atmospherics to the state of the root
 		    	for i = 1 to numAtmospherics do setActive (getAtmospheric i) theNode.checked
 				--then repopulate the tree
 				ABinitTreeView ABtv ilTv
 				ABfillInTreeView ABtv	
 			)
 			else --if a leaf was checked,
 			(
 		    	theAtmNode = getAtmospheric (theNode.index-1) --get the atmospheric by index
 		    	setActive theAtmNode theNode.checked --and set its state to the checked state
 			)	
 		) 
 
   
   
 		  on AB_rollout open do 
 		  (
 			  ABinitTreeView ABtv ilTv
 			  ABfillInTreeView ABtv	    	
 		  )
 				  
 	  )
   
 rf = newRolloutFloater "FX Control v1" 180 250
 addRollout AB_rollout rf 
 )  
 
 

Oh man,
thank you VERY mutch