def bakeSound(self): if self.filePath == "": return forbidCompiling() scene = bpy.context.scene oldFrame = scene.frame_current scene.frame_current = 1 soundObject = self.getSoundObject() self.removeSoundCurves(soundObject) soundCombinations = [(0, 50), (50, 150), (150, 300), (300, 500), (500, 1000), (1000, 2000), (2000, 4000), (4000, 10000), (10000, 20000)] wm = bpy.context.window_manager wm.progress_begin(0.0, len(soundCombinations) - 1.0) wm.progress_update(0.0) for index, (low, high) in enumerate(soundCombinations): self.bakeIndividualSound(soundObject, self.filePath, low, high) wm.progress_update(index + 1.0) wm.progress_end() soundObject.hide = True self.name = re.sub(r"\W+", "", os.path.basename(self.filePath)) loadSound(self.filePath) if self.setSyncMode: scene.sync_mode = "AUDIO_SYNC" scene.frame_current = oldFrame allowCompiling() nodeTreeChanged()
def addProperty(self, propertyName): """This function called to add a shape key socket as input/output or both according to propertyIOType attribute of the node. Note: The new node socket has enabled attribute False, so execution string load it's proper value and enable it. Args: propertyName (str): The name of the property. """ forbidCompiling() # if propertyIOType is INPUT or BOTH add new input socket to the node if self.propertyIOType != 'OUTPUT': try: # Search for existing socket with the same name so no duplicates exists socket = self.inputs[propertyName] except KeyError: socket = self.inputs.new("mn_FloatSocket", propertyName) socket.removeable = True socket.callNodeToRemove = True socket.enabled = False # if propertyIOType is OUTPUT or BOTH add new output socket to the node if self.propertyIOType != 'INPUT': try: # Search for existing socket with the same name so no duplicates exists socket = self.outputs[propertyName] except KeyError: socket = self.outputs.new("mn_FloatSocket", propertyName) socket.removeable = True socket.callNodeToRemove = True allowCompiling() nodeTreeChanged()
def newInputSocket(self): forbidCompiling() newSocketName = str(len(self.inputs)) + "." newSocket = self.inputs.new("mn_StringSocket", newSocketName) self.inputs.move(len(self.inputs) - 1, len(self.inputs) - 2) allowCompiling() nodeTreeChanged()
def updateNode(node, context): singleInputOperations = ["SINE", "COSINE", "TANGENT", "ARCSINE", "ARCCOSINE", "ARCTANGENT", "ABSOLUTE", "FLOOR", "CEILING"] if node.mathTypesProperty in singleInputOperations and not node.inputs[-1].hide: node.inputs[-1].hide = True elif node.mathTypesProperty not in singleInputOperations and node.inputs[-1].hide: node.inputs[-1].hide = False nodeTreeChanged()
def addProperty(self, propertyName): """This function called to add a modifier property socket as input/output or both according to propertyIOType attribute of the node. Note: The new node socket has enabled attribute False, so execution string load it's proper value and enable it. Needs modifierSubClass attribute of node to determine the type of the socket. Args: propertyName (str): The name of the property. """ socketType = getSocketTypeByDataPath("bpy.types." + self.modifierSubClass + ".bl_rna.properties['" + propertyName + "']") # print("Socket: ", socketType) forbidCompiling() # if propertyIOType is INPUT or BOTH add new input socket to the node if self.propertyIOType != 'OUTPUT' and socketType is not None: try: # Search for existing socket with the same name so no duplicates exists socket = self.inputs[propertyName] except KeyError: socket = self.inputs.new(socketType, propertyName) socket.removeable = True socket.callNodeToRemove = True socket.enabled = False #TODO: replace '_' from name with ' ' # if propertyIOType is OUTPUT or BOTH add new output socket to the node if self.propertyIOType != 'INPUT' and socketType is not None: try: # Search for existing socket with the same name so no duplicates exists socket = self.outputs[propertyName] except KeyError: socket = self.outputs.new(socketType, propertyName) socket.removeable = True socket.callNodeToRemove = True allowCompiling() nodeTreeChanged()
def updateNode(node, context): singleInputOperations = [ "SINE", "COSINE", "TANGENT", "ARCSINE", "ARCCOSINE", "ARCTANGENT", "ABSOLUTE", "FLOOR", "CEILING" ] if node.mathTypesProperty in singleInputOperations and not node.inputs[ -1].hide: node.inputs[-1].hide = True elif node.mathTypesProperty not in singleInputOperations and node.inputs[ -1].hide: node.inputs[-1].hide = False nodeTreeChanged()
def customNameChanged(self, context): if not self.customNameIsUpdating: self.customNameIsUpdating = True if self.customNameIsVariable: self.customName = makeVariableName(self.customName) if self.uniqueCustomName: customName = self.customName self.customName = "temporary name to avoid some errors" self.customName = getNotUsedCustomName(self.node, prefix=customName) if self.callNodeWhenCustomNameChanged: self.node.customSocketNameChanged(self) self.customNameIsUpdating = False nodeTreeChanged()
def customNameChanged(self, context): if not self.customNameIsUpdating: self.customNameIsUpdating = True if self.customNameIsVariable: newCustomName = "" for char in self.customName: if char.isalpha(): newCustomName += char self.customName = newCustomName if self.uniqueCustomName: customName = self.customName self.customName = "temporary name to avoid some errors" self.customName = getNotUsedCustomName(self.node, prefix = customName) if self.callNodeWhenCustomNameChanged: self.node.customSocketNameChanged(self) self.customNameIsUpdating = False nodeTreeChanged()
def buildSocketsFromDescription(self, socketDescription): forbidCompiling() try: inputDescription = socketDescription[0] for d in inputDescription: blName = getSocketNameByDataType(d[0]) name = d[1] identifier = d[2] self.inputs.new(blName, name, identifier) outputDescription = socketDescription[1] for d in outputDescription: blName = getSocketNameByDataType(d[0]) name = d[1] self.outputs.new(blName, name) self.errorMessage = "" except: self.errorMessage = "cannot build sockets" self.removeSockets() allowCompiling() nodeTreeChanged()
def updateSockets(self, socketStartValue = (None, None), inputRemoved = False, outputRemoved = False): forbidCompiling() connections = getConnectionDictionaries(self) self.removeSockets() inputNode = getNodeFromTypeWithAttribute("mn_GroupInput", "groupName", self.activeGroup) if inputNode is not None and not inputRemoved: network = NodeNetwork.fromNode(inputNode) if network.type == "Group": for socket in inputNode.getSockets(): newSocket = self.inputs.new(socket.bl_idname, socket.customName, socket.identifier) if socket == socketStartValue[0]: newSocket.setStoreableValue(socketStartValue[1]) if not outputRemoved: outputNode = network.getGroupOutputNode() if outputNode is not None: for socket in outputNode.getSockets(): newSocket = self.outputs.new(socket.bl_idname, socket.customName, socket.identifier) if socket == socketStartValue[0]: newSocket.setStoreableValue(socketStartValue[1]) tryToSetConnectionDictionaries(self, connections) allowCompiling() nodeTreeChanged()
def loopNameChanged(self, context): if not self.nameIsChanging: self.nameIsChanging = True self.loopName = self.getNotUsedLoopName(prefix=self.loopName) self.nameIsChanging = False nodeTreeChanged()
def selectedScriptChanged(self, context): updateScripts() self.buildSockets() self.errorMessage = "" nodeTreeChanged()
def updateCallerNodes(self, socketStartValue=(None, None)): nodes = getNodesFromTypeWithAttribute("mn_LoopCallerNode", "activeLoop", self.loopName) for node in nodes: node.updateSockets(socketStartValue) nodeTreeChanged()
def selectedSocketChanged(self, context): self.socketIsChanging = True self.setInputSocket() self.socketIsChanging = False nodeTreeChanged()
def removeInputSocket(self): forbidCompiling() if len(self.inputs) > 2: self.inputs.remove(self.inputs[len(self.inputs) - 2]) allowCompiling() nodeTreeChanged()
def amountChanged(self, context): self.generateInputSockets() nodeTreeChanged()
def selectedSocketChanged(self, context): self.socketIsChanging = True self.setInputSocket() self.socketIsChanging = False nodeTreeChanged()
def updateCallerNodes(self, socketStartValue = (None, None)): nodes = getNodesFromTypeWithAttribute("mn_LoopCallerNode", "activeLoop", self.loopName) for node in nodes: node.updateSockets(socketStartValue) nodeTreeChanged()
def checkedPropertiesChanged(self, context): self.updateSocketVisibility() nodeTreeChanged()
def update(self): nodeTreeChanged()
def usePropertyChanged(self, context): self.setHideProperty() nodeTreeChanged()
def usePropertyChanged(self, context): self.setHideProperty() nodeTreeChanged()
def loopNameChanged(self, context): if not self.nameIsChanging: self.nameIsChanging = True self.loopName = self.getNotUsedLoopName(prefix = self.loopName) self.nameIsChanging = False nodeTreeChanged()
def checkedPropertiesChanged(self, context): self.updateSocketVisibility() nodeTreeChanged()
def updateActiveLoop(self): if self.selectedLoop != "NONE": self.activeLoop = self.selectedLoop self.updateSockets() nodeTreeChanged()
def updateNode(node, context): nodeTreeChanged()
def updateNode(node, context): nodeTreeChanged()
def keyframeChanged(self, context): self.buildOutputSockets() nodeTreeChanged()
def keyframeChanged(self, context): self.buildOutputSockets() nodeTreeChanged()
def update(self): nodeTreeChanged()