vcLayoutSchemaPropertyList

vcLayoutSchemaPropertyList is a layout item and data structure used for handling large amounts of data.

Inherits: vcLayoutItem

Usage

vcLayoutSchemaPropertyList provides an extremely fast way to load and manipulate data while minimizing memory footprint. For example, you can create, delete, traverse, edit, visualize and pick a tool path and associated data which can be saved and loaded with a layout. One drawback is limited flexibility during usage.

Example. Concept of vcLayoutSchemaPropertyList as a database

  Schema Item 0 Schema Item 1 Schema Item 2
Data Record 0 Data field (0,0) Data field (0,1) Data field (0,2)
Data Record 1 Data field (1,0) Data field (1,1) Data field (1,2)
Data Record 2 Data field (2,0) Data field (2,1) Data field (2,2)

Supported Types

The data structure of a vcLayoutSchemaPropertyList object is a list of predefined data types. The overall assumption is that either the data types or their order do not change in a list. This is why only the following data types, of a fixed size, are supported:

  • Boolean
  • Integer
  • Matrix (4*Vector)
  • Real (float)
  • Vector (4*Real)

Schema Properties

A schema item is a supported type of vcProperty and also known as a schema property. In terms of databases, you can view a schema item as a column.

Data Count

The data count of a schema establishes the number of records for the schema, thereby allowing you to add values to data fields. In terms of databases, you can view data count as defining the number of rows.

Properties

Name Type Access Description
DataCount Integer R Gets the number of records in schema.
FrameColorSchemaIndex Integer RW Defines the index of schema property used for coloring frame.

The schema property should be a vector data type.

FrameDataSchemaIndex Integer RW Defines the index of schema property used for positional data of record.

Generally, the schema property is a matrix data type. The positional data is used for visualizing record as a Frame feature in 3D world.

FrameNameColorSchemaIndex Integer RW Defines the index of schema property used for coloring the label of frame.

The schema property should be a vector data type.

FrameNameSchemaIndex Integer RW Defines the index of schema property used for labeling the Frame feature of record in 3D world.

The schema property should be a string data type.

The default is -1. This means the Frame feature of record will not be labeled with its custom name rather the number of record in schema.

FrameNameVisibleSchemaIndex

Integer

RW

Defines the index of schema property used for controlling the visibility of label of record in 3D world.

The schema property should be a Boolean data type.

The default is -1. This means labels are visible.

FrameVisibleSchemaIndex Integer RW Defines the index of schema property used for controlling the visibility of Frame feature of record in 3D world.

The schema property should be a Boolean data type.

This also affects the visibility of label of record in 3D world.

LineDisplaySchemaIndex Integer RW Define the index of schema property used for the position of record in 3D world.   This allows you to connect positions with a line generated in 3D world.
Node vcNode RW Defines a node the Frame features of records are attached to in 3D world.

In some cases, this might be the simulation root node/World node. In other cases, this might be the root node of a workpiece.

PositionMatrix vcMatrix RW Defines an offset for position of record in 3D world.

The offset is based in coordinate system of Node property.

Generally, an offset is applied to compensate for weld torch flares or to adjust position based on Z-axis direction of robot TCP.

SchemaProperties List of vcProperty R Gets a list of all schema properties in the layout item.

Note: This does not include data values for each record in the schema.

Methods

Name Return Type Parameters Description
clearSchema None None Empties the schema, thereby removing all schema properties and setting the data count to zero.
cloneSchemaObject Boolean Integer from_dataindex, Integer count, Integer to_dataindex Clones a set of records in a given range.

The from_dataindex argument defines the first record in range. The count argument defines how many records to clone. The to_dataindex argument defines where to insert the copies.

Warning: Currently, you cannot append cloned records to the end of the table. You must insert the copies before an existing record.

createProperty vcProperty Enumeration type, String name, [Enumeration constraints] Adds a new property of a given type and name to the layout item.

An optional constraints argument can be given to define constraints for the new property, which must be defined at the time of creation.

See Property Constants for more information.

createSchemaProperty vcProperty Enumeration type, String name Adds a new schema property of a given type and name to the layout item.

See Property Constants for more information.

deleteProperty None vcProperty property Deletes a given property of the layout item.
deleteSchemaObject None Integer from_dataindex, Integer count Deletes a set of records in a given range.

The from_dataindex argument defines the first record in range. The count argument defines how many records to delete.

