Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
@bentraje
I think name atttribute is not easy as old c4d SDK to use . It cann't print in console .
I use this to get Name , and Set Name . some codes in python sdk didn't work and return None .Maxon SDK has a example to get info form node retrieve_information_r26.py
# 获取名称 : def GetNodeName(self, node, display=False): """ Retrieve the displayed name of a node. Parameters ---------- Args: node: (maxon.GraphNode): The node to retrieve the name from. display: print info when display is True Returns: Optional[str]: The node name, or None if the Node name can't be retrieved. """ if node is None: return None nodeName = node.GetValue(maxon.NODE.BASE.NAME) if nodeName is None: nodeName = node.GetValue(maxon.EffectiveName) if nodeName is None: nodeName = str(node) if display ==True : print(nodeName) return nodeName
@ferdinand Maybe the broblem in not the code but the Cinema Application, Some friends also told me when they load Aseets(especially at a large Asset data like 20G in disk) , It always take a long time or even not load unless restart C4D.
You are right, I should call WaitForDatabaseLoading() function for safe. That's my stupid , I didn't notice the loading failed in state bar
WaitForDatabaseLoading()
I do check the Python examples in GitHub , but I think maybe it is a dcc of my config problem, some friends also said assets broswer is a little slower . (perhaps due to china a internet far away from maxon server) .hope it will be fix in uncoming C4D
@bentraje A little set for this , hope it can help something Set color space
@bentraje I just drag and drop the item and return the str , I also didn't found any str define in cinema folder
@ferdinand
A little update for this topic , my final solution for this problem is reg some tokens , and reg a plugin to analysis the project name and set token string depend on project name structure .
like a project name has a version sign like _v , than the output path set a $v for render . All the tokens can set by the analysis plugin . It is a bit stupid way but work well for a quickly set render path just one click.
_v
$v
Cheers
@bentraje Reflection layer symbols can't drag to console to get , maybe you can check Materials document , And GitHub Example for this.
And Shout out to @ferdinand ,this is my topic for this .
Here is a little code I used to set textures for BaseMaterials :
import c4d def main(): # Creates a standard C4D Material mat = c4d.Material() if mat is None: raise RuntimeError("Failed to create a new default material.") # Removes the default specular layer mat.RemoveReflectionLayerIndex(0) # Adds a layer layer = mat.AddReflectionLayer() if layer is None: raise RuntimeError("Failed to create a new reflection layer.") # Sets the Layer to Blinn mode mat[layer.GetDataID() + c4d.REFLECTION_LAYER_MAIN_DISTRIBUTION] = c4d.REFLECTION_DISTRIBUTION_SPECULAR_BLINN # Sets the shader for width colormap = "filename" shacolor = c4d.BaseList2D(c4d.Xbitmap) shacolor[c4d.BITMAPSHADER_FILENAME] = colormap mat.InsertShader(shacolor) # Defines the Roughness float value mat[layer.GetDataID() + c4d.REFLECTION_LAYER_MAIN_SHADER_ROUGHNESS] = shacolor # Inserts a material in the active doc doc.InsertMaterial(mat) # Pushes an update event to Cinema 4D c4d.EventAdd() if __name__ == '__main__': main()
@m_adam Thanks a lot for this example A big shout out !
Hi @m_adam ,
I also have a problem with filename in the preference . It has the same problem as @potashalum did, and I look for the Github py-preference example , I notice that a note Filename parameter type are not supported. .
But I fine some build-in res file has the FILENAME attribute (like ...\description\prefsbrowser.res) , and it can actually read and set filename in preference , Is it fixed now and miss some information that I failed to do this in python
FILENAME
For the suggestion of the example, I try to fake it with a bitmap , but I failed draw a bitmap in res file ,could you please update the Github example a little for this ,or some tricks and tips?
Thanks!
@bentraje Thanks a lot ! I always want to spend some thing to do this , but unfortunately I am struggling to work with rendering .
If I have some time hopes I can change this a bit more
@ferdinand Thanks for this detailed explanation.
About 1st , the AttributeError: parameter set failed . I remembered that I trying to set a cloner Inexclude data or something like that , sometimes it will return None type , but when I drag a "data" to it , it can be received.(seems like in R26 , I have update to 2023.1.0 , and try it just now , it will work again , I can't make sure want is happened earlier )
AttributeError: parameter set failed
new_mat_link = new_mat[c4d.ID_MATERIALASSIGNMENTS]
And the Object , this is a great explanation. I didn't realized that material assignment is depend on actually texture tag
Object
@ferdinand said in c4d.MatAssignData can't link.:
There could be a plethora of reasons why it was done like this, ranging from pure oversight to an intentional boundary.
And the last InsertObject why didn't work explain I can't really understand (It's to technical to me ) But the fix function is really smart way to bypass the problem .
InsertObject
Hi :
I try to merge all selected materials assignment to a new material assignment . aka merge materials to one new material .
But it won't assign the new MatAssignData to new material .
MatAssignData
How can I fix this
Here is the mini code :
# @2023.1.0 from typing import Optional import c4d doc: c4d.documents.BaseDocument # The active document op: Optional[c4d.BaseObject] # The active object, None if unselected def merge_material() -> None: myMat = doc.GetActiveMaterial() ObjLink = myMat[c4d.ID_MATERIALASSIGNMENTS] new_mat = c4d.BaseMaterial(5703) doc.InsertMaterial(new_mat) new_mat.SetName(myMat.GetName() + " Combine") new_mat_link = c4d.MatAssignData() myCount = ObjLink.GetObjectCount() for i in range(myCount) : tag = ObjLink.ObjectFromIndex(doc,i) obj = tag.GetObject() #print (obj) new_mat_link.InsertObject(obj,0) print(new_mat_link.GetObjectCount()) # this will failed # AttributeError: parameter set failed new_mat[c4d.ID_MATERIALASSIGNMENTS] = new_mat_link doc.SetActiveMaterial(new_mat, c4d.SELECTION_NEW) c4d.EventAdd() if __name__ == '__main__': merge_material()
@ferdinand Thanks for the new solution for SetActiveObject . It works as expected.
SetActiveObject
Much appreciated !
That's all right I will move on another work for now. Thanks for your time