Python Generator: how to access 'self' object?
-
On 22/08/2018 at 14:56, xxxxxxxx wrote:
In my Python Generator code I want to create an Object Selection tag and actually insert it in the Generator object itself, so the user can see it in the Object Manager.
But "self is not defined". How to do this?
-
On 23/08/2018 at 08:39, xxxxxxxx wrote:
Hi,
actually a Python Generator is not allowed to modify the scene, but only to generate "something" and return it. More precisely, this is true for the generator's main() function, which is called inside of the execution pipeline. The creation of a tag on the generator itself is a modification of the scene (cloning the tag onto the result of your main() is fine, though).
See Threading Information for more.But you could add a user data button to the generator. In reaction to this button you'd create the tag (button press/UI happens in main thread). How this is achieved is described in Call Command thread, see my first post a bit further down.
Then in the generator's main() you can clone the selection tag onto your result, applying modifications as needed (and described in your Animated user data for Python Generator - how? thread).The generator itself is referenced via op.
-
On 23/08/2018 at 12:28, xxxxxxxx wrote:
Thanks for the clarification.
I think it makes more sense to require the user to add a Texture tag to the Python Generator object - then the user can maintain complete control over the tag attributes (scale, offset, etc).
However, I don't want the texture tag to be applied to all geometry created by the Generator - I want to restrict it to just one specific poly, which is why I was inquiring about the Selection Object.
Is there any way for the Generator to implement this restriction? I assume it cannot add a Selection Object to the Texture tag added by the user, since that would be "changing the scene."
If I clone the Texture tag and add a Selection Object to my clone, I still need to prevent the original tag from affecting the other polys created in the Generator.
-
On 24/08/2018 at 05:39, xxxxxxxx wrote:
How about doing it slightly different? Just add a link user data parameter to the Python Generator, where the user can drag a material to. Then you generate your polys, add a selection tag and a texture tag to them, assigning the linked material to the texture tag. The restriction to certain polygons is simply done via the name of the selection tag, set for the respective parameter of the texture tag.
-
On 26/08/2018 at 13:19, xxxxxxxx wrote:
Thanks for the info