How to make an object position follow the CV of a curve

How to make an object position follow the CV of a curve

flbishop
Community Visitor Community Visitor
1,702 Views
4 Replies
Message 1 of 5

How to make an object position follow the CV of a curve

flbishop
Community Visitor
Community Visitor

I have an issue I'm getting with an expression to match CV translation. I have a NURBS curve with a few CVs. I want an expression that makes the translations of a group (called "grp") match a specific CV on the curve. cv 4 in this case.

 

$globalUpdate_X = control.translateX;
$globalUpdate_Y = control.translateY;
$globalUpdate_Z = control.translateZ;
float $curve_cv1[] = `xform -q -ws -t curve.cv[4]`;
grp.translateX = $curve_cv1[0];

grp.translateY = $curve_cv1[1];
grp.translateZ = $curve_cv1[2];

 

When I edit the expression, the group pops the curve to where I would expect. When I translate the control, expecting the expression to fire off, I get this error: // Error: line 3: No object matches name: curve.cv [4]

0 Likes
1,703 Views
4 Replies
Replies (4)
Message 2 of 5

viru.gupta8
Enthusiast
Enthusiast

Hey,

As you are saying you have curve that have 4 cv.

so those will be cv[0], cv[1], cv[2], cv[3]

and in your code you are using cv[5] that might not be in curve so maya is throwing error "No object matches name: curve.cv [4]"

0 Likes
Message 3 of 5

flbishop
Community Visitor
Community Visitor

I can select the CV that it tells me it doesn't have. I am literally typing in the name, and it returns the CV. The code also works before I put the global update in.

0 Likes
Message 4 of 5

Anonymous
Not applicable

You can do this with the curveInfo node.  The resulting xyz positions will be in world of the curve.

 

followCV.jpeg

0 Likes
Message 5 of 5

sean.heasley
Alumni
Alumni

Hi @flbishop

 

I'm just checking in to see if you need more help with this. Did the suggestion that @Anonymous provided work for you?

If so, please click Accept as Solution on the posts that helped you so others in the community can find them easily.

 

 

0 Likes