move curve point as soon as locator moves


#1

Hi, everyone,
I placed two locators in the scene,
then created one curve :

 
curve -d 1 -p locator1.translateX loactor1.translateY locator1.translateZ
			   -p locator2.translateX loactor2.translateY locator2.translateZ

then how can i achieve the effect?

 
if (mouseMove And locatorIsMoved ) move curve.ep[0] to locator1.translation

ScriptJob did part of it. But curve.ep[0] was moved only when mouse had been released.
I also tried “connectAttr”, but

connectAttr curve.ep[0].translation locator1.translation

generated an error.

what can i do? Thanks in advance!


#2

you were almost there!

connectAttr locator1.t curve1.cp[0];
connectAttr locator2.t curve1.cp[1];

:nathaN


#3

It works!Thank you.
It turns out that “cp[0]” as a whole is the attribute to be connected, not “ep[0]”.
Connecting “cv[0]” also works.

I get two new questions:
1.
What are the differences between “cp” and “cv”?
2.
For curve with a degree of 3, controlPoints[1] is usually NOT on the curve, then how to connect locator1.t to the point exactly on the curve?
I tried:

 connectAttr anotherLocator.t anotherCurve.u[1]

I got: "// Error: The destination attribute ‘cc.u[1]’ cannot be found. // "


#4

What are the differences between “cp” and “cv”?

hmm… I’m not sure I can answer that… I’m guessing it’s something to do with the abstract parent classes that these nodes all inherit… Either way, I always use .cp for everything because it’s interchangeable with every point type, CVs, Verts, Lattice points, etc…

For curve with a degree of 3, controlPoints[1] is usually NOT on the curve, then how to connect locator1.t to the point exactly on the curve?

this is where it all get complicated… The short answer is that I don’t thnk you can… at least not in the way you’d want… you want to put a locator exactly on the curve at a specific position, and then when the user moves the locator the curve shape updates… right? unfortunately, I’m pretty sure this is a no-go, at least in scripting… I don’t think curves can behave like that… However, this is pretty much exactly how the Curve Editing Tool works, so it’s theortically possible…

The other way round is possible though, you can use animation constraints to fix objects onto curves, and this is the easiset and most straightforward way of doing it (afaik)… but you can also place locators in a curves underworld… this sounds spooky but it’s just a way of placing something into an objects u(v) space, rather than 3d coordinate space. This method is far more complex in theory, but in code it’s actually simpler than using constraints, and also means the locators won’t slide about when you move the curve.

probably not what you want in this case though.

:nathaN


#5

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.