vcComponent
vcComponent is the object type for a component and its associated root node.
Inherits: vcNode
Properties
Name | Type | Access | Description |
BackfaceMode | Enumeration | RW | Defines the mode for rendering geometry backfaces of component. That is, geometry not facing active camera.
See Component Constants for more information. |
BOM | Boolean | RW | If a component is included in the bill of materials. |
BOMdescription | String | RW | Component description in the bill of materials. |
BOMname | String | RW | Component name in the bill of materials. |
Category | String | RW | Defines the component group in Cell Graph. |
Container | vcContainer | R | Gets the container storing the component.
If a component is not stored in a container, the value is None. Note: Container refers to a behavior that can store components, for example a One Way Path. |
CreationTime | Real | RW | Defines the creation time of component.
Generally, creation time is used for gathering statistics about components created during a simulation. In some cases, you might want to edit the creation time of a component for filtering, tracking, assembly and manufacturing purposes. |
IsUnique | Boolean | R | Indicates if the component is sharing its feature trees with other components. |
Locked | Boolean | RW | Defines if the component is locked from being edited or manipulated in 3D world. |
Material | vcMaterial | RW | Defines the material of component and any of its features which do not have an assigned material or whose node is set to inherit a material.
This material definition is persistent data, meaning that the definition is stored when saving component. Note: Changing the material definition of a component causes all geometries to be rebuilt, which can be a computing intensive operation. For in-simulation visualization purposes, we recommend using the NodeMaterial property instead. |
MovementOrigin | vcMatrix | RW | Defines the offset of component when moving on a path. |
PackFolder | vcPackFolder | R | Gets the mechanism for attaching files to component. |
PathAcceleration | Real | RW | Defines the acceleration of component when moving on a path. |
PathDeceleration | Real | RW | Defines the deceleration of component when moving on a path. |
PathVelocity | Real | RW | Defines the velocity of component when moving on and in the direction of a path.
If a zero value, the velocity of the component is defined by the path. |
PDFExportLevel | Enumeration | RW | Defines the level of detail when exporting component to a 3D PDF.
See Component Constants for more information. |
Product | vcProduct | R | The Process Modeling product instance linked to this component, if any. |
Properties | List of vcProperty | R | Gets a list of all user defined properties in component. |
SimulationLevel | Enumeration | RW | Defines the simulation level of the component.
See Component Constants for more information. |
Uri | String | R | Gets the URI of component |
VCID | String | RW | Defines the VCID of component. That is, the unique key identifier of the component.
Generally, you should never set this property. Instead, allow the application to generate a VCID when you save the component. |
Visible | Boolean | RW | Turns on/off the visibility of component in 3D world. |
Methods
Name | Return Type | Parameters | Description |
clone | vcComponent | [Integer shared] | Creates a clone of component in 3D world, and then returns the new component.
If shared argument is non-zero the clone and original share geometry. That is, feature tree is shared not copied. This improves performance during simulation, but the cloned components cannot be edited separately (changing the appearance of either clone or original component affects all the others.) Cloning of a component is not allowed when 1) it's not attached to World 2) there is a hierarchy lock in the node tree, which happens during layout loading, or while moving a node from one place to another. |
createProperty | vcProperty | Enumeration type, String name, [Enumeration constraints] | Adds a new property of a given type and name to component, and then returns the new property.
An optional constraints argument can be used to define constraints for new property, which must be defined at the time of creation. See Property Constants for more information. |
deleteProperty | None | vcProperty property | Deletes a given property from component. |
getPathDistance | Real | None | If component is on a path, for example a conveyor path, returns the distance of component on path. |
getProperty | vcProperty | String name | Returns a property matching a given name in component; otherwise returns None. |
getTransportInfo | 4-tuple (Enumeration availability, vcNode node, vcContainer container, vcMatrix location) | vcComponent targetComponent | Returns information about a transport action for a given component.
Generally, a transport action is defined using an Action Container, Python Script and Transport Protocol. See Transportation Constants for information on availability options. |
incrementRevision | None | None | Increments the revision number of a file when using the save() method.
The effect is the same as the Increment Revision property in the Credits dialog when saving a file. |
makeUnique | None | None | Makes the feature trees of the component unique, thereby they are not shared with other components. |
save | None | String uri | Saves component to file using a given uri.
To save the component with a new VCID, set the VCID property of the component to an empty string. |
saveState | None | None | Saves the current state of component as its initial state. |
startMovement | None | [Boolean] | Start the movement of component in a flow, for example a path.
An optional Boolean argument can be used to override flow logic, thereby forcing component to move in flow. |
stopMovement | None | [Boolean] | Stops the movement of component in a flow, for example a path.
An optional Boolean argument can be used to override flow logic, thereby forcing component to not move in flow. |
transfer | None |
vcBehaviour behaviour, Integer port or vcConnector connector |
Transfers component into a flow and blocks Python execution until completion of transfer.
One option allows you to give two separate arguments for a behavior and port. Another option allows you to give a connector for performing transfer. A given behavior must be or derive from vcFlow and you should check for available capacity. |
transferNonBlocking | None | vcBehaviour behaviour, Integer port | Transfers component into a flow defined by a given behaviour and port without blocking Python execution. That is, call is executed immediately and does not wait for completion of transfer.
A given behavior must be or derive from vcFlow and you should check for available capacity. |
Events
Name | Parameters | Description |
OnNodeConfigurationChange | Enumeration type, vcNode node1, vcNode node2 | Triggered when a change occurs in component node hierarchy.
The node1 and node2 arguments are nodes affected by change. The type argument is the type of change that occurred in component. See Component Constants for more information. |
OnContainerTransition | vcContainer container, Boolean value | Triggered when component enters or exits a vcContainer object.
The value argument will be True if component is entering a container; otherwise value is False if component exiting a container. |
Examples
Example. Basic uses of vcComponent
from vcScript import * # note: some of the methods called via comp in this snippet are documented under vcNode def OnRun(): ## COMPONENT ## get the handle to a vcComponent object app = getApplication() comp = app.findComponent('MyConveyor') # access any component in the layout by name comp = getComponent()# typical way to access the owner component of the python script (preferred approach) ## BEHAVIOURS ## this is how you can create new behaviours in python cont = comp.createBehaviour(VC_ONEWAYPATH,'MainPath') cont = comp.createBehaviour(VC_COMPONENTCONTAINER,'MyCont') creator = comp.createBehaviour(VC_COMPONENTCREATOR,'MyCreator') ## this is how you can access the existing behaviours in the component (note: british english spelling) path = comp.findBehaviour('MainPath')# by name paths = comp.findBehavioursByType(VC_ONEWAYPATH) # by name (returns a list) path = paths[0] # access the first item in the list like this ## FEATURES ## this is how you can create new features in python transform = comp.RootFeature.createFeature(VC_TRANSFORM,'Trans') transform.Expression = 'Tx(200.0).Tz(400.0)' transform.Expression = 'Tx(%f).Tz(%f)' % (200.0, 400.0)# more pythonic way to do the same cylinder = transform.createFeature(VC_CYLINDER,'MyCylinder') cylinder.Height = str(500) ## this is how you can access the existing features block = comp.findFeature('Block') # find feature by name in the whole component root = comp.RootFeature # root feature exists for all nodes even if the component contains no geometry kids = root.Children # returns the list of all the direct children ## PARAMETERS i.e. properties ## this is how you can create new parameters radius_prop = comp.createProperty(VC_REAL, 'CylinderRadius') bool_prop = comp.createProperty(VC_BOOLEAN, 'ToggleThis') ## this is how you can access existing properties prop = comp.getProperty('CylinderRadius') prop.Value = 250.0 # or comp.CylinderRadius = 250.0 all_props = comp.Properties # list of all user defined properties in the component for p in all_props: # (Visible, PDFExportLevel and BackfaceMode -properties are also included) # loop the list and print name and value for each print p.Name, p.Value ## NODES i.e. links ## this is how you can create new links link1 = comp.createNode(VC_NODE, 'FirstLink') link1.OffsetExpression = 'Tz(200).Ry(45)' path = link1.getBehaviour('MainPath') # use get- instead of findBehaviour to search behs in specific node ## this is how you can access existing nodes link2 = comp.findNode('SecondLink') if link2: # test if a node named "SecondLink" exists print 'It is there! :) ' else: print "It's missing! :( " |
Example. Create Real Property with Min, Max and Default Values
from vcScript import * comp = getComponent() comp.createProperty(VC_REAL, "SurfaceLength",1) foo = comp.getProperty("SurfaceLength") foo.MinValue = 100 foo.MaxValue = 1000 foo.Value = 800 |
Example. Save file and increment revision number
from vcScript import * app = getApplication() comp = app.findComponent("component_name") name = comp.Name uri = "file:///C:\\Users\\[Username]\\Documents\\[ProductName]\\4.0\My Models\\" + name + ".vcm" comp.incrementRevision() comp.save(uri) |
Example. Identify components stored in containers
from vcScript import * #when the simulation is paused def OnStop(): app = getApplication() for c in app.Components: if c.Container != None: print c.Name #prints the name of components in storage |
Example. Get components with shared features
from vcScript import * app = getApplication() shared = [c for c in app.Components if c.IsUnique == False] for c in shared: #prints the same memory address print c.RootFeature |