redpawfx
I've tried this  2 different ways and it still crashes..

here's the scenario:

custom API emitter that checks to see if a specific PP attribute is on the particle object  its going to emit into.. if  the attr doesent exist then it  creates it.

I create the emitter and a particle object.  hook them up .  everything works fine.
step forward by a frame,  attr created.  all is good.
 
I delete the first particle object, and  create a new one,
hook it up via dynamic relationships editor, and  step a frame..
it seems to get thru the  adding of the  attributes  via  print statements, but  then it pauses for a  beat and segfaults maya. 

if however,  I  hook it up,   unhook,  and rehook, via the dynamic relationships editor   it then works fine. 

I am creating the  attribute    via   C++ api  but I have also tried doing  it via
MGlobal::executeCommandOnIdle  and neither one works..

I even tried  to   disconnect the  plug, make the connection, and reconnect the plug  via MGlobal::execute stuff but  it returned that it couldn't disconnect ! which I'm assuming is because there's  some safety stuff in the API that  keeps  code inside a compute from a connection  from deleting its own connection.. which I guess makes sense :-)

but  I can't figure out what to do to make this work.. I really don't want to resort to 
running a script job or something..

ugh...

any ideas?

thanks
-johnc
 

Reply 0 0
pshipkov
Hmm, hard to tell. This stuff is little tricky with the delayed evaluation in play.
Reply 0 0
redpawfx
Got some suggestions from the guys here,  any hints as to how to  create an PPattribute on a child connection (particle object) when  a dynamic relationship connection is made?  ie by setting up an MDagMessage callback for when connections are made?   I'm hoping that  by taking the  add attribute call out of the compute block of the emitter, it might solve the issue.  Does this sound crazy? or  should it be doable?

thx.


it worked!   made a  MDGMessage callback for  connections made, filtered by  node type and  did my thing... seems to work well.
-j


Reply 0 0
pshipkov
Maybe, i don't know, but you should try with callback outside the compute block. Let me know how it goes.
Reply 0 0
Reply