Script Operator Issue
#1
Hi Tyson, there is a problem with Script Operator I would like to mention, when there are two flows having script operators in one tyFlow object, the script operator does not recognizes the picked geometry, it recognizes the geometry in only one flow if both flows are enabled, the other one goes to [0,0,0]. I don't think I am explaining my problem very well that's why I am attaching a max file, please look into it, and also when I click on the three dots button of script operator the max crashes.


Attached Files
.max   ScriptOp_forTyson.max (Size: 704 KB / Downloads: 195)
  Reply
#2
Hi Apratim,

The reason your second script is not working is because you're using the simulation index to get the vertex from the mesh, instead of the event index.

Since the teapot particles are born first, the simulation index for the box particles starts at 2082...so when you call "GetVert" with those simulation indices it returns [0,0,0] because those indices are outside of the range of vertices on the box. Call "GetVert(e)" instead of "GetVert(sInx)", because in your case the event index corresponds perfectly to the number of vertices in each mesh.

As for the crash, thank you for letting me know. I will fix that in the next build.
  Reply
#3
Thank you so much for letting me know, I am going to try it now.
  Reply
#4
I tried it and I got some questions first one is how one can call the event Index in script operator (right now i am getting it by custom properties and its working) ? Second is how I can evaluate the script only on first frame just like the timing rollout?
  Reply
#5
The event index is just the number from 0 to (eventParticleCount-1).

So for example, in the following code:

Code:
for (int i = 0; i < eventParticleCount; i++)
{

}

...i is the event index. You don't need to get it with a custom property.

If you only want to eval on a certain frame, you can just put a condition in your function that does a frame number comparison. In the script operator, "f" is the built-in frame number variable. Ex:

Code:
if (f == 10) //only evaluate at frame 10
{
  //do work
}
  Reply


Forum Jump: