problem with Keys on DSpline parameters

Discussion about scripting with Python
mephis
Posts: 3
Joined: Tue Mar 18, 2008 5:50 am

problem with Keys on DSpline parameters

Postby mephis » Fri Apr 26, 2013 6:30 am

Hello,

I have a quick question about adding keys to parameters in DSpline, using Batch Script.

I need to be able to keyframe CP values, but I run into a problem:

When I do this:

curve = DSpline01.getParameterCurve("Axial strength")
newKey = Key.new()
curve.addKey(newKey)

It works.

But when I do this:

curve = DSpline01.getParameterCurve("@ CP Axial")
newKey = Key.new()
curve.addKey(newKey)

I get an error.

And yet I'm able to add keyframes to either parameter using right mouse click "Add
key".

Am I missing something? There is nothing in documentation, and I've searched the web
for a while with no success.

Thanks in advance.


m


User avatar
Otuama
Posts: 1155
Joined: Fri Apr 02, 2010 12:56 am
Location: Swansea
Contact:

Re: problem with Keys on DSpline parameters

Postby Otuama » Sat Apr 27, 2013 10:39 pm

I think you need to first find a way of getting the CP index number in order to add a key to one of that numbers parameters.

If you manually add a key to @ CP Axial etc then double click on @ CP Axial to open the curve you'll see:

DSpline01
--> Point 1 (the CP index)
----> Axial force
iCreate Ltd
'Strength does not come from physical capacity. It comes from an indomitable will.' - Gandhi
'What Does Success Look Like?' - iCreate Ltd

mephis
Posts: 3
Joined: Tue Mar 18, 2008 5:50 am

Re: problem with Keys on DSpline parameters

Postby mephis » Tue Apr 30, 2013 4:47 am

Thanks for the post.

It's the way you would normally access the CP's parameters by setting the CP index and then it's values, ie:

DSpline01.setParameter("@ CP index", 17)
DSpline01.setParameter("@ CP axial", 2.67)

Unfortunately, currently, there seems to be no way of setting actual keys, through script, unlike on the "base" strength parameters.
That prevents me from animating those values over time.

Jorge, has pointed out a workaround that solves half of my problem. The keying part.
It involves placing an expression that ties value of that CP's parameter to a position of a Null, for instance:

In curve editor open that parameter and add: null01.position.x

And then keyframe that null's position.

However, it still requires manually adding the expression, unless I can find way of that trough script.

Don't want to be doing that too often since some of my splines, so far, have had 60 CPs or more... :shock:


m

User avatar
Otuama
Posts: 1155
Joined: Fri Apr 02, 2010 12:56 am
Location: Swansea
Contact:

Re: problem with Keys on DSpline parameters

Postby Otuama » Tue Apr 30, 2013 8:04 am

What I meant was you need to access the CP in order to access the parameter within the CP.... I think.

Something like this:

accessCP = DSpline01.getParameter("@ CP index", 17)
acessCP.setParameter("@ CP axial", 2.67)

However, it doesn't seem to work and I can't think of another way around it and you're right. Creating expressions for 60ish parameters would be a pain.
iCreate Ltd
'Strength does not come from physical capacity. It comes from an indomitable will.' - Gandhi
'What Does Success Look Like?' - iCreate Ltd


Return to “Python-Scripting”

Who is online

Users browsing this forum: No registered users and 1 guest