Component properties and Python Features

I am working on creating components in Kuka Sim Pro 3.0.4 using Python Features and have managed to design some shapes. The shapes are designed parametric such that changing property values in python code changes the shape accordingly.
Now, I would like to make the process simpler by change the property values in the component property tab and get the changes done in the shape. Is it possible to share the variables defined in property tab directly in the python feature script ?


@zesty, @TSy Can you help me with the above asked problem?
I am a bit stuck at this stage.

You are a brave soul to use Python features. If I remember the Python feature must be recompiled/evaluated in its feature tree to update. A quick way to do that is dragging and dropping the Python feature on the root of the feature tree. I don’t remember if a bug with rendering was ever fixed in that version of Sim Pro, which involved geometry being persistent/remaining in 3D world as a rendering issue.

But in general, a feature has no direct way to know its component object let alone application object. you could try creating new properties for the Python feature, and then use a Python Script behavior to bind component property change event to update those feature properties, but this is getting crazy enough for me.

Thank you so much for replying.
I had to use Python feature as the component I am trying to create is not possible using primitive geometry shapes. :sweat_smile:
Yes, the rendering of created object is still an issue in this version. And the geometry remains unchanged in the 3D world. A trick to update the geometry is by changing value of any property in the component tree.
As you said, I tried using Python Script behavior to use variables to assign properties values to the variables in Python features. But it seems the variables cannot be shared between two python files. Component properties are accessible by the python script but not with the python feature file.
I am attaching my file below. If you could help me with the issue!
Torisphere.vcmx (21.3 KB)


All features are shared between clones of components, so your Python feature doesn’t have a single parent component from which to get properties.

You could try creating expression properties to your Python feature, and then those expressions might be able to access specific component’s property values as usual. Then your Python feature reads the values from those properties. I haven’t tested this, it might either not work at all or you might get same property values in all instances of your feature.

1 Like

I’m not going down the road of sharing variables between scripts and Python features, but the code example from Help file I modified to quickly test.

So I used a Python Script behavior to add properties to the feature, and then I could reference them in the OnEvaluate event because it gives me the feature object. The Python Script is an additional step. That is, you can use the Python Feature to add properties to the feature since the OnEvaluate event provides the feature object.

And you can reference component properties in the Expression property of a feature as Tsy mentioned. If the component properties have Rebuild component enabled, the Python Feature should update automatically as well.


Thank you so much for the help.
The problem is solved. :grinning: