ScriptSpot

Forum topic · General Scripting

Need help setting up radio button

By Redballoon · 2014-04-17

Description

Hi,

I'm very new to scripting and stumbling at the basics. I followed a script tutorial from Louis Marcoux on how to animate the construction of a building. It's a simple script that rotations and unhides an object or multiple objects and added keyframes.

The problem I have is a want to link it up to a dialog box and control the timing and the direction of rotation. I've made it control the timing but I have no idea how to implement a radio button to control the x,y,z rotation axis.

Also since creating this as a microscript I've lost the abitlity to undo after running the script. It was fine when it was just a standard script, I could undo the keyframes applied but now it doesn't. Is this something to do with it being a microscript?

This is what I have so far and thank you for your help.

Attachments
Comments (2)

brttd · 2014-04-18

Just use something like this:


on BTN_CreateAnimation pressed do
(
   TheStartFrame = SPN_TheStartFrame.value
   TheEndFrame = SPN_TheEndFrame.value
   AnimationSegment = 5.0

   OffsetAnimation = ((TheEndFrame-AnimationSegment)-TheStartFrame)/Selection.count
   TheCurrentFrame = TheStartFrame
   
   case rdo_AxisRotation.state of
   (
      1:(
         --X rotation
         for a in Selection do
         (
            with animate on
	    (
               at time (TheCurrentFrame+5.0) in coordsys local a.rotation.x = 0.0 --change rotation axis here
			
	       at time (TheCurrentFrame +1.0) a.visibility.controller.value = 1.0
			
	       at time TheCurrentFrame in coordsys local a.rotation.x = degtorad (-120.0) --change rotation axis here
			
	       at time (TheCurrentFrame +0.0) a.visibility.controller.value = 0.0
			
	     )
             TheCurrentFrame = TheCurrentFrame + OffsetAnimation
         )
      )
      2:(
         --Y rotation
         --Copy and modify animation code
      )
      3:(
         --Z rotation
         --Copy and modify animation code
      )
   )
)

Hope this helps.

Works like a charm

Redballoon · 2014-04-18

Thank you so much for this, works like a charm. Never thought about states. I was trying to set it up to substitute the value x,y or z but couldn't get it to work. Still having trouble with the undo function, but I can live without it as long as I save before hand.

Thanks again