Delete object by name
-
On 05/07/2014 at 03:50, xxxxxxxx wrote:
Hi, I am new to Python and am creating a rig. When the user clicks a userdata checkbox, I need a specific object deleted. Here is what I have that doesn't work.
def delete() :
# find "MAT and Surface Thumbs"
mat_thumbs = doc.SearchObject('MAT and Surface Thumbs')
if obj.mat_thumbs:
obj.Remove('MAT and Surface Thumbs')Can anyone help? Thanks.
-
On 05/07/2014 at 07:16, xxxxxxxx wrote:
Hi,
- What is obj? But nevermind, you can be sure that mat_thumbs won't be assigned to its
attributes if you don't do so explicitly - Assuming that mat_thumbs was an attribute of obj, you'd still need to use it when
calling Remove(), like obj.mat_thumbs.Remove() - The Remove() method does not need an argument.
def delete() : mat_thumbs = doc.SearchObject('MAT and Surface Thumbs') if mat_thumbs: mat_thumbs.Remove()
-Niklas
- What is obj? But nevermind, you can be sure that mat_thumbs won't be assigned to its
-
On 05/07/2014 at 07:44, xxxxxxxx wrote:
Here is my entire code block but it does not seem to remove the object. (This is part of the rig I PM'd you about. I will probably end up paying you to do it, based on your response to my email but in the meantime, the more I can learn about getting this all to work, the better. Thank-you for your time and patience.)
import c4d
from c4d import guidef delete() :
mat_thumbs = doc.SearchObject('MAT and Surface Thumbs')
if mat_thumbs:
mat_thumbs.Remove()if __name__=='__main__':
main() -
On 07/07/2014 at 01:53, xxxxxxxx wrote:
I guess you have to add c4d.EventAdd().
So tel cinema 4d to update.