PostWmOnFrameChanged
The callback
PostWmOnFrameChanged(
) is called from the kernel when the tool or base frame was been changed at the operation level.
It can be used to:
-
get attribute values
-
set attribute values
-
output to the log
-
access OlpController
-
access SCV parser
-
get the full path to the technology table file
-
get newly changed frame name, index, type, matrix and world matrix
The callback may return a Boolean value. There is no need to return False, because the default value is False anyway:
-
True: if it is necessary to perform an operation recompute (ENTERSTATE_STARTWITHRULEEVENTS) after the callback ends
-
False: no recompute
The callback is defined in the
%WORKMETHOD_NAME%.py
file that is located in the scripts folder of the
.
def PostWmOnFrameChanged(Operator):
attribGetter = Operator.GetAttribGetter()
attribSetter = Operator.GetAttribSetter()
olpController = Operator.GetController()
toolIndex = olpController.GetActiveToolFrameIndex()
baseIndex = olpController.GetActiveBaseFrameIndex()
csvParser = Operator.GetCsvParserOperator()
iRet = csvParser.LoadCsvFile(" ..\\TechTabs\\WeldingAttrib.csv")
filePath = Operator.GetTechTabFolder("WeldingAttrib.csv")
logging.LogInfo("TechTab path: " + str(filePath))
changedFrameName = Operator.GetChangedFrameName()
logging.LogInfo("Newly changed frame name: " + str(changedFrameName))
changedFrameIndex = Operator.GetChangedFrameIndex()
logging.LogInfo("Newly changed frame index: " + str(changedFrameIndex))
changedFrameType = Operator.GetChangedFrameType()
if changedFrameType == FRAMETYPE_BASE:
logging.LogInfo("Newly changed frame type: Base")
if changedFrameType == FRAMETYPE_TOOL:
logging.LogInfo("Newly changed frame type: Tool")
matrix = Operator.GetChangedFrameMatrix()
if matrix.IsValid():
logging.LogInfo("Matrix position: " + str(matrix.GetPosition().GetXYZ()))
logging.LogInfo("Matrix rotation: " + str(matrix.GetRotation()))
else:
logging.LogInfo("Matrix is not valid!")
worldMatrix = Operator.GetChangedFrameWorldMatrix()
if worldMatrix.IsValid():
logging.LogInfo("World matrix position: " + str(worldMatrix.GetPosition().GetXYZ()))
logging.LogInfo("World matrix rotation: " + str(worldMatrix.GetRotation()))
else:
logging.LogInfo("World matrix is not valid!")
# Set to True when a recompute is required
requestStartWithRuleEventsRecompute = True
return requestStartWithRuleEventsRecomputeWas this page helpful?