I found the solution on https://plugincafe.maxon.net/
It was enough in the for loop to add the following line of code:
for object in list_object:
if object != object_root:
object.InsertUnder(object_root)
c4d.EventAdd()
I found the solution on https://plugincafe.maxon.net/
It was enough in the for loop to add the following line of code:
for object in list_object:
if object != object_root:
object.InsertUnder(object_root)
c4d.EventAdd()
Hi,
With a script, I create a large number of objects in my scene.
In the hierarchy, they are presented in the form of a list, which becomes difficult to read because it's too long.
So I want to put the names of the child objects under the name of the root object.
How can I do this ?
def hierarchie_organise(doc, object_root, list_object):
# document name: doc
# object root: object_root
# child objects: list_object
# checking (exclusion of the root object if it's in the list of child objects)
list_child = []
for object in list_object:
if object != object_root:
list_child.append(object)
# positioning of list_child objects under the object_root object
...
...
...
return
True
I have created a function that adds points to a polygon.
But how to remove a point from a polygon, as well as remove the faces that contain it ?
Creation of UVW tag for a plane
I would like to know how to create texture coordinates for a plane, with python.
So I want to create with python the basic UVW tag for a plan.
I would like to get the same result as with Bodypaint.
Thanks, it works well
My first method was complex:
Hi,
I want to do a rotation for a polynone.
I know the coordinates of the points of the polygon, in the global coordinate system.
For this rotation, I know the axis of rotation, defined by a vector V, and the angle of rotation A with respect to this axis.
I manage to do this type of rotation, with matrices and with a change of Cartesian coordinate system, but I know that there is a much simpler method with C4D python functions
I am going to write a new script, using c4d.CallCommand and c4d.utils.SendModelingCommand which can do the same thing much faster.
The Script log window presents the code very well, in real time, for many operations.
@cairyn said in Polygon corresponding to a selection:
SendModelingCommand
Indeed, with SendModelingCommand it would be faster.
I don't remember how we visualize with C4D the python code corresponding to the actions of the keyboard and the mouse.
Hi,
I would like to know if we can quickly obtain a polygon corresponding to a selection.
I manage to do it in python, but for the large meshes it's much too slow, because I do treatments on the indices of points and faces.
Below, with python, I create two polygons with the corresponding material, for the two selections (selection_1 and selection_2)
For a large mesh (greater than 100 Mo), the use of indices for points and faces considerably slows down the program.
We see that the initial polygon has been divided correctly, according to the two selections
Thank you.
I had forgotten about this excellent feature of C4D.
It must be said that I rarely do plugins, because now C4D can do a lot of things.
Hi,
I have another problem that looks a bit like my previous post.
Now for each tag (type 5616), I want to know the name of the associated selection, if it exists.
Could you put the correct code in place of the dotted lines
tag = obj.GetFirstTag()
while tag:
if tag.GetType() == 5616: #texture tag
#name of tag
print tag.GetMaterial().GetName()
#name of the associated selection, if it exists
...
...
...
tag = tag.GetNext()
Thanks for your quick replies
I used GetBaseSelect() which allowed me to have the selected faces for each selection
list_polygon = obj.GetAllPolygons()
dim = len(list_polygon)
L = []
tag = obj.GetFirstTag()
while tag:
if tag.GetType() == c4d.Tpolygonselection:
sel = tag.GetBaseSelect()
L2 = []
for i in range(0,dim):
if sel.IsSelected(i):
L2.append(i)
L.append([tag.GetName(),L2])
tag = tag.GetNext()
for item in L:
print item[0]
print item[1]
Hi,
I have a polygon with multiple selections.
For each selection, I want to know the list of faces (presented as a list of indices)
For a polygon I know how to access each selection:
tag = polygone.GetFirstTag()
while tag:
if tag.GetType() == c4d.Tpolygonselection:
print tag.GetName()
..
...
...
tag = tag.GetNext()
If you can replace the dotted lines with the correct code, thanks
I found the solution to my problem, on the internet, with code samples:
https://www.c4dcafe.com/ipb/forums/topic/101805-materials-and-shaders-with-python/
Hi
I created a material.
I inserted a texture into the COLOR channel.
Then, I inserted another texture into the BUMP channel.
Now, I want to insert a texture for the specularity, but I don't know how to create a Layer Reflection (Legacy)
I only activated the REFLECTANCE channel with the following code:
mat [c4d.MATERIAL_USE_REFLECTION] = True
Then I want to apply the following values for this layer:
0.5 for REFLECTION_LAYER_MAIN_VALUE_ROUGHNESS
1.0 for REFLECTION_LAYER_MAIN_VALUE_REFLECTION
0.2 for REFLECTION_LAYER_MAIN_VALUE_SPECULAR
1.0 for REFLECTION_LAYER_MAIN_VALUE_BUMP
I suppose that these values must be prefixed by the variable 'mat' which represents the material and also by the id of the layer.
I found the solution (I already had this problem but I couldn't remember the right code)
mat [c4d.MATERIAL_TRANSPARENCY_COLOR] = c4d.Vector (1.0, 1.0, 1.0) #color white
mat.Update (True, True)
Hi,
In the 'Transparency' channel of a material, I need to modify the color.
How to read and modify this value with Python ?
I already have the material identifier.
I found the solution to my problem in the Script Log window which shows the manual commands in python
Hi,
I know how to apply a material to an object, but I would like to know how to apply a material to one of the object's selections only.
Hi
C4D has a command which allows to weld points of a mesh.
I would like to make a script in python which would allow me to weld very close points.
How can I call this command with python ?