I want to trigger a new product with a Boolean signal from a robot or push button.
I wrote the code below, it does everything but create a part.
from vcScript import *
Find the Product Creator and Boolean Signal behaviors
comp = getComponent()
pcreator = comp.findBehaviour(“ProductCreator”)
signal = comp.findBehaviour(“CreateProduct”)
def OnRun():
“”"
Executed when the simulation is started or reset.
Sets the creator’s limit to 0 to disable internal logic.
“”"
print(“nope”)
pcreator.SingleFeed.Limit = 0
pcreator.SingleFeed.Interval = 0
def OnSignal(signal):
“”"
Executed when a connected signal changes value.
“”"
if signal.Name == “CreateProduct” and signal.Value == True:
# Set the limit to 1 to create a single product
print(“Yup”)
pcreator.SingleFeed.Limit = 1
pcreator.SingleFeed.Interval = 1
# Wait for the creator to produce the item
# Note: In version 4.10, you can use creator.create() for Component Creators,
# but with Product Creators, setting the limit is the standard approach.
# Reset the limit and signal after the product has been created
# Delay this action slightly to ensure the product has time to be created.
delay(2)
#pcreator.SingleFeed.Limit = 0
signal.Value = False