ScriptSpot

Forum topic · General Scripting

Scripted Modifier Animation Question

By PowerCreative · 2015-04-11

Description

I have a modifier I am working on that is almost fully functional. I cannot figure out how to get the value of an animated slider to return a command on each frame of animation.

on xxxxx set val do xxxxx does work unless I manually update the value on each frame.

Is there a better way to detect that a parameter has changed and to fire a command because of it?

Comments (1)

Grow Selection With Invert Modifier

PowerCreative · 2015-04-13

Below is the code I am working through. I have gotten closer, but now none of the ButtonOp commands work with an extended edit_poly or poly_select. Below is my current code with edit_poly extended. It is so close to functional.


plugin modifier PowerGrowSelMod
name:"PowerGrowSel"
classID:#(0xd5b9689, 0x5de6b389)
extends:Edit_Poly replaceUI:false version:2


( 
--ADD FUNCTIONS FIRST	
function  growsel = (
 modPanel.getCurrentObject()
 --print "growsel properly defined"  --FUNCTIONS PROPERLY
 frameInterval = this.frameInterval   --FUNCTIONS PROPERLY
 polySourceID = this.polySourceID  --FUNCTIONS PROPERLY
 invCb = this.invCb  --FUNCTIONS PROPERLY
 theLoopCount = (currentTime as integer)/TicksPerFrame --FUNCTIONS PROPERLY
 delegate.setSelection #Face #{} --clearSelection  --FUNCTIONS PROPERLY
 delegate.Select #Face #{polySourceID}
 for i = 1 to theLoopCount by frameInterval do ( --grow selection based off time and intervals
	--print ("CALL COUNT "+i as string)   --FUNCTIONS PROPERLY
	 delegate.ButtonOp #GrowSelection -- grow selection from stack
	) 
 if (invCb == true) then delegate.setSelection #Face -(delegate.getSelection #Face)  --FUNCTIONS PROPERLY INVERTS SELECTION
 delegate.ButtonOp #UnhideAllFace
 delegate.ButtonOp #HideFace
 redrawViews()
)

  parameters main rollout:params
  (
    frameInterval type:#integer animatable:true ui:frameInterval default:1
	polySourceID  type:#integer animatable:true ui:polySourceID  default:1 
	invCb type:#boolean animatable:true ui:invCb default:false
    on frameInterval set val do  growsel() 
	on polySourceID  set val do  growsel()  
	on invCb set val do  growsel() 
  )
  
rollout params "Power GrowSelection Params"
(
	spinner frameInterval "FrameInterval: " range:[1,999999,1] type:#integer
	spinner polySourceID  "SourcePoly#: " range:[1,999999,1] type:#integer
	checkbox invCb "InvertSelection" checked:false
)

on create do
(
delegate.SetEPolySelLevel #Face
growsel()
--callbacks.removeScripts #modPanelObjPostChange id:#PowerGrowSelCB1
--callbacks.addScript #modPanelObjPostChange "growsel()"  id:#PowerGrowSelCB1 persistent:true 
--callbacks.addscript #filePostOpen "growsel(frameInterval polySourceID  invCb)" persistent:true
unregisterTimeCallback growsel
registerTimeCallback growsel
)

)