0
$\begingroup$

He guys,

I'm working on a commandline-based puthon-script that imports an IFC-file and cleans it up. So far i can import an IFC-file, do some clean-up and than save the file. The only thing that i cant get my head around is the deleting of hidden objects. These object are hidden in the 3D view and from the rendered view. From within blender you can simply unhide and delete them. Is there a way to delete thes objects from a commandline based python script.

$\endgroup$
1
  • $\begingroup$ Please do not edit the title with Solved; accepting the answer already did that, read help about answered questions. $\endgroup$
    – Mr Zak
    Commented Feb 21, 2017 at 12:29

1 Answer 1

1
$\begingroup$

You can use the command line to run blender and pass the below python script to it which will delete all unhidden objects:

import bpy
bpy.ops.object.select_all(action='DESELECT')
for obj in bpy.data.objects:
    if obj.hide == True:
        obj.hide = False
        obj.select = True
bpy.ops.object.delete() 
$\endgroup$
6
  • $\begingroup$ This brings me closer to the solution, it works from the text editor and not from the commandline script. The only thing is that i dont know the name of the object, so i'll have to make a list of hidden object. Is there a way to do this? Maybe it's an idea to move the objects i want to keep to the next layer and then unhide all object in the first layer?? $\endgroup$ Commented Feb 21, 2017 at 10:55
  • $\begingroup$ @AndreBredeweg what do you mean by you don't know the name of the object? so imagine you doing it manually which object you are going to delete? there should be a way to identify which object you want to delete. $\endgroup$
    – Tak
    Commented Feb 21, 2017 at 10:59
  • $\begingroup$ Do the objects that are hidden have somekind of attribute that say they are hidden? $\endgroup$ Commented Feb 21, 2017 at 11:01
  • $\begingroup$ @AndreBredeweg yes, do you want to delete all hidden objects? $\endgroup$
    – Tak
    Commented Feb 21, 2017 at 11:05
  • $\begingroup$ Yes, that's the idea. IFC files tend to have lots of hidden objects (103 in this test-case). These hidden objects show up in Unity3D. $\endgroup$ Commented Feb 21, 2017 at 11:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .