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.

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

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
for obj in bpy.data.objects:
    if obj.hide == True:
        obj.hide = False
        obj.select = True
| improve this answer | |
  • $\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$ – Andre Bredeweg Feb 21 '17 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 Feb 21 '17 at 10:59
  • $\begingroup$ Do the objects that are hidden have somekind of attribute that say they are hidden? $\endgroup$ – Andre Bredeweg Feb 21 '17 at 11:01
  • $\begingroup$ @AndreBredeweg yes, do you want to delete all hidden objects? $\endgroup$ – Tak Feb 21 '17 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$ – Andre Bredeweg Feb 21 '17 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.