Skip to main content
MartinMH
Inspiring
September 23, 2015
Answered

Create Puppet Pin programmatically

  • September 23, 2015
  • 3 replies
  • 3075 views

Hi all,

I'd like to ask whether is it possible to create puppet pins programmatically...

I have tried to copy stream structure ("ADBE FreePin3", "ADBE FreePin3 Mesh", "ADBE FreePin3 PosPin Position", ...) of manually created pins with

corresponding values, but when I create streams this way they are disabled (AEGP_DynStreamFlag_DISABLED - and greyed out in UI).

I suppose that the vertex index "ADBE FreePin3 PosPin Vtx Index" is just an index to the array stored internally as arbitrary data so the mesh and pins must be created somehow before setting these values.

I've found this thread where they try to do the same thing using scripting (also without success  )Create Puppet Pin on existing mesh via scripting

I have some ideas about how this could be done using SDK, but all of them involve diving in very dark waters..

- call the EffectSuite::AEGP_EffectCallGeneric method with fake mouse click events (PF_Cmd_EVENT) or some direct PF_Cmd_COMPLETELY_GENERAL commands if the FreePin effect supports it

- use "FreePin Suite" - which is not a part of public SDK but can be aquired using AquireSuite... - but as it's not public I suppose it operates with memory which is not so safe to touch even if I managed to get/create proper header file for this suite

Maybe there is a simple elegant way of creating these pins which I completely overlooked, so I would be really thankful for any suggestions

Thanks a lot!

Martin

This topic has been closed for replies.
Correct answer MartinMH

Voila, I've just found a workaround...

step 1: save an animation preset with one Puppet effect applied (with desired number of pins - but it doesn't matter where you place the pins)

step 2: apply this preset on a layer (using AEGP_ExecuteScript("app.project.item(index).layer(index).applyPreset(presetName);") ) - which will add the puppet effect with pins

step 3: modify vertex offset stream values of existing pins using stream suite

step 4: reset effect (which will reload the internal state - pins will jump to correct place)

step 5: modify vertex position streams using stream suite

So all you need is a set of .ffx files with different number of puppet pins used - because they cannot be added programatically - but it is possible to modify the existing ones...

Thanks a lot for your support!

Cheers,

Martin

3 replies

cb43551664
Inspiring
March 19, 2018

Thanks, I will give it a try.

Chris

MartinMH
MartinMHAuthorCorrect answer
Inspiring
September 25, 2015

Voila, I've just found a workaround...

step 1: save an animation preset with one Puppet effect applied (with desired number of pins - but it doesn't matter where you place the pins)

step 2: apply this preset on a layer (using AEGP_ExecuteScript("app.project.item(index).layer(index).applyPreset(presetName);") ) - which will add the puppet effect with pins

step 3: modify vertex offset stream values of existing pins using stream suite

step 4: reset effect (which will reload the internal state - pins will jump to correct place)

step 5: modify vertex position streams using stream suite

So all you need is a set of .ffx files with different number of puppet pins used - because they cannot be added programatically - but it is possible to modify the existing ones...

Thanks a lot for your support!

Cheers,

Martin

françois leroy
Inspiring
September 25, 2015

Nice and smart!

Glad you found a way.

Cheers,

François

françois leroy
Inspiring
September 23, 2015

Hi Martin,

I don't really see where you could find the 'FreePin Suite'... If you do, I'm REALLY interested in getting it too! I've spent days trying to do it the scripting way, and as you said, without success...

I think the 'Real' Mouse event is the only way to go. You can check this thread for info:

Any way to click a button on an effect?

When I say 'Real mouse event', I mean that it's probably easier to programatically perform this click and let the FreePin tool deal with everything it needs.

At least easier than trying to emulate this click 'inside' the FreePin and have to do all the hard work that's been already done on their side.

Now, I hope I'm wrong and we can access this suite directly...

Cheers,

François

Community Expert
September 23, 2015

yo leroy! what's up?

if i'm not mistaking, the puppet tool adds some dynamic streams to the layer. perhaps these can be reverse engineered (sort of).

create a puppet effect with some pins in it. now recursively read that layer's streams, and read their match name.

now that you have that info, can these streams be created using the dynamic stream suite? (i don't know. i'm theorizing here)

all the stuff you need for this experiment is in the DynamicStreamSuite. (AEGP_AddStream, AEGP_GetMatchName, ect...)

MartinMH
MartinMHAuthor
Inspiring
September 23, 2015

yep, that's exactly what I've tried to do, but it doesn't work...

as I've said - when you create these streams manually (using dyn stream suite or via scripting) they are disabled (greyed out in UI) and the pins are not really present in the preview window...


btw. there is the "ADBE FreePin3 Outlines" stream of type AEGP_StreamType_NO_DATA called "Auto-traced Shapes"...

I'm not sure whether the NO_DATA streams can contain some arbitrary data (I think there is an AEGP_StreamType_ARB type for that purpose)

it would be easier to reverse engineer these streams if the arbitrary data was available via sdk api.. but apparently its not


moreover I don't really need to reverse engineer it completely - I just need to be able to serialize these streams and then create them on a different layer... something like copypasting it to a different layer... so if i could get a blob containing a raw binary data (if it was a simple structure containing only values not pointers etc) for these streams and if I was able to write this data blob to the new stream created using dyn streams suite, it would be enough for me...


all these values must be somehow serialized in aep file - so it should not be so hard to reverse engineer this structure, but it would be probably impossible to write them back without direct editing of aep file - which I really don't want to do... (reloading aep file would destroy undo stack etc)


anyway, thanks for suggestion!