I want to add selected objects at selected layer
To my mind it should be in the following way:
- select object
- press the button of script
- select layer from the list of layers
How to add all layers in custom menu If this variant is right?
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.
import c4d
def main():
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])
op.SetMg(new_m)
op.Message(c4d.MSG_UPDATE)
c4d.EventAdd()
if name == 'main':
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:
: video
import c4d
def main():
doc.StartUndo()
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
layer.InsertUnder(layerRoot)
name = layer.GetName()
rvalue = c4d.gui.RenameDialog(name) # rename
print(rvalue)
layer [c4d.ID_BASELIST_NAME] = rvalue
#layer.DelBit(c4d.BIT_ACTIVE)
null_obj = c4d.BaseObject(c4d.Onull)
null_obj [c4d.ID_LAYER_LINK] = layer
null_obj [c4d.ID_BASELIST_NAME] = rvalue
doc.InsertObject(null_obj)
doc.AddUndo(c4d.UNDOTYPE_NEWOBJ, layer)
doc.AddUndo(c4d.UNDOTYPE_NEWOBJ, null_obj)
s = doc.GetSelection()
vp = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_NONE)
for obj in vp:
print obj
obj [c4d.ID_LAYER_LINK] = layer
obj.InsertUnder(null_obj)
obj_mat_tags = [t for t in obj.GetTags() if t.IsInstanceOf(c4d.Ttexture)]
for tag in obj_mat_tags:
mat = tag.GetMaterial()
print mat
mat [c4d.ID_LAYER_LINK] = layer
doc.EndUndo()
c4d.EventAdd()
if __name__ == '__main__':
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?
Dear community!
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
c4d.GV_PORT_OUTPUT, [c4d.ID_BASEOBJECT_REL_POSITION,c4d.VECTOR_X]
Hello for everyone. Is it real to set up parameters like a position and rotation for all selected nodes by python?
def main():
nodes = []
root = nodeMaster.GetRoot()
for node in root.GetChildren():
if node.GetBit(c4d.BIT_ACTIVE):
##place for setting parameter##
If its real, could you write a command which set up x position in input for example
Hello guys! I know how to merge a scene with a current project. But i have no idea how to insert scene under parent with coordinats of this parent.
I want to create custom nulls thats why i want to it. What should i add in this code if i want insert scene under object?
import c4d
def main():
doc.StartUndo() # Start recording undos
path = "C:\Users\Jamaletdinov.r\Desktop\ArrowR.c4d"
flags = c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS | c4d.SCENEFILTER_MERGESCENE
c4d.documents.MergeDocument(doc, path, flags)
c4d.EventAdd()
doc.EndUndo()
if __name__=='__main__':
main()
@ferdinand Sorry for the late reply. Yes you understood me correctly. Will this be fixed in new c4d versions?
Hello for every one. Does anybody know is it real to set up value for selected user data and for all user data in object?
@cairyn Thank you again. I will check your patreon
@cairyn
For example, we have 20 layers and i need to change visibility just for 2 layers in this list. That's what i meant when i talked about selected layers.
I tried to use same code but it showed to me first layer in list....while i want to work with active layers which i have selected.
And i wanted to ask which command delete layer?
Sorry for stupid questions, but SDK a little bit unobvious.
@cairyn, i don't understand just one thing how should i change a code if i want to do it with selected objects not for all.
import c4d
def visitLayer(layer):
if layer == None: return
print (layer.GetName())
doc.AddUndo(c4d.UNDOTYPE_CHANGE, layer)
layer [c4d.ID_LAYER_VIEW] = 1
visitLayer(layer.GetDown())
visitLayer(layer.GetNext())
def main():
doc.StartUndo()
first = doc.GetLayerObjectRoot().GetDown()
visitLayer (first)
doc.EndUndo()
c4d.EventAdd()
if name=='main':
main()
It’s too bad, but thank you for your answer Manuel.
Hello for everybody!
I want to show all User Data of object in HUD. Is it real to make it by python,
i checked SDK but didn't find something about User data HUD.
Is it real or not?
P.S. I found an information about viewport in general (visibility of polygons, joints and so on) but nothing about user data hud.