vcNode
vcNode is the object type for nodes, which are used by components and other objects to form simple and complex tree structures.
Properties
Name | Type | Access | Description |
Behaviours | List of vcBehaviour | R | Gets a list of all behaviors in node. |
BoundCenter | vcVector | R | Gets a vector from node origin to center of its geometry bound box. |
BoundDiagonal | vcVector | R | Gets a vector from center of node's geometry bound box to its upper corner using positive axis directions. |
ChildComponents | List of vcComponent | R | Gets a list of all components attached to the node at any depth in structure. |
Children | List of vcNode | R | Gets a list of nodes attached to the node at first level. That is, the node is parent to those nodes. |
Component | vcComponent | R | Gets the component of node. |
ComponentChildren | List of vcComponent | R | Gets a list of components attached to the node at first level. That is, the node is parent to those component root nodes. |
Dof | vcDof | R | Gets the degree-of-freedom (DOF) object that defines the joint properties of the node and its mechanism of movement.
If JointType is fixed, Dof will be assigned None. |
Geometry | vcGeometryContainer | R | Gets the container of geometry in node.
Geometry in container is result of evaluating node's feature tree, but can be manually set. |
IgnoreEvents | Boolean | RW | Defines if node ignores event passing in order to avoid the creation of cyclic calls. |
InverseWorldPositionMatrix | vcMatrix | R | Gets inverse of node's position matrix in World coordinate system.
Note: Using World matrix requires scene updating. |
JointExpression | String | RW | Defines an expression that when evaluated returns the joint definition of the node.
(Deprecated) Use vcNode.Dof.Joint if joint type is custom. |
JointType | Enumeration | RW | Defines the joint type of the node.
See Joint Constants for more information. |
MaterialInheritance | Enumeration | RW | Defines the mode for managing NodeMaterial property.
For example, node material could override feature materials and child nodes. See Node Constants for more information. |
Name | String | RW | Defines the node's name. |
NodeMaterial | vcMaterial | RW | Defines the node's material.
This property is used with MaterialInheritance to define how the node's material is assigned to its features and child nodes. |
NodeVisible | Boolean | RW | Turns on/off the visibility of the node but not its child nodes. |
Offset | String | RW | Defines an expression that when evaluated returns the offset of node. |
OffsetExpression | String | RW | Defines an expression that when evaluated returns node offset.
(Deprecated) Use Offset property. |
Parent | vcNode | R | Gets the parent node of this node. |
PivotExpression | String | RW | Defines an expression that when evaluated returns the pivot point definition of node.
(Deprecated) Use vcNode.Dof.Pivot if joint type is custom. |
PositionMatrix | vcMatrix | RW | Defines position matrix of node in parent coordinate system. |
RootFeature | vcFeature | R | Gets the root feature of node. |
Type | Enumeration | R | Gets the node's type, which identifies the node as either a simulation root node, component root node or a link in a component.
See Node Constants for more information. |
UserGeometry | vcGeometryContainer | R | Gets a container of geometry that is unique to the node. That is, the geometry of this container is never shared with other nodes. |
Visible | Boolean | RW | Turns on/off the visibility of the node and its child nodes. |
World | vcNode | R | Gets the 3D world/simulation root node. |
WorldPositionMatrix | vcMatrix | R | Gets the position matrix of node in World coordinate system.
Note: Using World matrix requires scene updating. |
Methods
Name | Return Type | Parameters | Description |
attach | None | vcNode node, [Boolean permanent] | Attaches a given node.
The permanent argument is optional, and its value is set to True by default. If you set the value to False, the Save button in the Visual Components user interface will remain disabled when you attach the node. See Example. Attach a node to another node during a simulation for more information. |
createNode | vcNode | Enumeration type, String name |
To be used inside an event and not on global scope. Creates a new child node of a given type and name for this node.This cannot be used to create a new 3D world root node. See Node Constants for more information. |
createBehaviour | vcBehaviour | Enumeration type, String name | Creates a new behavior of a given type and name in node.
See Behavior Constants for more information. |
delete | None | None | Deletes the node.
Deletion will fail if method is called in Python Script contained in the node. |
findBehaviour | vcBehaviour | String name | Returns the first behavior matching a given name in node or in one of its child nodes; otherwise returns None. |
findBehavioursByType | List of vcBehaviour | Enumeration type | Returns a list of all behaviors matching a given type in node and all of its child nodes; otherwise returns an empty list.
See Behavior Constants for more information. |
findFeature | vcFeature | String name | Returns the first feature matching a given name in node or in one of its child nodes; otherwise returns None. |
findNode | vcNode | String name | Returns the first child node matching a given name; otherwise returns None. |
getBehaviour | vcBehaviour | String name | Returns the first behavior matching a given name in node; otherwise returns None. |
getBehavioursByType | List of vcBehaviour | Enumeration type | Returns a list of all behaviors matching a given type in the node; otherwise returns an empty list.
See Behavior Constants for more information. |
getFeature | vcFeature | String name | Returns the first feature matching a given name in node; otherwise returns None. |
localToWorld | vcMatrix or vcVector |
vcMatrix matrix or vcVector vector |
Transforms the given matrix or vector from node’s coordinate system to the world coordinate system and returns that with a new instance. |
measureDistance | 4-tuple (Real distance, vcVector point1, vcVector point2, vcVector direction) |
List of vcNode list or n-tuple of vcNode tuple |
Returns the minimum distance between the geometry of this node and a node or a given list of nodes. Additional values returned are position vectors for the two closest points, point1 and point2, as well as a direction vector indicating the distance and direction from those points. If no minimum distance found, returns None. Note: The returned vector is based in the coordinate system of the node calling this method. |
rebuild | None | [Integer rebuild_tree] | Rebuilds the geometry of node and its hierarchy by re-evaluating their feature trees. The hierarchy contains child components. Note: Try to avoid using this method during a simulation. |
update | None | [Integer update_tree] | Updates the node and its hierarchy. The hierarchy contains child components. |
worldToLocal | vcMatrix or vcVector |
vcMatrix matrix or vcVector vector |
Transforms the given matrix or vector from world coordinate system to the node’s local coordinate system and returns with a new instance. |
Events
Name | Parameters | Description |
OnNodeTransform | vcNode node | Triggered when a node is transformed in 3D world. |
Examples
Example. Access parent and child nodes
from vcScript import * app = getApplication() comp = app.findComponent("Articulated Robot") # find a component node node = comp.findNode("Axis 1") childNode = node.Children # get the child nodes for i in childNode: print i.Name |
Example. Attach a node to another node during a simulation
from vcScript import * def OnRun(): comp = getComponent() comp2 = getApplication().findComponent("example") delay(1) #retain the position of attached node in 3D world m = comp.InverseWorldPositionMatrix * comp2.WorldPositionMatrix comp.attach(comp2, True) comp2.PositionMatrix = m print comp.ComponentChildren |
Example. Toggle visibility of node and/or child nodes
from vcScript import * ##tested with KR 16-2 robot comp = getComponent() node = comp.findNode("A2") node.NodeVisible = False |
from vcScript import * ##tested with KR 16-2 robot comp = getComponent() node = comp.findNode("A2") node.Visible = False |
Example. Measure the minimum distance between geometries in given nodes
from vcScript import * # measures the distance between nodes # prints the distance in millimeters # and visualizes the shortest distance with a line in 3D app = getApplication() conveyor1 = app.findComponent('Conveyor') conveyor2 = app.findComponent('Conveyor #2') conveyor3 = app.findComponent('Conveyor #3') ##3 alternatives for using measureDistance()-method return_tuple = conveyor1.measureDistance([conveyor2, conveyor3]) # List of vcNodes as argument #return_tuple = conveyor1.measureDistance((conveyor2, conveyor3)) # 2-Tuple of vcNodes as argument #return_tuple = conveyor1.measureDistance(conveyor2, conveyor3) # 2 vcNodes as arguments distance, point1, point2, direction = return_tuple print distance geo_container = app.Simulation.World.UserGeometry geo_container.clear() line_set = geo_container.createGeometrySet(VC_COMPACTLINESET) mtx = conveyor1.WorldPositionMatrix line_set.addLine([mtx*point1, mtx*point2]) line_set.update() app.render() |