deleteSchemaProperty None vcProperty property Deletes a given property that is a schema property of the layout item.
getDataValue <Type> Integer dataindex, Integer itemindex Returns the value of a data field at a given dataindex and itemindex.
getDataValues n-tuple of <Type> Integer dataindex Returns the values of a record at a given dataindex.
getProperty vcProperty String name Returns a property of the layout item that matches the given name; otherwise returns None.
getSchemaProperty vcProperty String name Returns a schema property of the layout item that matches the given name; otherwise returns None.
setDataValue None Integer dataindex, Integer itemindex, <Type> value Sets the value of a data field at a given dataindex and itemindex.

The value argument must be a supported data type and match the type of the schema property; otherwise the data field will not reference the new value.

Note: The value argument can be a vcProperty object, thereby the value of that property is passed to the data field.

setDataValues None Integer dataindex, Integer itemindex, n-tuple of <Type> values Sets all values for schema properties of a record at a given dataindex.

The values argument must be a tuple with the same amount of elements as there are schema properties. Each element's value must be a supported data type and match the type of the corresponding schema property; otherwise the data field will not reference the new value.

Note: An element of a tuple given as the values argument can be a vcProperty object, thereby the value of that property is passed to the data field.

updateData None Integer count Allocates the size of the schema to support a potential amount of elements/entries for schema properties based on the given count.

Note: The allocation is optional as size is updated automatically based on number of entries.

Examples

Example. Create schema layout item

from vcScript import *
 
app = getApplication()
 
#find schema by name, else create new one
schema = app.findLayoutItem("mySchema")
if not schema:
  schema = app.createLayoutItem(VC_LAYOUTITEM_IT_LAYOUTSCHEMAPROPERTYLIST)
  schema.Name = "mySchema"
  
#print schema

Example. Create schema properties

Generally, a schema layout item contains at least one of the following data fields/column attributes:

  • Position vector to define a location in the containing coordinate system.
  • Position vector and Direction vector to define a location and direction in the containing coordinate system.
  • Frame/matrix that defines the location and full orientation in the containing coordinate system.

In all cases, the containing coordinate system is defined by the Node property of the schema layout item. In some cases, a schema may contain any number of additional schema properties, thereby allowing you to store all data needed to execute and manipulate tool paths.

A simple implementation of a schema layout item is to first remove all of its data, add six different schema properties, and then define how to visualize data stored in the schema.

from vcScript import *
 
app = getApplication()
schema = app.findLayoutItem("mySchema")
if not schema:
  schema = app.createLayoutItem(VC_LAYOUTITEM_IT_LAYOUTSCHEMAPROPERTYLIST)
  schema.Name = "mySchema"
  
schema.clearSchema()
schema.createSchemaProperty(VC_MATRIX, "Frame")
schema.createSchemaProperty(VC_VECTOR, "Direction")
schema.createSchemaProperty(VC_REAL, "Speed")
schema.createSchemaProperty(VC_INTEGER, "Mode")
schema.createSchemaProperty(VC_BOOLEAN, "FrameVisible")
 
schema.LineDisplaySchemaIndex = 0
schema.FrameDataSchemaIndex = 0
schema.FrameVisibleSchemaIndex = 4
 
schema.update()

Example. Allocate and add data to schema

In order to add data, you must first know the amount of data you want to store in the schema. That is, the number of records or rows to use in the schema.

from vcScript import *
import vcMatrix
import vcVector
 
app = getApplication()
schema = app.findLayoutItem("mySchema")
if not schema:
  schema = app.createLayoutItem(VC_LAYOUTITEM_IT_LAYOUTSCHEMAPROPERTYLIST)
  schema.Name = "mySchema"
  
schema.clearSchema()
schema.createSchemaProperty(VC_MATRIX, "Frame")
schema.createSchemaProperty(VC_VECTOR, "Direction")
schema.createSchemaProperty(VC_REAL, "Speed")
schema.createSchemaProperty(VC_INTEGER, "Mode")
schema.createSchemaProperty(VC_BOOLEAN, "FrameVisible")
schema.LineDisplaySchemaIndex = 0
schema.FrameDataSchemaIndex = 0
schema.FrameVisibleSchemaIndex = 4
 
#the following creates 5 rows
#each row contains data for 5 schema items/properties
count = 5
schema.updateData(count)
m = vcMatrix.new()
v = vcVector.new()
r = 1.2345
k = 1000000
b = False
for i in range(count):
  schema.setDataValue(i,0,m)
  schema.setDataValue(i,1,v)
  schema.setDataValue(i,2,r)
  schema.setDataValue(i,3,k + i)
  schema.setDataValue(i,4,b)
 
 
