Measurements (3-matic 14.0)

In this tutorial basic measurements operations are presented using the project Femur.mxp that is located in the 3-matic installation folder under folder DemoFiles. To open the project, first launch 3-matic and select File -> Open project .

The first step in this tutorial is to manually mark the femur head, the neck and the femur shaft. To mark areas click on the menu Mark -> Brush Mark -> Wave Brush Mark and select the area of interest. To make sure that the triangles are marked through the selected area, hold the SHIFT button while selecting.

The Marked triangles of the regions are then separated into different surfaces. To create a new surface, right click on the Marked triangles that appear in the Object tree after the selection of the desired area, click Separate -> Move to Surface -> Create New .

Rename the created surfaces to head, neck and shaft for the femoral head, neck and shaft area respectively.

import trimatic
# Assign to variables the part and the created surfaces
femur = trimatic.find_part("femur")
shaftsurface = femur.find_surface('Shaft')
necksurface = femur.find_surface('Neck')
headsurface = femur.find_surface('Head')

# Create an analytical sphere and fit lines
headsphere = trimatic.create_sphere_fit(headsurface)
neckline = trimatic.create_line_fit_ruled_surface(necksurface)
shaftline = trimatic.create_line_fit_ruled_surface(shaftsurface)

#to check if the analytical entities are present in the correct positions, set the femur to high transparency
femur.transparency=0.5

# print the radius of the head of the sphere
print("Radius of the femur head is ",headsphere.radius)
print("\n \n")
# Calculate the angle between the neck and the femur and print the value
femurangle = trimatic.create_angle_measurement_line_to_line(shaftline,neckline)
print("Angle between femur neck and femur shaft is ",femurangle.value)

The next script is an updated version of the “Measurements” script. The pre-processing steps are integrated in the script in an interactive manner.

import os
import trimatic

#Open project, find part and set view.
application_exe = trimatic.get_application_path()
application_path = os.path.dirname(application_exe)
project_filename = application_path + "/DemoFiles/Femur.mxp"
trimatic.open_project(project_filename)
view_vector=[0.48249295353889465, -0.874954879283905, 0.040668144822120667]
up_vector=[0.7136449217796326, 0.4196108281612396, 0.5609255433082581]
trimatic.view_custom(view_vector, up_vector)
femur = trimatic.find_part("femur")

#Mark the different areas and create the corresponding surfaces.
trimatic.message_box(message="Mark the triangles of the femur's head using Mark-> Brush Mark -> Wave Brush Mark and click OK. To make sure that the triangles are marked through the selected area, hold the **SHIFT** button while selecting." , title= "Marking Head")
head_marked_triangles=trimatic.get_selection()
head_surface= trimatic.move_to_surface(head_marked_triangles)

trimatic.message_box(message="Mark the triangles of the femur's shaft using Mark-> Brush Mark -> Wave Brush Mark and click OK. To make sure that the triangles are marked through the selected area, hold the **SHIFT** button while selecting." , title= "Marking Shaft")
shaft_marked_triangles=trimatic.get_selection()
shaft_surface= trimatic.move_to_surface(shaft_marked_triangles)

trimatic.message_box(message="Select the surface of the neck to define the variable and click OK." , title= "Define Neck Surface")
neck_surface= trimatic.get_selection()

# Create an analytical sphere and fit lines
head_sphere = trimatic.create_sphere_fit(head_surface)
neck_line = trimatic.create_line_fit_ruled_surface(neck_surface)
shaft_line = trimatic.create_line_fit_ruled_surface(shaft_surface)
femur.transparency=0.5

# print the radius of the head of the sphere
print("Radius of the femur head is ",head_sphere.radius)
print("\n \n")

# Calculate the angle between the neck and the femur and print the value
femurangle = trimatic.create_angle_measurement_line_to_line(shaft_line,neck_line)
print("Angle between femur neck and femur shaft is ",femurangle.value)