I want to add selected objects at selected layer
To my mind it should be in the following way:
How to add all layers in custom menu If this variant is right?
Hello for everyone! How to add selected objects at selected layer in layer mager?!!
edit: I restored your image, we will answer the posting tomorrow [ferdinand]
@mogh I didn't know about this function
@ferdinand Thank you a lot for your detailed response. I will chek posts which you recommended
Hello guys! Is it real to check everything in layer (objects, materials, tags) and delete layer if its empty?
Script add a null in center of world coordinates. I want to change it, i described what i want to do in pictures.
I added Mike's code, because i wanted to make 2 options for Step 2:
I'm sorry for my English...
@ferdinand , thank you a lot!
When i tried to fix my code i used Mike Udin's example, but i couldn't understand why this code didn't work with multiple objects. I've got next message: "AttributeError: 'NoneType' object has no attribute 'GetAllPoints'".
I supposed my script to set selected objects' axis points in the center for each other. After that the script should create a null between all axis points.
ps = op.GetAllPoints() #Points in Local coordinates List
m = op.GetMg() #Object Global Matrix
center = op.GetMp() #Local coordinates center: https://tinyurl.com/wed88cn
rad = op.GetRad() # Geometry radius: https://tinyurl.com/tb6vn64
center -= c4d.Vector(0,rad.y,0) #Move down axis to lowest point. Comment this line to keep axis in a center
center *= m #Convert to Global coordinates center
new_m = c4d.Matrix(m) #Copy matrix
new_m.off = center #Change its center
loc_m = ~new_m * m #Get local matrix
op.SetAllPoints([loc_m.Mul(p) for p in ps])
if name == 'main':
edit: This topic has been forked from How to fix the bug of objects position in script by @ferdinand
Guys! Please, help. I cannot fix this problem.
The main idea of this script is:
layer = c4d.documents.LayerObject()
# Set layer name (another option tp set the name)
# Get the invisible root layer
layerRoot = doc.GetLayerObjectRoot()
# Insert the layer under the parent
name = layer.GetName()
rvalue = c4d.gui.RenameDialog(name) # rename
layer [c4d.ID_BASELIST_NAME] = rvalue
null_obj = c4d.BaseObject(c4d.Onull)
null_obj [c4d.ID_LAYER_LINK] = layer
null_obj [c4d.ID_BASELIST_NAME] = rvalue
s = doc.GetSelection()
vp = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_NONE)
for obj in vp:
obj [c4d.ID_LAYER_LINK] = layer
obj_mat_tags = [t for t in obj.GetTags() if t.IsInstanceOf(c4d.Ttexture)]
for tag in obj_mat_tags:
mat = tag.GetMaterial()
mat [c4d.ID_LAYER_LINK] = layer
if __name__ == '__main__':
I use r21 version of c4d.
@ferdinand Thank you a lot for your help! I'm really sorry for organization of my post. Could you point out on my mistakes in tagging?
I want to create length port for spline node but I can’t find correct command for it.
How to get id of port in form like this
Mike, thank you a lot!