Hide menu
Loading...
Searching...
No Matches
Wall Thickness Analyzer Example

Demonstrates how to compute minimum and maximum wall thickness of a 3D model and print the result in a console.

Overview

In this example demonstrates how to compute minimum and maximum wall thickness of a 3D model using wall thickness analysis tool (WallThickness_Analyzer). For this purpose, used a console application that imports a model. Wall thickness analysis will be performed for each unique ModelData_Part , but only for the scope of accepted geometries.


Application needs 1 or 2 input arguments to run:

Usage: wall_thickness_analyzer <input_file> <input_resolution>, where:
<input_file> is a name of the file to be read
<input_resolution> is an optional argument that determine accuracy of wall thickness calculation. The larger the value, the higher the accuracy of the calculations, but greatly increase computation time and memory usage. Should be at least 20.


For more information about wall thickness visit Wall Thickness Calculation page.

Implementation

To explore the model and process ModelData_Part , it's need to create an inheritor from the ModelData_ModelElementVoidVisitor and override the part processing method void operator() (const ModelData::Part& thePart). For this purpose, the SolidProcessor and PartProcessor classes were created. In operator() method a ModelData_Part is examined for the presence of ModelData_Solid shapes in it.

def VisitPart(self, thePart: mtk.Part):
aPartName = "noname" if thePart.Name().IsEmpty() else thePart.Name()
aBodyList = thePart.Bodies()
i = 0
for aBody in aBodyList:
aShapeIt = mtk.ShapeIterator(aBody)
for aShape in aShapeIt:
if aShape.Type() == mtk.ShapeType_Solid:
print("Part #", self.myPartIndex, " [\"", aPartName, "\"] - solid #", i, " has:", sep="")
i += 1
self.ProcessSolid(mtk.Solid.Cast(aShape))
elif aShape.Type() == mtk.ShapeType_Shell:
print("Part #", self.myPartIndex, " [\"", aPartName, "\"] - shell #", i, " has:", sep="")
i += 1
self.ProcessShell(mtk.Shell.Cast (aShape))
self.myPartIndex += 1

ProcessSolid method is used to run wall thickness analysis for given entities.

def ProcessSolid(self, theSolid: mtk.Solid):
aWTData = self.myAnalyzer.Perform(theSolid, self.myResolution)
self.PrintWTData (aWTData)

PrintWTData method is used to retrieve minimum and maximum thickness from computed WallThickness_Data and print these values to console.

def PrintWTData(self, theData: mtk.WallThickness_Data):
if theData.IsEmpty() != True:
print(" Min thickness = ", theData.MinThickness(), " mm", sep="")
print(" Max thickness = ", theData.MaxThickness(), " mm\n", sep="")
else:
print(" Failed to analyze the wall thickness of this entity.\n")

To traverse only unique parts of the imported model, the ModelData_ModelElementUniqueVisitor class is used.

aPartProcessor = PartProcessor()
aVisitor = mtk.ModelData_ModelElementUniqueVisitor(aPartProcessor)
aModel.Accept(aVisitor)

Example output

Below is the example output for model from ./examples/models/barrel.stp and resolution set to 1000.

Model Example output
Model: barrel

Part #0 ["barrel"] - solid #0 has:
    Min thickness = 4.526479 mm
    Max thickness = 10.036917 mm

Files