Curve point constraint

Discussions concerning programming of SOFTIMAGE©
Post Reply
Judicator
Posts: 39
Joined: 18 Apr 2013, 09:26

Curve point constraint

Post by Judicator » 06 Aug 2013, 15:31

Hey, guys.

I have a curve and i need to constrain it's different points to some different objects' position (in python) so their movement would animate the curve as-well.
I know you can do that easily in 3DS Max, but I couldn't find such type of constraint in SoftImage.
Any suggestions? For some reason I think it's not as difficult as I imagine.

Eugen
Posts: 331
Joined: 10 Jan 2010, 12:40
Location: Vienna/Austria
Contact:

Re: Curve point constraint

Post by Eugen » 06 Aug 2013, 15:57

Select Point(s) > MCP Edit > Cluster with Center
Then animate that center.

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 15:31
Skype: csaezmargotta
Location: Sydney, Australia
Contact:

Re: Curve point constraint

Post by csaez » 07 Aug 2013, 05:04

Or just envelope it using those objects as deformers, a lot cleaner than multiple deformers/clusters.

Ahmidou
Posts: 106
Joined: 04 Jan 2010, 14:00

Re: Curve point constraint

Post by Ahmidou » 07 Aug 2013, 06:05

envelope is way faster than cluster center!

Eugen
Posts: 331
Joined: 10 Jan 2010, 12:40
Location: Vienna/Austria
Contact:

Re: Curve point constraint

Post by Eugen » 07 Aug 2013, 07:34

Ahmidou wrote:envelope is way faster than cluster center!
I wonder why... isn't it the simpler algorithm? No weights and such.

Ahmidou
Posts: 106
Joined: 04 Jan 2010, 14:00

Re: Curve point constraint

Post by Ahmidou » 07 Aug 2013, 07:48

There is, you can modulate a cluster center op with a weight map, there also is some matrix multiplications for the offset,
and I'm not sure this operator is multitreaded.

Judicator
Posts: 39
Joined: 18 Apr 2013, 09:26

Re: Curve point constraint

Post by Judicator » 07 Aug 2013, 10:38

Thanx for the tips.
But how do I envelope them through python?
I've just started working with SoftImage about 3 months ago with some specific tasks, so sorry for dumb questions. Didn't have a chance to work with enveloping yet. For me it's still new.

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 15:31
Skype: csaezmargotta
Location: Sydney, Australia
Contact:

Re: Curve point constraint

Post by csaez » 07 Aug 2013, 19:28

General recipe: Do it manually and check the command log, look for those commands in the SDK docs and you will know ​​how to implement it ;)

http://download.autodesk.com/global/doc ... exEnv.html

Cheers!

Judicator
Posts: 39
Joined: 18 Apr 2013, 09:26

Re: Curve point constraint

Post by Judicator » 12 Aug 2013, 12:53

Everything worked fine. Thanks again!


... on second thought, somethings still wrong :D What I did is just created the envelope, adjusted the weights and used XSI's generated script.
But it doesn't seem to work this way. What could be wrong?
By "Argument 0 is invalid" it's pointing to "crvlist.pnt[0]", which is the first point of a curve. What's wrong with that?
Attachments
Error.png

Chris_TC
Posts: 411
Joined: 22 Mar 2010, 17:43

Re: Curve point constraint

Post by Chris_TC » 12 Aug 2013, 15:17

The argument error points to the envelope weights property.
(see documentation: http://download.autodesk.com/global/doc ... vWght.html)

Here's a version that should work:

Code: Select all

A = Application

op = A.ApplyFlexEnv("crvlist;sphere,sphere1,sphere2,sphere3,sphere4", "", 2)
env_weightcls = op(0).Parent

A.SIModifyFlexEnvWght(env_weightcls, "sphere", "crvlist.pnt[0]", 0)
Ideally, you'll want to use the object model for changing weights instead of running the ModifyFlexEnvWght command. See:
http://download.autodesk.com/global/doc ... ights.html

Judicator
Posts: 39
Joined: 18 Apr 2013, 09:26

Re: Curve point constraint

Post by Judicator » 13 Aug 2013, 12:39

Chris_TC wrote:The argument error points to the envelope weights property.
(see documentation: http://download.autodesk.com/global/doc ... vWght.html)

Here's a version that should work:

Code: Select all

A = Application

op = A.ApplyFlexEnv("crvlist;sphere,sphere1,sphere2,sphere3,sphere4", "", 2)
env_weightcls = op(0).Parent

A.SIModifyFlexEnvWght(env_weightcls, "sphere", "crvlist.pnt[0]", 0)
That worked perfectly. But what did you do here?
Chris_TC wrote:Ideally, you'll want to use the object model for changing weights instead of running the ModifyFlexEnvWght command. See:
http://download.autodesk.com/global/doc ... ights.html
That may be true, but unfortunately that means learning and experimenting and I don't have time for that now, since the deadline for the project is closing.
But maybe I'll study it when I have some free time. I'll have to learn all of this anyway.
Thanks for the help!

Chris_TC
Posts: 411
Joined: 22 Mar 2010, 17:43

Re: Curve point constraint

Post by Chris_TC » 13 Aug 2013, 22:37

Judicator wrote:That worked perfectly. But what did you do here?
You supplied a name as the cluster, but that name may not always be correct (for example if your curve already had an identically named cluster before you applied the script).

ApplyFlexEnv returns the automatic enveloping operator whose parent is the cluster you want (it actually returns a collection because you can run the enveloping command on multiple objects, so you'd get multiple operators - therefore I use op(0).Parent, assuming you only ever do this to one curve). By using that as the argument, you don't have to rely on string names. The other arguments are still strings ("sphere" and "crvlist.pnt[0]") - these too would be more bulletproof if they didn't rely on specific names, for example:

Code: Select all

mycurve = Application.Selection(0) #assuming you always select the curve first
# Then instead of "crvlist.pnt[0]" use this as your argument:
# mycurve.FullName + ".pnt[0]"

Post Reply

Who is online

Users browsing this forum: trendiction [Bot] and 16 guests