Skip to Content

PostCompute

The callback

PostCompute

(

CENPyOlpEvent_EventComputeOperator

) is called when the kernel computes the events.  

The callback is defined in the

%EVENT_NAME%.py

file that is located in the scripts folder of the

plugin

.

def PostCompute(eco): logOperator = eco.GetLoggerOperator() attribGetter = eco.GetAttribGetter() controller = eco.GetController() actors = controller.GetActors(FSITEMTYPE_PRODUCTION, ITEM_MACHINE_ROBOT, FSACTOR_NONE) actorsCount = len(actors) for i in range(0, actorsCount): actor = actors[i] actorName = actor.GetName() actorResourceName = actor.GetResourceName() logOperator.LogDebug('actor[' + str(i) +'] actorName = '+ actorName + '; actorResourceName = ' + actorResourceName) logOperator.LogDebug('actor[' + str(i) +'] ItemType(): = '+ str(actor.AskItemType()) + '; ItemSubType = ' + str(actor.AskItemSubType())) sensors = controller.GetSensors(0, 0, 0) sensorsCount = len(sensors) for i in range(0, sensorsCount): sensor = sensors[i] sensorName = sensor.GetName() sensorResourceName = sensor.GetResourceName() logOperator.LogDebug('sensor[' + str(i) +'] sensorName = '+ sensorName + '; sensorResourceName = ' + sensorResourceName) tp10Matrix = eco.GetInitialPathMatrixByLength(10) myTpElement = eco.GetRefTpElement() eventOperator = eco.GetEventOperator() se = eventOperator.AddSpeed(myTpElement, TPINSERTPOS_INSERTBEFORE) se.SetSpeed(1.5) eco.SkipPath(0.1, False) refTpElement = eco.GetRefTpElement() obj = eventOperator.AddEvent("69B94E6B-03D7-48FF-A62A-BE9CE3C142C8", refTpElement, TPINSERTPOS_INSERTAFTER) index = obj.GetEnumIndex("EEnumAttribute") obj.SetEnumIndex("EEnumAttribute", 1) eventOperator.AddActorEvent(myTpElement, actors[0], TPINSERTPOS_INSERTAFTER) tpMat = tp10Matrix tpMatPos = eco.GetRefToolpathElementPosition() pos = tpMat.GetPosition() posP = tpMatPos.GetPosition() logOperator.LogInfo('pos1 = tpMat.GetPosition() = ' + str(pos.GetXYZ())) logOperator.LogInfo('pos2 = tpMatPos.GetPosition() = ' + str(posP.GetXYZ())) matDest = eco.CreateMatrix() matVia = eco.CreateMatrix() matDest.Translate(pos.GetX(), pos.GetY(), pos.GetZ() + 0.02, True) matVia.Translate(pos.GetX(), pos.GetY() + 0.01, pos.GetZ() + 0.01, True) pos = matDest.GetPosition() eco.MoveCir(matDest, matVia)
Was this page helpful?