General functions
init
def __init__(self):afterInit
This event will be called whenever the extension is added to the project and when exist while the project is loading. UI-Parameter, Events and Actions should be defined here as well as everything which is needed to be initialized for the extension object.
def afterInit(self):onParameterFeedback
This function will be called on any parameter feedback/change
def onParameterFeedback(self, parameter):
if parameter == self.someParameter:
print(self.someParameter.value)onDisabling
This function will be called whenever the object is set to disabled
def onDisabling(self):onEnabling
This function will be called whenever the object is set to disabled
def onEnabling(self):shutdown/remove
This function will be called whenever the project will be closed as well as when the object will be removed from the project.
def shutdown(self):Timer
self.addTimer("name", 1.0, self.onTimer)
self.removeTimer("name")Set parameter as read only
someParameter = self.moduleContainer.addFloatParameter("Example", 0, 0, 100)
someParameter.setParam("readonly", True)Set suffix for parameter
Add a suffix to a parameter. Supports float, int, point and vector.
someParameter = self.moduleContainer.addFloatParameter("Example", 0, 0, 100)
someParameter.setParam("suffix", "cm")Status Arrow
self.showStatusArrow(True, True) #Input, Output
self.pushStatusInput()
self.pushStatusOutput()Status
self.setStatus(sp.StatusType.Undefined)
self.setStatus(sp.StatusType.Undefined, "optionalCustomName")
self.setStatus(sp.StatusType.Active, "optionalCustomName")
self.setStatus(sp.StatusType.Connected, "optionalCustomName")
self.setStatus(sp.StatusType.Disconnect, "optionalCustomName")
self.setStatus(sp.StatusType.DeviceError, "optionalCustomName")
self.setStatus(sp.StatusType.ConnectionError, "optionalCustomName")
self.setStatus(sp.StatusType.InvalidSettings, "optionalCustomName")
self.setStatus(sp.StatusType.Standby, "optionalCustomName")
self.setStatus(sp.StatusType.Disabled, "optionalCustomName")
self.setStatus(sp.StatusType.TrackedState_Live, "optionalCustomName")
self.setStatus(sp.StatusType.TrackedState_False, "optionalCustomName")
self.setStatus(sp.StatusType.TrackedState_Timeline, "optionalCustomName")
self.setStatus(sp.StatusType.Connecting, "optionalCustomName")Logging
self.log("normal logs")
self.logWarning("Warning logs")
self.logError("Error logs")Validate IP parameter
.isValidIP()
self.myIPparameter.isValidIP() #Return True or FalseAdding workflow
It is possible to also ship with your extension a default workflow.
This means when the extension object is added to Grid Studio, the workflow is automatically added with the object and all the functions that are built inside the workflow can be loaded automatically.
Once you have a workflow file, you need to add one line of code inside the afterInit() function
self.cc.general.workflow.importFromFile(os.path.join(os.path.dirname(os.path.abspath(__file__)),"workflow.spasset"))
#workflow.spasset being the default workflow file that you like to load when user adds your extensionLast updated