Others have given examples that answer your question. If it is for debug or testing purposes, consider using Advanced feeder or library like Works to create boxes with different heights that are fed to conveyor as alternative to scripting.
I made a test layout in which the box changes its height when it is created during simulation. I do not recommend this approach for various reasons.
- It is just an experiment to test certain things such as feature sharing, feature tree evaluation, performance, expression calculation, troubleshooting primitive feature expression versus Transform scaling expression, part vs component creator, etc. I did not go so far with the layout to test with Python Feature since it is rarely used in component modeling, albeit as an alternative for Transform feature.
Layout - Box with Pseudo-random Height.vcmx (54.6 KB)
Some additional comments on keke and deadeye examples if it helps.
When box arrives at conveyor, it is transferred to path. A One-Way Path is vcMotionPath object that inherits from vcContainer.
The OnTransition event is from vcContainer. The event itself is logical (box is being transferred to or from path).
The OnPhysicalTransition is from vcMotionPath. The event itself is physical (box is physically entering or leaving the path).
Generally, an event-based approach is straightforward. That is what keke and deadeye did using the OnTransition event. Here are two lessons in Academy that might help if the concept is new to you in Visual Components Python API.
The examples of keke and deadeye use the random module in Python 2.7 to get a pseudo-random number. In keke’s example, keke uses a component property (parameter) to control the height, which is a real number. In deadeye’s example, deadeye uses expression, which is a string, to set a default property of a Cylinder feature. The expression is calculated to return a value (the calculated value).
Perhaps this lesson in Academy can help with understanding how Visual Components can generate pseudo-random numbers.
Side question: Do you plan on doing any machine learning for your robot or need to make datasets from the simulation?