Remove object from layer
-
I have searched through the documentation and cannot seem to find a way to use Python to remove and object from a layer.
for item in spline_id: layer = doc.GetLayerObjectRoot().GetDown() if layer.GetName() == "nd": print layer.GetName() layer.SetLayerObject(None)
This is the code I am using. I am trying to remove the object from the nd layer. Can you help? Thanks.
-
Hi,
maybe I am overlooking something here, but your code does not make much sense to me. You are using
BaseList2D.SetLayerObject
onlayer
, which is aLayerObject
. This technically works, since layers are derived fromC4DAtom
(i.e. are also aBaseList2D
), but practically makes very little sense. If you want to remove a layer from a nested layer structure, you have to use the hierarchy methods ofGeListNode
. If you want to remove anything else in the scene graph from an layer, you have to overwrite the layer withBaseList2D.SetLayerObject
on that object - in your case that object would beitem
, assumingitem
is some kind ofBaseList2D
.Cheers,
zipit -
Like zipit said, SetLayerObject() is from a shared base class but supposed to be used on with thingy (object, tag, material):
op.SetLayerObject(None) c4d.EventAdd()
actually it is also possible just to edit the "Layer" parameter:
op[c4d.ID_LAYER_LINK] = None c4d.EventAdd()
Compare Layer Manual.
-
@PluginStudent said in Remove object from layer:
op[c4d.ID_LAYER_LINK] = None
op[c4d.ID_LAYER_LINK] = None c4d.EventAdd()
did it! Thanks!
As you can tell from my previous code, I am hacking my way through Python. If you saw the rest of it, you would probably have to sit down and maybe drink a Gatorade. Or something stronger.