Python scripting - Workmethod callbacks

PostProcessOperationAttributes

Previous  Chapter  Next

 

The callback PostProcessOperationAttributes(CENPyOlpWM_POAttribOperator) is called before an operation path computation.

 

It can be used to:

- get operation attribute values

- set operation attribute values

- access csv files

- output to the log

 

The callback is defined in the %WORKMETHOD_NAME%.py file that is located in the scripts folder of the plugin.

 

PostProcessOperationAttributes

 

[Example]

 

def PostProcessOperationAttributes(poa):

# parser

   csvParser = poa.GetCsvParserOperator()

 

   # Get the path to the TechTabs folder and CSV file:

   # Do not forget to add "import inspect, os" at the top of the file

   # currentPythonFilePath = os.path.abspath(inspect.getfile(inspect.currentframe()))

   # scriptsDirectoryPath = os.path.dirname(currentPythonFilePath)

   # parentDirectoryPath = os.path.dirname(scriptsDirectoryPath)

   # csvFilePath = str(parentDirectoryPath + "\\TechTabs\\Test.csv")

   # or simply:

   csvFilePath = str(os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))) + "\\TechTabs\\Test.csv")

 

   iRet = csvParser.LoadCsvFile(csvFilePath)

   if iRet == 0:

      logging.LogInfo("Successfully imported CSV file: " + str(csvFilePath))

      csvParser.SetSeparator(",")

      numberOfRows = csvParser.GetNumberOfRows()

      numberOfColumns = csvParser.GetNumberOfColumns()

      cell12 = csvParser.GetCell(1, 2)   

      cell12 = csvParser.GetCellByColumnName('B', 2)

      row1 = csvParser.GetRow(1)

      row2 = csvParser.GetRow(2)

 

   geometryOperator = poa.GetGeometryOperator()   

   vector0 = geometryOperator.CreateVector(0, 1, 1)

   vector1 = geometryOperator.CreateVector(0, 0, 1)

   vectorN = geometryOperator.CreateVector(0, 0, 1)

   angle = GetIncludedAngle = geometryOperator.GetIncludedAngle(vector0, vector1, vectorN, 0)

   rad = geometryOperator.ToRadian(180)

   deg180 = geometryOperator.ToDegrees(rad)

 

   controller = poa.GetController();

   toolIndex = controller.GetActiveToolframeIndex()

   controllerName = controller.GetName()

   logOperator.LogDebug("controllerName: " + controllerName)

   logOperator.LogDebug("toolIndex: " +  str(toolIndex))

   pass

 


PostProcessOperationAttributes_Ex

 


Previous
Previous page
Chapter
Chapter page
Next
Next page