def accept(self): """Accept the operation.""" aov_data = { "variable": self.variable_name.text(), "vextype": self.type_box.itemData(self.type_box.currentIndex()) } channel_name = self.channel_name.text() if channel_name: aov_data["channel"] = channel_name quantize = self.quantize_box.itemData(self.quantize_box.currentIndex()) if not utils.isValueDefault(quantize, "quantize"): aov_data["quantize"] = quantize sfilter = self.sfilter_box.itemData(self.sfilter_box.currentIndex()) if not utils.isValueDefault(sfilter, "sfilter"): aov_data["sfilter"] = sfilter pfilter = self.pfilter_widget.value() if not utils.isValueDefault(pfilter, "pfilter"): aov_data["pfilter"] = pfilter if self.componentexport.isChecked(): aov_data["componentexport"] = True aov_data["components"] = self.components.text().split() lightexport = self.lightexport.itemData(self.lightexport.currentIndex()) if lightexport: aov_data["lightexport"] = lightexport if lightexport != "per-category": aov_data["lightexport_scope"] = self.light_mask.text() aov_data["lightexport_select"] = self.light_select.text() comment = self.comment.text() if comment: aov_data["comment"] = comment new_aov = AOV(aov_data) self.new_aov = new_aov new_aov.path = os.path.expandvars(self.file_widget.getPath()) writer = manager.AOVFileWriter() writer.addAOV(new_aov) writer.writeToFile( os.path.expandvars(self.file_widget.getPath()) ) self.newAOVSignal.emit(new_aov) return super(AOVDialog, self).accept()
def _createAOVs(self, definitions): """Create AOVs based on definitions.""" for definition in definitions: # Insert this file path into the data. definition["path"] = self.path # Construct a new AOV and add it to our list. aov = AOV(definition) self.aovs.append(aov)
def _create_aovs(self, definitions): """Create AOVs based on definitions. :param definitions: AOV definition data. :type definitions: list(dict) :return: """ for definition in definitions: # Insert this file path into the data. definition["path"] = self.path # Construct a new AOV and add it to our list. aov = AOV(definition) self.aovs.append(aov)
def accept(self): """Accept the operation.""" aov_data = {} aov_data["variable"] = self.variable_name.text() aov_data["vextype"] = self.type_box.itemData(self.type_box.currentIndex()) self.buildAOVDataFromUI(aov_data) aov = AOV(aov_data) # Open file for writing. aov_file = manager.AOVFile(aov.path) # if aov_file.exists: # if aov_file.containsAOV(new_aov): # existing_aov = aov_file.aovs[aov_file.aovs.index(new_aov)] # choice = hou.ui.displayMessage( # "{} already exists in file, overwrite?".format(new_aov.variable), # buttons=("Cancel", "OK"), # severity=hou.severityType.Warning, # details=str(existing_aov.getData()), # details_expanded=True, # ) # # if choice == 0: # return # aov_file.replaceAOV(new_aov) # else: # aov_file.addAOV(new_aov) # else: # aov_file.addAOV(new_aov) aov_file.addAOV(aov) aov_file.writeToFile() self.newAOVSignal.emit(aov) return super(NewAOVDialog, self).accept()
def buildAOVsFromMultiparm(node): """Build a list of AOVs from a Mantra node's multiparm.""" aovs = [] num_aovs = node.evalParm("vm_numaux") for idx in range(1, num_aovs + 1): aov_data = { "variable": node.evalParm("vm_variable_plane{}".format(idx)), "vextype": node.evalParm("vm_vextype_plane{}".format(idx)) } channel = node.evalParm("vm_channel_plane{}".format(idx)) if channel: aov_data["channel"] = channel aov_data["quantize"] = node.evalParm("vm_quantize_plane{}".format(idx)) aov_data["sfilter"] = node.evalParm("vm_sfilter_plane{}".format(idx)) pfilter = node.evalParm("vm_pfilter_plane{}".format(idx)) if pfilter: aov_data["pfilter"] = node.evalParm( "vm_pfilter_plane{}".format(idx)) aov_data["componentexport"] = node.evalParm( "vm_componentexport{}".format(idx)) lightexport = node.evalParm("vm_lightexport{}".format(idx)) lightexport = uidata.LIGHTEXPORT_MENU_ITEMS[lightexport][0] if lightexport: aov_data["lightexport"] = lightexport aov_data["lightexport_scope"] = node.evalParm( "vm_lightexport_scope{}".format(idx)) aov_data["lighexport_select"] = node.evalParm( "vm_lightexport_select{}".format(idx)) aovs.append(AOV(aov_data)) return aovs