Jump to content


Photo

Moving Object With Mathematical Expression?


  • Please log in to reply
3 replies to this topic

#1 Kjones

Kjones

    Member Pig

  • Adv Members
  • PipPip
  • 11 posts

Posted 30 October 2012 - 05:38 PM

Can I have an expression that will move an import object based off of a mathematical equation? I'm trying to calculate how many characters are in a Text 3D and shift the object down accordingly. I've found out I can get the text length by doing "string.len(Text1.StyledText[0])" but when I attempt to put the equation into an expression on the objects Z offset it just errors out on me. This is the equation I'm putting it.

"string.len(Text1.StyledText[0]) * 0.15"

Obviously I'm not doing this correctly has anyone ever moved an object, and if so how can I go about doing this?

Thanks
Kris
  • pterhi likes this

#2 isotron

isotron

    Flying Pig

  • Adv Members
  • PipPipPipPipPip
  • 237 posts

Posted 06 November 2012 - 05:42 AM

interesting , if u paste " print(string.len(Text1.StyledText[0])) " u get a number , but maybe string.len return not a correct variable to use... ?

#3 Tilt

Tilt

    Flying Pig

  • Adv Members
  • PipPipPipPipPip
  • 2,137 posts

Posted 06 November 2012 - 06:20 AM

Have you tried StyledText[0].Value?

#4 Kjones

Kjones

    Member Pig

  • Adv Members
  • PipPip
  • 11 posts

Posted 08 November 2012 - 05:40 PM

Alright update guys I've gotten the object to be moved, using an InTool Script. I've gotten it to work just fine in per frame situation but the problem is the the object has a tendency to jump from frame to frame even though the numbers don't change. I've tried to move it once in the Start Render Script but my object doesn't move any more. Same exact script from the Frame Render Script, I've printed out my values and everything is correct right up to the point where I need to apply the movement to the Transform3D. Here is an example of the script any idea on why it's not moving?


fusion = eyeon.scriptapp("Fusion")
size = Text1.LayoutSize
length = string.len(Text1.StyledText.Value)
distance = -((length * .12 + .0864) * size)
self.Transform3DOp.Translate.Z = distance

print("----------------------------")
print("distance: " .. distance)
print("size: " .. size)
print("length : " .. length)
print("location :" .. self.Transform3DOp.Translate.Z)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users