Heavy simple script

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Search this Thread Display Modes
Old 05 May 2014   #1
Post Heavy simple script

Hi every body ... I'm new to rigging, having some issues & hoping if some one could help

I'm working on a project where I wanted to limit the position of a group of controllers with the position of another movable controllers so I used this script in a float script

Range = #(r1,r2,r3,r4,r5,r6,r7,r8)
ctrl = #(ctrl1,ctrl2,ctrl3,ctrl4,ctrl5,ctrl6,ctrl7,ctrl8)
for n=1 to 8 do
(
ctrl[n].pos.controller.zero_pos_xyz.controller.x_position .controller.upperlimit = (mult*range[n])+(xupper.position[1]-ctrl[n].parent.position[1])-1
ctrl[n].pos.controller.zero_pos_xyz.controller.x_position .controller.lowerlimit = (xlower.position[1]-ctrl[n].parent.position[1])-(mult*range[n])+0.5
ctrl[n].pos.controller.zero_pos_xyz.controller.y_position .controller.lowerlimit = (ylower.position[3]-ctrl[n].parent.position[3])-(mult*range[n])+2
)
centr.pos.controller.zero_pos_xyz.controller.x_pos ition.controller.upperlimit = (mult*r9)+(xupper.position[1]-centr.parent.position[1])-1+7
centr.pos.controller.zero_pos_xyz.controller.x_pos ition.controller.lowerlimit = (xlower.position[1]-centr.parent.position[1])-(mult*r9)+0.5+12.5
centr.pos.controller.zero_pos_xyz.controller.y_pos ition.controller.lowerlimit = (ylower.position[3]-centr.parent.position[3])-(mult*r9)+2+3
0

The ISSUE here is this made my scene heavy .... I think that this is because the script is evaluated so many times in each second & now I'm trying to use a timer but i can't get the hang of it ....
This simple timer ..

fn x =
(
timer clock interval:1000
on clock tick do print "m"
)

throws me this error ...

-- Error occurred in anonymous codeblock; filename: ; position: 72; line: 5
-- Syntax error: at ), expected while
-- In line: )

ANY SUGGESTIONS .....
Thanks in advance
 
Old 05 May 2014   #2
You definitely don't want all that code being evaluated every cycle!

Why not just use wire parameters or instanced controllers to drive your limits?

For example, lets say you want the x position of $obj1 to be the limit for the x position of $obj2:
$obj2.pos.controller.x_position.controller.upperli  mit.controller = $obj1.pos.controller.x_position.controller


Good luck
 
Old 05 May 2014   #3
Thanks for the quick reply...
Unfortunately this won't work for me because obj1 and obj2 have different parents & local positions ..... and i need to compare the position by the world position.

I could speed up my file dramatically by using float script on each limit separately.

I was trying to use the timer to make the code run every x (ex: 500) cycle instead of every cycle but unfortunately I couldn't get it to work right
 
Old 05 May 2014   #4
There are a few different ways to work around the world position issue...

Sticking with the previous example, to limit the local x pos of obj2 to the world x pos of obj1 you could create an expose transform helper and set it to reference obj1

paramwire.connect $ExposeTransform001.baseObject[#Expose][#World_Position_X] $obj2.pos.controller.X_Position.controller[#Limits][#Upper_Limit] "World_Position_X"


Or, if you want to limit the xpos of obj2 to obj1's x pos in relation to obj2's parent, create an expose transform helper and set it to reference obj1. Then set the local reference node to obj2's parent.

paramwire.connect  $ExposeTransform001.baseObject[#Expose][#Local_Position_X]  $obj2.pos.controller.X_Position.controller[#Limits][#Upper_Limit]  "Local_Position_X"


Hope that's more useful...
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:40 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.