schema.update()

Data entry can be processed faster by adding multiple values at a time.

for i in range(count):
  schema.setDataValue(i,0,(m,v,r,k+i,b))

Example. Traverse data in schema

count = 5
schema.updateData(count)
m = vcMatrix.new()
v = vcVector.new()
r = 1.2345
k = 1000000
b = False
for i in range(count):
  schema.setDataValue(i,0,(m,v,r,k+i,b))
 
schema.update()
  
#getting values is similar to setting values
for i in range(count):
  m = schema.getDataValue(i,0)
  v = schema.getDataValue(i,1)
  r = schema.getDataValue(i,2)
  k = schema.getDataValue(i,3)
  b = schema.getDataValue(i,4)
  
for i in range(count):
  m,v,r,k,b = schema.getDataValues(i)
  print m,v,r,k,b

Example. Attach schema to node

Generally, a tool path is associated with a node. If this case is not true, you can locate and set the schema's node and apply an offset for data relative to that node's coordinate system.

#attach schema to World node and apply offset
comp = getComponent()  
schema.Node = comp.World
m = vcMatrix.new()
m.translateRel(0,0,100)
schema.PositionMatrix = m

Example. Pick schema data

The simTopologyPick command defined in vcTopologyPickCommand supports the picking of schema data. Once you pick or hover over the top of schema data visualized in the 3D world, the TargetPointIndex property of the command is set in the vcTopologyPickCommand object.

Example. Delete schema

getApplication().deleteLayoutItem(mySchema)

Example. Delete and clone records

from vcScript import *
import vcMatrix
import vcVector
  
app = getApplication()
schema = app.findLayoutItem("mySchema")
if not schema:
  schema = app.createLayoutItem(VC_LAYOUTITEM_IT_LAYOUTSCHEMAPROPERTYLIST)
  schema.Name = "mySchema"
   
schema.clearSchema()
schema.createSchemaProperty(VC_MATRIX, "Frame")
schema.createSchemaProperty(VC_VECTOR, "Direction")
schema.createSchemaProperty(VC_REAL, "Speed")
schema.createSchemaProperty(VC_INTEGER, "Mode")
schema.createSchemaProperty(VC_BOOLEAN, "FrameVisible")
schema.LineDisplaySchemaIndex = 0
schema.FrameDataSchemaIndex = 0
schema.FrameVisibleSchemaIndex = 4
  
#the following creates 5 rows
#each row contains data for 5 schema items/properties
count = 5
schema.updateData(count)
m = vcMatrix.new()
v = vcVector.new()
r = 1.2345
k = 1000000
b = False
 
for i in range(count):
  schema.setDataValue(i,0,m)
  schema.setDataValue(i,1,v)
  schema.setDataValue(i,2,r)
  schema.setDataValue(i,3,k + i)
  if i == 4:
    ##sets the last value of last record to True
    schema.setDataValue(i,4,True)
  else:
    ##all other records will have a last value of False
    schema.setDataValue(i,4,b)
 
##delete the first record
schema.deleteSchemaObject(0,1)
 
##copy first two records and insert them before last record
schema.cloneSchemaObject(0,2,schema.DataCount-1)
 
##copy last record and insert it before first record
schema.cloneSchemaObject(schema.DataCount-1,1,0)
 
schema.update()
 
for i in range(schema.DataCount):
  print schema.getDataValues(i)
  
'''
prints the following
(<vcMatrix object at 0x000002AE80B1ADF8>, <vcVector object at 0x000002AE80BC1AE8>, 1.2345, 1000004, True)
(<vcMatrix object at 0x000002AE80B1ADF8>, <vcVector object at 0x000002AE80BC1AE8>, 1.2345, 1000001, False)
(<vcMatrix object at 0x000002AE80B1ADF8>, <vcVector object at 0x000002AE80BC1AE8>, 1.2345, 1000002, False)
(<vcMatrix object at 0x000002AE80B1ADF8>, <vcVector object at 0x000002AE80BC1AE8>, 1.2345, 1000003, False)
(<vcMatrix object at 0x000002AE80B1ADF8>, <vcVector object at 0x000002AE80BC1AE8>, 1.2345, 1000001, False)
(<vcMatrix object at 0x000002AE80B1ADF8>, <vcVector object at 0x000002AE80BC1AE8>, 1.2345, 1000002, False)
(<vcMatrix object at 0x000002AE80B1ADF8>, <vcVector object at 0x000002AE80BC1AE8>, 1.2345, 1000004, True)
'''