Python scripting OLP - Objects

CENPyOlpTeachHandler

 

Methods

 

GetTpElementPosition(tpElement: CENPyOlpTpElement, posRelation: PosRelation): CENPyOlpPosition

 

o

tpElement

Toolpath element object

 

o

posRelation

Type of the position relation represented as enum PosRelation

 

o

return

Object of the CENPyOlpPosition class

 

Get position of the toolpath element.

 

[Example]

   program = Operator.GetActiveProgram()

   tpes = program.GetTpElements()

   teachHandler = Operator.GetTeachHandler()

   olpPosition = teachHandler.GetTpElementPosition(tpes[0], POSRELATION_LOCALTPELEMENT)

 


 

GetTpElementPosition(tpElement: CENPyOlpTpElement, posRelation: PosRelation, baseFrameIndex: int): CENPyOlpPosition

 

o

tpElement

Toolpath element object

 

o

posRelation

Type of the position relation represented as enum PosRelation

 

o

baseFrameIndex

Index of the base frame to be used for position representation. The default value is the index of an active base frame

 

o

return

Object of the CENPyOlpPosition class

 

Get position of the toolpath element.

 

[Example]

   program = Operator.GetActiveProgram()

   tpes = program.GetTpElements()

   teachHandler = Operator.GetTeachHandler()

   olpPosition = teachHandler.GetTpElementPosition(tpes[0], POSRELATION_BASEFRAME) #Index of an active base frame used

or

   olpPosition = teachHandler.GetTpElementPosition(tpes[0], POSRELATION_BASEFRAME, 1)

 


 

ModifyTpElement(olpPosition: CENPyOlpPosition): bool

 

o

olpPosition

Olp position to take current values from and that holds the reference toolpath element

 

o

return

True if modification was successful, False otherwise

 

Apply the current position values to the reference toolpath element. Only an active program is allowed to be modified.

 

[Example]

   olpPosition = teachHandler.GetTpElementPosition(tpElement, POSRELATION_LOCALTPELEMENT)

   olpPosition.TranslatePosition(0, 0, 0.05, POSRELATION_WORKPIECEROOT)

   successful = teachHandler.ModifyTpElement(olpPosition)

   if not successful:

      logging.LogError("Failed to modify TPE!")

 


 

·

InsertNewTpElement(olpPosition: CENPyOlpPosition, motionType: MotionType, insertPos: TPInsertPosition): CENPyOlpTpElement

 

o

olpPosition

Olp position to take current values from and that holds the reference toolpath element

 

o

motionType

Motion type of the toolpath element to be created

 

o

insertPos

IInsert position in relation to the reference toolpath element

 

o

return

Newly created object of the CENPyOlpTpElement class. None, if failed to insert the new toolpath element

 

Insert a new toolpath element. Currently, only PTP and LIN motion types can be inserted and only an active program is allowed to be modified.

An active toolpath elements should have target type of TARGETTYPE_CARTESIAN, otherwise the insertion will fail.

 

[Example]

   olpPosition = teachHandler.GetTpElementPosition(tpElement, POSRELATION_LOCALTPELEMENT)

   olpPosition.TranslatePosition(0, 0, 0.01, POSRELATION_LOCALTPELEMENT)

   newTpe = teachHandler.InsertNewTpElement(olpPosition, MOTIONTYPE_PTP, TPINSERTPOS_INSERTBEFORE)

   if not newTpe:

      logging.LogError("Failed to insert new TPE!")

 


 

RemoveTpElement(tpElement: CENPyOlpTpElement)

 

o

tpElement

Toolpath element to remove

 

Remove the given toolpath element. Currently, only an active program is allowed to be modified.

Toolpath elements with the process type ProcessInsert, Auxiliary and TeachInsert will be deleted, and all other types will be suppressed.

 

[Example]

   teachHandler = Operator.GetTeachHandler()

  program = Operator.GetActiveProgram()

  tpElements = program.GetTpElements()

  for tpe in tpElements:

     teachHandler.RemoveTpElement(tpe)

 


 

SetTpElementName(tpElement: CENPyOlpTpElement, newName: string)

 

o

tpElement

Toolpath element object

 

o

newName

New name to set

 

Set the name of the toolpath element. The Teach Flag for Name will be set.

 

[Example]

  teachHandler = Operator.GetTeachHandler()

  program = Operator.GetActiveProgram()

  tpElements = program.GetTpElements()

  for counter, tpe in enumerate(tpElements, 1):

     if counter == 3:

        teachHandler.SetTpElementName(tpe, "NewName")

 


   

