def main(): doc = c4d.documents.GetActiveDocument() # Get active Cinema 4D document selection = doc.GetSelection() # Get active selection (objects, tags) for s in selection: # Iterate through selection print(s.GetName(), "\"" + type(s).__name__ + "\"", s.GetType()) # Print: name, class and type id if type(s).__name__ == "XPressoTag": # If operator is xpresso tag nodeMaster = s.GetNodeMaster() # Get node master root = nodeMaster.GetRoot() # Get xpresso root for c in root.GetChildren(): # Loop through nodes if c.GetBit(c4d.BIT_ACTIVE): # If node is selected print("Node: " + c.GetName() + ", " + str(c.GetOperatorID())) # Print node info inPorts = c.GetInPorts() # Get input ports outPorts = c.GetOutPorts() # Get output ports for p in range(0, len(inPorts)): # Loop through input ports print(" In port: " + inPorts[p].GetName(c) + ", " + str(inPorts[p].GetMainID())) # Print inPort info for p in range(0, len(outPorts)): # Loop through output ports print( " Out port: " + outPorts[p].GetName(c) + ", " + str(outPorts[p].GetMainID())) # Print outPort info materials = doc.GetMaterials() # Get materials for m in materials: # Iterate through materials if m.GetBit(c4d.BIT_ACTIVE): # If material is selected print(m.GetName(), "\"" + type(m).__name__ + "\"", m.GetType()) # Print: name, class and type id if m.GetType() == 1036224: # If Redshift material rsnm = redshift.GetRSMaterialNodeMaster( m) # Get Redshift material node master root = rsnm.GetRoot() # Get node master root for c in root.GetChildren(): # Loop through nodes if c.GetBit(c4d.BIT_ACTIVE): # If node is selected print("Node: " + c.GetName() + ", " + str(c.GetOperatorID())) # Print node info inPorts = c.GetInPorts() # Get input ports outPorts = c.GetOutPorts() # Get output ports for p in range( 0, len(inPorts)): # Loop through input ports print(" In port: " + inPorts[p].GetName(c) + ", " + str(inPorts[p].GetMainID()) ) # Print inPort info for p in range( 0, len(outPorts)): # Loop through output ports print(" Out port: " + outPorts[p].GetName(c) + ", " + str(outPorts[p].GetMainID()) ) # Print outPort info c4d.EventAdd() # Refresh Cinema 4D
def main(): name = gui.InputDialog("Matte name", "") # Input dialog if name is None: return if name is "": return doc = c4d.documents.GetActiveDocument() # Get active document doc.StartUndo() # Start recording undos theList = [] # Collect all items for matte creation selection = doc.GetSelection() # Get active selection (objects and tags) for s in selection: # Loop through selected objects if not isinstance(s, c4d.BaseTag): # If object tags = s.GetTags() # Get object's tags for t in tags: # Loop through tags if isinstance(t, c4d.TextureTag): # If texture tag mat = t[c4d.TEXTURETAG_MATERIAL] # Get material m = checkRedshiftMaterial(mat) theList.append(m) if isinstance(s, c4d.TextureTag): # If texture tag mat = s[c4d.TEXTURETAG_MATERIAL] # Get material m = checkRedshiftMaterial(mat) theList.append(m) materials = doc.GetMaterials() # Get materials for mat in materials: # Iterate through materials if mat.GetBit(c4d.BIT_ACTIVE): # If material is selected m = checkRedshiftMaterial(mat) theList.append(m) theList = [i for i in theList if i] # Remove Nones finalList = [] # Init the final list for items names = [] # Init list for collecting material names for item in theList: # Iterate through the list if item.GetName() not in names: names.append(item.GetName()) finalList.append(item) for item in finalList: renderdata = doc.GetActiveRenderData() vprs = redshift.FindAddVideoPost(renderdata, redshift.VPrsrenderer) if vprs is None: return rsnm = redshift.GetRSMaterialNodeMaster(item) # Get Redshift material node master AddMatte(rsnm, vprs, name) # Run the main function doc.EndUndo() # Stop recording undos c4d.EventAdd() # Refresh Cinema 4D
def main(): doc = c4d.documents.GetActiveDocument() # Get active Cinema 4D document doc.StartUndo() # Start recording undos materials = doc.GetMaterials() # Get materials try: # Try to execute following script for m in materials: # Iterate through materials if m.GetBit(c4d.BIT_ACTIVE): # If material is selected rsnm = redshift.GetRSMaterialNodeMaster( m) # Get Redshift material node master triplanar_maptype(rsnm) # Run the main function except: # Otherwise pass # Do nothing doc.EndUndo() # Stop recording undos c4d.EventAdd() # Refresh Cinema 4D
def CompareRedshiftMaterial(mata, matb): #Get the root node for the redshift node graph mata_master = redshift.GetRSMaterialNodeMaster(mata) matb_master = redshift.GetRSMaterialNodeMaster(matb) #Iterate through all the nodes and dump them in a list mata_nodes = GetAllNodes(mata_master) matb_nodes = GetAllNodes(matb_master) # if the lists aren't the same length they aren't duplicate if len(mata_nodes) == len(matb_nodes): # iterate through list a for idx, n in enumerate(mata_nodes): # compare the data basecontainer on each node, if they aren't equal return false if n.GetOperatorContainer()!=matb_nodes[idx].GetOperatorContainer(): return False # if we made it through all the nodes with all of them being equal then # I bet the materials are duplicated return True # Return false if the lengths aren't equal return False
def SetMat(self, mat): """Set the mat to act on. :param mat: The material to act on. Only accept a Redshift Material. :type mat: c4d.BaseMaterial. :raises: TypeError """ global redshift if not isinstance(mat, c4d.BaseMaterial): raise TypeError('material is not a c4d.BaseMaterial') if not mat.IsInstanceOf(redshift.Mrsmaterial): raise TypeError('material is not a redshift material') self._mat = mat self._gvMaster = redshift.GetRSMaterialNodeMaster(mat) if not self._gvMaster: raise TypeError('can\'t get GvMaster from mat')
def main(): doc = c4d.documents.GetActiveDocument() # Get active document bc = c4d.BaseContainer() # Initialize a base container keyMod = "None" # Initialize a keyboard modifier status # Button is pressed if c4d.gui.GetInputState(c4d.BFM_INPUT_KEYBOARD, c4d.BFM_INPUT_CHANNEL, bc): if bc[c4d.BFM_INPUT_QUALIFIER] & c4d.QSHIFT: if bc[c4d.BFM_INPUT_QUALIFIER] & c4d.QCTRL: # Ctrl + Shift if bc[c4d. BFM_INPUT_QUALIFIER] & c4d.QALT: # Alt + Ctrl + Shift keyMod = 'Alt+Ctrl+Shift' else: # Shift + Ctrl keyMod = 'Ctrl+Shift' elif bc[c4d.BFM_INPUT_QUALIFIER] & c4d.QALT: # Alt + Shift keyMod = 'Alt+Shift' else: # Shift keyMod = 'Shift' elif bc[c4d.BFM_INPUT_QUALIFIER] & c4d.QCTRL: if bc[c4d.BFM_INPUT_QUALIFIER] & c4d.QALT: # Alt + Ctrl keyMod = 'Alt+Ctrl' else: # Ctrl keyMod = 'Ctrl' elif bc[c4d.BFM_INPUT_QUALIFIER] & c4d.QALT: # Alt keyMod = 'Alt' else: # No keyboard modifiers used keyMod = 'None' doc.StartUndo() # Start recording undos materials = doc.GetMaterials() # Get materials selection = doc.GetSelection() # Get active selection try: # Try to execute following script # Xpresso for s in selection: # Iterate through selection if type(s).__name__ == "XPressoTag": # If operator is xpresso tag xpnm = s.GetNodeMaster() # Get node master AlignNodesVer(xpnm, keyMod) # Run the main function # Redshift for m in materials: # Iterate through materials if m.GetBit(c4d.BIT_ACTIVE): # If material is selected rsnm = redshift.GetRSMaterialNodeMaster( m) # Get Redshift material node master AlignNodesVer(rsnm, keyMod) # Run the main function except: # Otherwise pass # Do nothing doc.EndUndo() # Stop recording undos c4d.EventAdd() # Refresh Cinema 4D
def main(): doc = c4d.documents.GetActiveDocument() # Get active document bc = c4d.BaseContainer() # Initialize a base container keyMod = GetKeyMod() # Get keymodifier doc.StartUndo() # Start recording undos materials = doc.GetMaterials() # Get materials selection = doc.GetSelection() # Get active selection #try: # Try to execute following script # Redshift for m in materials: # Iterate through materials if m.GetBit(c4d.BIT_ACTIVE): # If material is selected rsnm = redshift.GetRSMaterialNodeMaster( m) # Get Redshift material node master AddTriplanar(rsnm, keyMod) # Run the main function #except: # Otherwise #pass # Do nothing doc.EndUndo() # Stop recording undos c4d.EventAdd() # Refresh Cinema 4D
def main(): doc = c4d.documents.GetActiveDocument() # Get active Cinema 4D document doc.StartUndo() # Start recording undos materials = doc.GetMaterials() # Get materials selection = doc.GetSelection() # Get active selection try: # Try to execute following script # Xpresso for s in selection: # Iterate through selection if type(s).__name__ == "XPressoTag": # If operator is xpresso tag xpnm = s.GetNodeMaster() # Get node master DistributeNodes(xpnm) # Run the main function for m in materials: # Iterate through materials if m.GetBit(c4d.BIT_ACTIVE): # If material is selected rsnm = redshift.GetRSMaterialNodeMaster( m) # Get Redshift material node master DistributeNodes(rsnm) # Run the main function except: # Otherwise pass # Do nothing doc.EndUndo() # Stop recording undos c4d.EventAdd() # Refresh Cinema 4D
def get_rs_node(self, mat): node_master = redshift.GetRSMaterialNodeMaster(mat) root_node_sg = node_master.GetRoot() output = root_node_sg.GetDown() r_shader = output.GetNext() return r_shader
def matSetSpec(self, setting, value): doc = c4d.documents.GetActiveDocument() # Process for all materials of scene docMaterials = doc.GetMaterials() for mat in docMaterials: matName = mat.GetName() skinMats = [ "MainSkin", "Legs", "Torso", "Arms", "Face", "Fingernails", "Toenails", "EyeSocket", "Ears", "Feet", "Nipples", "Forearms", "Hips", "Neck", "Shoulders", "Hands", "Head", "Nostrils", ] for x in skinMats: if x in matName: if mat.GetType() == 1038954: # Vray if setting == "Rough": mat[c4d.VRAYSTDMATERIAL_REFLECTGLOSSINESS] = ( 1.0 - value / 100) if setting == "Weight": colorValue = value / 100 mat[c4d.VRAYSTDMATERIAL_REFLECTCOLOR] = c4d.Vector( colorValue, colorValue, colorValue) if mat.GetType() == 5703: # Standard layer = mat.GetReflectionLayerIndex(0) if setting == "Rough": mat[layer.GetDataID() + c4d.REFLECTION_LAYER_MAIN_VALUE_ROUGHNESS] = ( value / 100) if setting == "Weight": mat[layer.GetDataID() + c4d.REFLECTION_LAYER_MAIN_VALUE_SPECULAR] = ( value / 100) if mat.GetType() == 1029501: # Octane if setting == "Weight": mat[c4d.OCT_MATERIAL_SPECULAR_FLOAT] = value / 100 if setting == "Rough": mat[c4d.OCT_MATERIAL_ROUGHNESS_FLOAT] = value / 100 if mat.GetType() == 1036224: # Redshift gvNodeMaster = redshift.GetRSMaterialNodeMaster(mat) rootNode_ShaderGraph = gvNodeMaster.GetRoot() output = rootNode_ShaderGraph.GetDown() RShader = output.GetNext() gvNodeMaster = redshift.GetRSMaterialNodeMaster(mat) nodeRoot = gvNodeMaster.GetRoot() rsMaterial = nodeRoot.GetDown().GetNext() if setting == "Weight": rsMaterial[ c4d.REDSHIFT_SHADER_MATERIAL_REFL_WEIGHT] = ( value / 100) rsMaterial[ c4d.REDSHIFT_SHADER_MATERIAL_REFL_IOR] = ( value / 10) if setting == "Rough": rsMaterial[ c4d. REDSHIFT_SHADER_MATERIAL_REFL_ROUGHNESS] = ( value / 100)