Script & Plugin

juanb

New member
Hello,
I may be wrong but I have the impression that in a container, the plugins are applied after the script has been executed.
For example, when I want to retrieve the width of a text with the maxsize plugin, I can't get the right width. I always get the value before executing the maxsize plugin.
Is it possible to wait for the maxsize plugin to render before measuring the width?
Is there a special way of triggering a script once the rendering has been done?

(I don't want using OnExecutePerField)

I'm on VizArtist 3.13

Thanks


--------------------------------------------------------------------------------------------------------------------------------------------------

Bonjour,
Je me trompe peut-être mais j'ai l'impression que dans un container, les plugins sont appliqués après l'exécution du script.
Par exemple, lorsque je souhaite récupérer le width d'un texte ayant le plugin maxsize, je n'arrive pas à obtenir le bon width. J'obtiens toujours la valeur avant exécution du plugin maxsize.
Est-il possible d'attendre le rendu du plugin maxsize pour faire la mesure du width ?
Existe-t-il une méthode particulière pour pouvoir déclencher un script, une fois que le rendu est fait ?

(Je ne souhaite pas utiliser la méthode OnExecutePerField)

Je suis sous Vizartist 3.13

Merci
 
Perhaps by triggering a script when the container's Scale X changes. Is it possible to trigger a procedure when a container's Scale X changes?

I often use this.geometry.RegisterTextChangedCallback which triggers the OnGeometryChanged() but I don't know how to do it with the Scale X parameter. Has anyone done this before?

-----------------------------------------------------------------------------------------------------------------------------------------------------

Peut-être en déclenchant un script lorsque le Scale X du container change. Peut-on déclencher une procédure au changement du Scale X d'un container ?
J'utilise souvent this.geometry.RegisterTextChangedCallback qui déclenche le OnGeometryChanged() mais je ne sais pas le faire avec le paramètre Scale X . Quelqu'un l'a-t-il déjà fait ?
 
hi juanb,
Is it possible to trigger a procedure when a container's Scale X changes?
the only script Callback i know is OnGeometryChanged(). If you want to track Changes of a Container's Scaling you can use a workaround for getting the correct Boundingbox Dimensions using OnGeometryChanged():
  • Use the plugin TextBG in combination with a Rectangle
  • Configure the TextBG Plugin:
    • Size Parameter: W/H (> this will change the Geometry)
    • Text Container: select the BoundingBoxContainer you want to track. It can also be a ParentContainer with ChildContainers in it.
    • High Precision: True
    • Margins (Right, Left, Bottom, Top): 0.0
Here is an Example Scene named "BoundingBoxOnGeometryChanged" with a little Script:BoundingBoxOnGeometryChanged.png
  • RED: if you make changes within the Container "BoundingBoxContainer", the Red Background will change its Dimensions automaticly via TextBG Plugin.
  • GREEN: the Script watches the Geometry of "Red" and sets the Scaling of "Green" OnGeometryChanged()
Note: this workaround will only work for Dimensions, Scalings etc. - not for Positions. If you want to track Positions you can use OnExecPerField.

Hope that helps.
Cheers, Albi
 

Attachments

  • BoundingBoxOnGeometryChanged.zip
    595.5 KB · Views: 8
Hi Albi,
Your answer confirms what I thought. Relying on the behaviour of a plugin to trigger measures at the right time.
That said, when I look at your script, I discover a function I haven't used yet: RecomputeMatrix(). If I've understood correctly, it updates the values as if a redraw had been performed?
I've read that there's also something like RegisterAsListener but I don't know how to use it. VizEventName?
Anyway, thank you for your reply!

-------------------------------------------------------------------------------------------------------------------------

Bonjour Albi,
Ta réponse confirme ce que je pensais. S'appuyer sur le comportement d'un plugin pour déclencher les mesures au bon moment.
Cela dit, lorsque je regarde ton script, je découvre un fonction que je n'ai pas encore utilisé : RecomputeMatrix(). Si j'ai bien compris, cela met à jour les valeurs comme si un redraw avait été fait ?
J'ai lu qu'il existe aussi quelque chose comme RegisterAsListener mais je ne sais pas l'utiliser. Des VizEventName ?
Quoiqu'il en soit, je te remercie pour ta réponse !
 
Hi juanb,
exactly: RecomputeMatrix() recalculates the bounding box within the current frame. If you comment out this line in the code and, for example, change the text, you'll see that the bounding box still holds the value from before the last change. It feels like one frame "too late".

However, with the TextBG Plugin, you can monitor the bounding box of the parent container, and it doesn't matter which plugins the child containers use, regardless of any delay they might have (MaxSize, Autofollow, etc.). And the changes for all these plugins are monitored via OnGeometryChanged() and not via OnExecPerField().
 

Attachments

  • StageEvents.zip
    28.9 KB · Views: 12
Back
Top