Visual Components' Community

New Thinking for Factory Simulation
Welcome to Visual Components' Community Sign in | Help
in Search

Changing dynamic component's parameters from the Component Creator

Last post pe, elo 15 2008 14:37 by RicardoVelez. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • pe, elo 15 2008 14:37

    Changing dynamic component's parameters from the Component Creator

    When a component creator is triggered to create a new dynamic components, the former can access the component API to modify the parameters of the dynamic component during simulation runtime. This can be achieved by creating parameters in the creator that will match the parameters in the dynamic component, then accessing these through a Python script. The code that performs this is as follows:

    from vcScript import *

    def OnRun():
      comp = getComponent()
      creator = comp.findBehaviour("ComponentCreator")
      conv = comp.findBehaviour("One-WayPath")
      #this is used as a dummy counter
      counter = 0
      while counter <comp.CreatorLimit:
        delay(creator.Interval)
        #the system will delay the creation of new components,
        #as long as there is a component in the path
        while conv.ComponentCount >0:
          delay(creator.Interval)
        #a component is created
        ccomp = creator.create()
        #A small delay to ensure that the component is already in the 3Dworld
        delay(0.1)
        #Simply match the parameters of the dynamic component to those of the creator
        ccomp.getProperty("ProductSizeX").Value = comp.getProperty("ProductSizeX").Value
        ccomp.getProperty("ProductSizeY").Value = comp.getProperty("ProductSizeY").Value
        ccomp.getProperty("ProductCountX").Value = comp.getProperty("ProductCountX").Value
        ccomp.getProperty("ProductCountY").Value = comp.getProperty("ProductCountY").Value
        ccomp.getProperty("PalletSizeX").Value = comp.getProperty("PalletSizeX").Value
        ccomp.getProperty("PalletSizeY").Value = comp.getProperty("PalletSizeY").Value

     

    Simply the code matches the dynamic component parameters with those of the component creator. This is useful when a pallet is parametric, and the same pallet is loaded in different layouts with different size.

    Ricardo Velez
    Research and Development Manager
    Filed under:
Page 1 of 1 (1 items)