# coding: utf-8
#
# Copyright © 2020 MSC.Software Corporation
#  
# Permission to use Scripts
#  
# Permission is granted to MSC.Software customers with valid licenses of the MSC Apex™ software 
# to use script files posted on this page (collectively “Scripts”) solely for customers’ own authorized 
# internal use in conjunction with licensed use of the MSC Apex software.  
# No other use is permitted.  No license to MSC Apex or other software is granted under this Permission.
#  
# SCRIPTS ARE PROVIDED ON AN "AS-IS" BASIS, WITH NO WARRANTIES OF ANY KIND.  USE OF THE SCRIPTS IS AT CUSTOMER'S SOLE RISK.
#  
# IN NO EVENT SHALL MSC.SOFTWARE CORPORATION, ITS AFFILIATES, SUBSIDIARIES, SUPPLIERS, AGENTS, REPRESENTATIVES OR EMPLOYEES BE LIABLE FOR ANY 
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, 
# STRICT LIABILITY, OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION USE OF THE SCRIPTS, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
#  
# Customer shall indemnify, defend and hold MSC.Software Corporation, its affiliates, subsidiaries, suppliers, agents, 
# employees or representatives (collectively, “Indemnified Parties”) harmless from and against any third-party claims 
# brought against Indemnified Parties rising out of or in connection with Customer’s use of the Scripts.
#
# Macro created by MSC Apex MSC_Apex Hawk PRE - Version CLR:535240
# Macro created on Dec 13, 2017 at 10:08:12
# 
# Macro Name = Get Stuff
# 
# Macro Description = Returns and counts geometrical entities in a model
# 
# Macro Hot Key = Ctrl+G
# 
# Initialize Apex environment for macro execution


import apex
from apex.construct import Point3D, Point2D

apex.setScriptUnitSystem(unitSystemName = r'''mm-kg-s-N''')

def getAllParts():
	#get and return all solids from current model
	model_1 = apex.currentModel()
	parts = model_1.getParts(True)
	return parts
	
def getAllSolids():
	solids = apex.entityCollection()
	parts=getAllParts()
	for part in parts:
		solids += part.getSolids()
	return solids

def getAllSurfs():
	surfs = apex.entityCollection()
	parts=getAllParts()
	for part in parts:
		surfs += part.getSurfaces()
	return surfs
	
def getAllFaces():
	faces = apex.entityCollection()
	surfs=getAllSurfs()
	for surf in surfs:
		faces += surf.getFaces()
	solids=	getAllSolids()
	for solid in solids:
		faces += solid.getFaces()
	return faces
#added
def getAllSurfFaces():
	surffaces = apex.entityCollection()
	surfs=getAllSurfs()
	for surf in surfs:
		surffaces += surf.getFaces()
	return surffaces
#added	
def getAllSolidFaces():
	solidfaces = apex.entityCollection()
	solids=	getAllSolids()
	for solid in solids:
		solidfaces += solid.getFaces()
	return solidfaces
		
def getAllEdges():
	edges = apex.entityCollection()
	interior_edges=apex.entityCollection()
	exterior_edges=apex.entityCollection()
	surfs=getAllSurfs()
	for surf in surfs:
		edges += surf.getEdges()
	return edges

def getAllInteriorEdges():
	edges = apex.entityCollection()
	surfs=getAllSurfs()
	for surf in surfs:
		edges += surf.getInteriorEdges()
	return edges	
	
def getAllExteriorEdges():
	edges = apex.entityCollection()
	surfs=getAllSurfs()
	for surf in surfs:
		edges += surf.getExteriorEdges()
	return edges

def getSolidEdges():
	edges = apex.entityCollection()
	solids=getAllSolids()
	for solid in solids:
		edges += solid.getEdges()
	return edges


def getAllCurves():
	curves = apex.entityCollection()
	parts=getAllParts()
	for part in parts:
		curves += part.getCurves()
	return curves
	
if __name__ == "__main__":
	if 1==1:
		parts=getAllParts()
		solids=getAllSolids()
		surfs=getAllSurfs()
		faces=getAllFaces()
		edges=getAllEdges()
		curves=getAllCurves()
		interior_edges=getAllInteriorEdges()
		solid_edges=getSolidEdges()
	#added	
		surffaces=getAllSurfFaces()
		solidfaces=getAllSolidFaces()
		
		model_1 = apex.currentModel()
		print("Database: " + model_1.getName() )
		print("Path: " + model_1.getPath() )
		print("============================")
			
		print("Parts: " + str(len(parts)))
		print("Solids: " + str(len(solids)))
		print("Surfaces:  " + str(len(surfs)))
		#modified
		print("Surface and solid faces: " + str(len(faces)))
		print("Surface edges: " + str(len(edges)))
		print("Surface Interior edges: " + str(len(interior_edges)))
		print("Curves: " + str(len(curves)))
		#added
		print("Surface faces: " + str(len(surffaces)))
		print("Solid faces: " + str(len(solidfaces)))
		
		print("Solid edges: " + str(len(solid_edges)))

				
	