SetTpElementMotionType(tpElement: CENPyOlpTpElement, motionType: MotionType)

 

o

tpElement

Toolpath element object

 

o

motionType

New motion type to set

 

Set the new motion type of the toolpath element. The Teach Flag for MotionType will be set. If the motion type cannot be set because of restrictions, the element will be skipped.

 

[Example]

  teachHandler = Operator.GetTeachHandler()

  program = Operator.GetActiveProgram()

  tpElements = program.GetTpElements()

  for counter, tpe in enumerate(tpElements, 1):

     if counter == 3:

        teachHandler.SetTpElementMotionType(tpe, MOTIONTYPE_LIN)

 


   

SetTpElementTargetType(tpElement: CENPyOlpTpElement, targetType: TargetType)

 

o

tpElement

Toolpath element object

 

o

targetType

New target type to set

 

Sets the new target type of the underlying toolpath element. The Teach Flag for TargetType will be set.

 

[Example]

  teachHandler = Operator.GetTeachHandler()

  program = Operator.GetActiveProgram()

  tpElements = program.GetTpElements()

  for counter, tpe in enumerate(tpElements, 1):

     if counter == 3:

        teachHandler.SetTpElementTargetType(tpe, TARGETTYPE_CARTESIAN)

 


   

SetTpElementConfigBehavior(tpElement: CENPyOlpTpElement, configBehavior: ConfigBehavior)

 

o

tpElement

Toolpath element object

 

o

configBehavior

New config behavior to set

 

Sets the config behavior for the given toolpath elements. The Teach Flag for Config will be set.

 

[Example]

  teachHandler = Operator.GetTeachHandler()

  program = Operator.GetActiveProgram()

  tpElements = program.GetTpElements()

  for counter, tpe in enumerate(tpElements, 1):

     if counter == 3:

        teachHandler.SetTpElementConfigBehavior(tpe, CONFIGBEHAVIOR_INHERIT)

 


   

SetTpElementTurnBehavior(tpElement: CENPyOlpTpElement, turnBehavior: TurnBehavior)

 

o

tpElement

Toolpath element object

 

o

turnBehavior

New turn behavior to set

 

Sets the turn behavior for the given toolpath elements. The Teach Flag for Turn will be set.

 

[Example]

  teachHandler = Operator.GetTeachHandler()

  program = Operator.GetActiveProgram()

  tpElements = program.GetTpElements()

  for counter, tpe in enumerate(tpElements, 1):

     if counter == 3:

        teachHandler.SetTpElementTurnBehavior(tpe, TURNBEHAVIOR_INHERIT)

 


 

RemoveTeachFlags(tpElement: CENPyOlpTpElement): bool

 

o

tpElements

Reference toolpath element

 

o

return

True if removal was successful, False otherwise

 

Removes all teach flags and resets the toolpath element properties to their initial values.

 

[Example]

  teachFlags = tpElement.GetTeachFlags()

  if teachFlags & TEACHFLAGS_TURNBEHAVIOUR and teachFlags & TEACHFLAGS_CONFIGBEHAVIOR:

     successful = teachHandler.RemoveTeachFlags(tpElement)

     if successful:

        logging.LogInfo(f"All teach flags were removed successfully.")

 


 

RemoveTeachFlags(tpElement: CENPyOlpTpElement, teachFlags: TeachFlags): bool

 

o

tpElement

Reference toolpath element

 

o

teachFlags

Bitmask of TeachFlags

 

o

return

True if removal was successful, False otherwise

 

Removes the specified teach flags and resets their properties to the initial values.

 

[Example 1]

  teachFlags = tpElement.GetTeachFlags()

  if teachFlags & TEACHFLAGS_NAME:

     successful = teachHandler.RemoveTeachFlags(tpElement, TEACHFLAGS_NAME)

     if successful:

        logging.LogInfo(f"Name teach flag was removed successfully.")

 

[Example 2]

  teachFlags = tpElement.GetTeachFlags()

  if teachFlags & TEACHFLAGS_TARGETTYPE and teachFlags & TEACHFLAGS_MOTIONTYPE:

     teachHandler.RemoveTeachFlags(tpElement, TEACHFLAGS_TARGETTYPE | TEACHFLAGS_MOTIONTYPE | TEACHFLAGS_CONFIGBEHAVIOR | TEACHFLAGS_TURNBEHAVIOUR | TEACHFLAGS_JOINTS | TEACHFLAGS_EXTERNALJOINTS)

 


 

 

 


Previous
Page précédente
Chapter
Page principale du chapitre
Next
Page suivante