I have several cad files that I want to analyze. I want to analyze several cad files (step file,stl file), like a plate with several holes inside of it. I want to extract all the dimensions of these files (height,width of the plate and radius of the holes) in order to compare them.
I didn't find any kind of examples on stackoverflow, or at least I didn't undertand.
I tried numpy-stl but not that far. I tried pyvista also.
Did someone has done something like that ?
Thank you very much
Which solution is the best bewteen numpy-stl or pyvista ? Do you have an other solution ?
What have you tried yourself so far, please include code.
And what didn't you get from other sources? Be more specific please.
What I can come up, and found online is the following:
#!/usr/bin/env python3
import pyvista as pv
# load stl file
mesh = pv.read("plate_with_holes.stl")
# extract the bounding box
bounds = mesh.bounds
# calculate the height, width, and length
# fiddle around w the numbers
height = bounds[5] - bounds[4]
width = bounds[1] - bounds[0]
length = bounds[3] - bounds[2]
# print them
print("plate height: ", height)
print("plate width: ", width)
print("plate length: ", length)
# use `find_radius` to extract the radius of each hole
radius = []
for hole_center in hole_centers:
radius.append(mesh.find_radius(hole_center))
print("hole radius: ", radius)
Again, you need to be more specific and at least provide examples.