Access to Part Triangles and Points (Mimics 22.0)

The Mimics API also supports low-level data access to images, masks and 3D parts (or STLs). This tutorial shows how to access the nodes (points) and triangles of a part. The Mimics project Heart.mcs from C:\MedData\DemoFiles will be used.

# Tutorial for access to nodes of an STL
# Import the required libraries
	import numpy as np  # First need to install numpy package for Python. Type pip install numpy in your cmd
except ImportError as ie:
	print("=== The 3rd party Python package 'numpy' is not installed! ===")
	print("=== To install it, use 'pip install numpy' in your cmd!    ===")
# Open Heart.mcs project
input_dir = r'C:\MedData\DemoFiles\Heart.mcs'
# Get the LV part
p ="LV")
if p is not None:
	# Get a copy of nodes and triangles
	nodes, triangles = p.get_triangles()
	# Read them with numpy
	nodes = np.asarray(nodes)
	triangles = np.asarray(triangles)
	# Find the point that is closest to the WCS
	mx = []
	for m in nodes:
	i_mx = mx.index(max(mx))
	# Find the point that is furthest from the WCS
	mn = []
	for m in nodes:
	i_mn = mn.index(min(mn))
	# Calculate the distace
	d = mimics.measure.create_distance_measurement(list(nodes[i_mx]), list(nodes[i_mn]))
	print("The part LV could not be found.")