Control Product Creator with boolean signal

Hello

I use a Product Creator to have a random distribution of three different product dropping vertical into a container. I would like to be able to use a sensor signal to pause product creation when the container is full (because the products drop, i cannot use the outpath capacity of the creator). In my py script i have tried to change distribution mode to “0” (single) on signal change and back to “3” (distribution). But even though i can see on the properties panel of the Product Creator, that the script is changing the mode, and i have changed the maximum number of single products to 0, the creator keeps running thus overfilling my container.

Is there an alternative way/method for controlling the Product Creator?

1 Like

Hello rasmussen,

maybe you can stop/start the creation of products in the OnRun Event by evaluating the sensor signal in the python script.

Something like this:

while True:
if sensorSignal.Value == True:
triggerCondition(lambda: getTrigger() == sensorSignal and sensorSignal.Value == False)
part = creator.create()

This won’t work (at least in 4.2.2) because the product creator behaviour doesn’t have a create method like the component creator.

Thank you @Max for the suggestion. As @TSy points out the “create” method is not present in the ProductCreator and i get “NameError: Attribute or method ‘create’ not found.” error. This is why i tried to modify its property “FeedMode” as a workaround, but i suppose modifying properties does not apply until model is restarted. I did try the “update” method to see if this would change the feed mode on the run, but it did not.

Sorry I misread. I thought it was a component creator!

What the op described sounds like a process. Some alt-ways to consider.

Hamburger - Use a Component Creator and try using the converter component in the eCat for making the components products.

Hotdog - Don’t use a Product Creator. Instead use a Process Executor to make the products according to the needed process.

Layout - Product Creator OnSignal.vcmx (339.6 KB)

Popcorn - Don’t use a Product Creator. Instead use a Process Executor and make a custom statement. A little tedious, and try to avoid scripting. For Hotdog, I used a script to set a property value because there is no requirement statement that can read a signal value. Sure, I could use a WaitSignal task, but that would mean by process is always running.

Fried Pickel - Play around with the Limit property of the creator in a script. Not a fan of this, and it is error prone.

Thank you @WilliamSmith for your thorough reply. I have been working my way through the “menu” but i still remain to find the solution. I have the following comments on your suggestions:

Hamburger: I don’t think i really need the converter - the component creator can create physics parts if the template file has physics entity. However, the component creator lacks the possibility to create a (random) mix of parts (in the attached layout my “Steak” solution is an attempt to randomly change the template file of the creator, but for some reason the entire simulation is updated when i try to do that).

Hotdog. This was my first introduction to use Process - cool. I managed to make it work ok. But (i am a difficult guy) i don’t see any way to save the feeder AND the configured process as a component that i can distribute to my students. When i insert the feeder from MyModels the process configuration is lost :frowning:

Popcorn. I did not really understand the difference from Hotdog, and still faced the problem of not being able to distribute a complete feeder component, so i did not pursue the popcorn.

Fried pickle. Using the Limit property of the creator shows the same problem as changing the distribution mode - the Limit property changes (I can observe it in the properties pane during simulation), but the creator somehow does not use the updated property (I tried again with creator.update and creator.Enable = False -> True)

Steak. My attempt to use a script to randomly change the template file of the creator (a semi-solution, as i still need to distribute the templatefiles separate from the model). Does not work because the simulation is “reinitialized” every time the template is changed!?

Thank you for trying to help :slight_smile: I will try to ask VC support.

Feeder enable tests.vcmx (429.5 KB)

Ok. Good luck.

With Hamburger, my concept is you create a Component Creator behavior for every type of part you need, and then use script to pseudo-randomly use one of the creators from the list of the creators.

With Hotdog, apologies. If it is new concept, be aware that product type definitions are saved with layout not component. You need to use API to create the product types when component is loaded (I forget, API for process modeling requires VC 4.2.1 or higher but don’t quote me on that). I attached a quick example, but apologies for the messy code. One thing missing from the quick example is how to deal with the order of creation when component is being loaded in 3D world. The Create statements in the Process Execute will have Null product type when you load the component because the product types in the script have not yet created them.
MyProductCreator.vcmx (23.8 KB)

With Popcorn, it involves creating an entirely new type of statement available in a Process Executor using a Python Process Handler.

With Steak, yes, changing the template on the fly can over cook it. That is one reason why Hamburger and Advanced Feeder in VC eCat use multiple Component Creator behaviors for each template. So maybe Hamburger Steak, but support can definitely help. If you get a working solution, please share on this thread.