- This topic has 1 reply, 2 voices, and was last updated 4 years ago by
Leonardo Bernardini.
-
Posted in: Python template system
-
13th September 2021 at 5:06 pm #34426
Hi!
How can I access the information entered by the user in the string field from the “onFieldChanged” function. Below is a part of my template in which I am trying to do this. Obviously I’m doing it wrong (look at the commented lines) because the “onFieldChanged” function doesn’t know anything about the “job”. How else can I implement “attributeGetString” in a situation like this?class MyTemplate(MTemplateAPI.MTemplate):
def __init__(self):
…..
exrFile = MTemplateAPI.MTemplateItemFile(“EXRFILENAME”,”Sequence”,”Specifies one of sequence .exr file”,””,0,1,1,”*.exr”)
NImagicword = MTemplateAPI.MTemplateItemString(“NIMAGICWORD”,”Variance tag”,”Detect variance channels by this suffix”,”variance”,1,1,1)
NIbeautyname = MTemplateAPI.MTemplateItemString(“NIBEAUTYNAME”,”Beauty pass”,”Beauty pass name”,”RGBA”,1,1,1)
NIaov = MTemplateAPI.MTemplateItemString(“NIAOV”,”AOVs”,”Denoise this AOVs (empty field for RGBA only)”,”specular diffuse sss”,0,1,0)
…..
self.addSubmissionItem(exrFile)
self.addSubmissionItem(NImagicword)
self.addSubmissionItem(NIbeautyname)
self.addSubmissionItem(NIaov)def onFieldChanged(self, fieldName, fieldValue, fieldsToChange):
if fieldName == “EXRFILENAME”:
“””
magicWord = job.attributeGetString(“NIMAGICWORD”)
beautyName = job.attributeGetString(“NIBEAUTYNAME”)
exrChans = parseExrHeader(fieldValue, ‘magicWord’, ‘beautyName’)
“””
exrChans = parseExrHeader(fieldValue, ‘variance’, ‘RGBA’) # explicit “magicWord” and “beautyName”
toDenoise = ‘ ‘.join(exrChans[1])
fieldsToChange.addEvent(“EXRFILENAME”,MClientAPI.GetSequenceMask(fieldValue),MTemplateAPI.MTemplateItemEvent.kTemplateItemFieldsActivationNone)
fieldsToChange.addEvent(“NIAOV”,toDenoise,MTemplateAPI.MTemplateItemEvent.kTemplateItemFieldsActivationNone)13th September 2021 at 8:23 pm #34427well, indeed there’s no concept of the job inside the submission view, that’s why just a string is passed.
Considering that you’re doing lot of interesting stuff like parsing the EXR files and compose the job in a certain way, it would be extremely easier for you to implement a custom submitter inside Console so you can roll your own interface/checks using PySide -
You must be logged in to reply to this topic.