Python - How to Get Deformed Point Position?


#1

In a Python Effector, I’m grabbing some point positions from a series of splines.

for i in xrange(0, splinecount):
        new_pos = splines[i].GetPoint(ptnum)
        marr[i].off = new_pos 

All good! Except the splines are deformed, and GetPoint() doesn’t retrieve deformed points. Alas.

I tried this code snippet from 2013, but it seems to only incorporate the object’s matrix rather than deformers (was getting wonky results regardless.)

Any thoughts?

Thanks!
Luke


#2

BaseObject.GetDeformCache

You need to retrieve cache from splines.
need to test


#3

That does seem to be involved, but this thread at the plugin cafe reveals how kludgy it is in reality. Ugh.

http://www.plugincafe.com/forum/forum_posts.asp?TID=11999

Even in some brief tests here, sometimes it returns “None”, other times it gets a result - but the result isn’t the deformed spline. Sigh…

It’s annoying in general, because in Xpresso the Point node just has a toggle for getting deformed points.


#4

Hah, looks like I can now accomplish my needs for the project just by cloning onto the spline. :smiley:


#5

This new example was added in R21 https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/c7116c37eb7bb357294d60dd009aebb7e044153f/scripts/04_3d_concepts/scene_elements/scene_management/basedocument_read_animated_mesh_r16.py and should covers your needs.

For any further questions, please contact us on plugincafe.com.


#6

Thanks for sharing. I realize that that sample is accomplishing many things unrelated to this specific task, but it shouldn’t take that many line of code just to get the position of a single point. As much as some cringe at the complexity of Houdini, this task requires just a short snippet of code in that program:

point(0,“P”,@ptnum)

Perhaps a similar function could be implemented such as: GetPosition(ptnum,1) - with the the latter digit being 0 for local and 1 for global.

It’s these sorts of things that encourage/discourage people from creating more complex setups in Cinema.


#7

op.GetDeformCache().GetPoint(ptIndex) should do what you want, unfortunately it will not works in any case as Cinema 4D is a bit more context specific than Houdini.

E.g. a cloner and a cube is an object generator, but they are different, since a cube creates only a cube, while a cloner create a whole hierarchy. So is not the same things, the previous example take care of all of this, but if you read the previous example most of stuff are useless for you special needs.

Cheers,
Maxime.


#8

Thanks Maxime for the info!