Check if active Document is empty

Is there a method which checks if the active document contains a solid body?

Couldnt find an answer by searching the forum..


Thanks in advance!


Re: Check if active Document is empty

Hi bschla,


Based on the information that you look for a solid body I assume that by "active document" you mean a Part document.

I can think of two ways to accomplish this:



Check if the volume of the model is zero



Check if there are any Edgebar features that create a volume (extrusions, party copies, etc.)


If by "empty" you also mean other part features like constructions, then forget solution 1) and extend the list of features in solution 2) accordingly.



Re: Check if active Document is empty

Hi bschla,


for a par/psm document object you may simply check the property Models.Count for a value greater than zero.



Kind regards,
Wolfgang Kunert -

Re: Check if active Document is empty

i am planning to implement the button in assembly, part, weldment and sheetmetal.

With empt I mean no solid body (no volume)

I need a 3d printable object, so a 3D model, not just planes.


Thanks, I will get into that. I am also thinking about saving the model as a stl file and check if the stl filesize is greater than 0..



Re: Check if active Document is empty

For part and sheetmetal documents, you should iterate through all Model objects in the Models collection and check for the Body.IsSolid property. If there is no solid body in any of the models, it is EMPTY.


For assembly documents, you will iterate through all its child documents and do the above check for part and sheetmetal occurrences. For subassemblies, you will iterate recursively. You have to stop the recursion as soon as you have found a solid body to tell that the assembly is NOT EMPTY.


For weldments, I don't know, but I think it's similar to the assembly documents.