vcProductTypeManager

The product type manager is used to create, modify and delete vcProductType or vcAssemblyProductType objects. It is owned by a vcProcessController.

 

Properties

Name Type Access Description
Controller vcProcessController R Gets the owner process controller.

ProductTypes

List of vcProductType or vcAssemblyProductType R Gets a list of all product types in this process controller. vcAssemblyProductType are listed where appropriate.

Methods

Name Return Type Parameters Description
createProductType

vcProductType

or

vcAssemblyProductType

String name, vcProcessFlowGroup groupToPlaceObject, Boolean createAssemblyProductType

Creates new product type and assigns it to the given flow group. The name must be unique.

When createAssemblyProductType is set to True, creates and returns vcAssemblyProductType. Otherwise, creates and returns vcProductType.

deleteProductType None

vcProductType typeToDelete

or

String typeName

Tries to delete the given product type. Cannot delete system product types or product types from a different process controller.

Tries to delete product type with given name. Cannot delete system product types or product types from a different process controller.

findProductType vcProductType

String name

Tries to find a product type with the given name. Returns None if not found.

Events

Name Parameters Description
OnProductTypeAdded

vcProductType or vcAssemblyProductType productType 

Triggered when a new product type has been added to this process controller.

OnProductTypeRemoving

vcProductType or vcAssemblyProductType productType

Triggered when a product type is being removed from this process controller.

Examples

Example. Access the vcProductTypeManager from the ProcessController

from vcScript import *
 
process_controller = getSimulation().ProcessController
product_type_manager =  process_controller.ProductTypeManager

Example. Check to which process controller the manager belongs to.

#print product_type_manager.Controller
Get the list of ProductTypes
##To get the list of ProductTypes
#print product_type_manager.ProductTypes

Example. Find and Create a new product type

#You need to get the flow group to add product types
flow_group_manager =  process_controller.FlowGroupManager
flow_group = flow_group_manager.findGroup('Flow Group #1')
my_productType = product_type_manager.findProductType('MyProduct')
if not my_productType:
  my_productType = product_type_manager.createProductType('MyProduct', flow_group)

Example. Delete a given product type

#if my_productType:
#  product_type_manager.deleteProductType('MyProduct')

Example. Get event when you add and remove product type from UI

def productAdded(prod):
  print 'New ProductType added. Product name is "{}".'.format(prod.Name)
def productRemoved(prod):
  print 'ProductType "{}" is removed.'.format(prod.Name)
  
product_type_manager.OnProductTypeAdded = productAdded #trigger when a new product type is added
product_type_manager.OnProductTypeRemoving  = productRemoved #trigger when a an existing product type is removed