Working with planes (3-matic 14.0)

In this tutorial some basic features of planes in 3-matic 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 create anatomical points. First, Mark the triangles on the femur’s head. To activate marking tools, go to the Mark toolbar, and select one of the tools. Mark the femur head.

The next step is to separate the Marked Triangles into a new surface. Rename the new surface into “head”.

import trimatic

femur=trimatic.find_part("femur")
head=femur.find_surface("Head")

trimatic.create_sphere_fit(entities=head)
sphere=trimatic.find_sphere(name="Sphere")
head_pt=trimatic.create_point((sphere.center))

#perform indicate coordinates to create points on the condyles
medial_pt=trimatic.indicate_coordinate()
trimatic.create_point(coords=medial_pt)
lateral_pt=trimatic.indicate_coordinate()
trimatic.create_point(coords=lateral_pt)

# Create a midshaft plane	
mid_shaft_plane=trimatic.create_plane_midplane(point1=head_pt,point2=medial_pt)
mid_shaft_plane.name="midshaft"
# Create a midplane in condyles
mid_cond_plane=trimatic.create_plane_midplane(point1=medial_pt,point2=lateral_pt)

center_cond=trimatic.create_point(mid_cond_plane.origin)
center_cond.name="c_cond"
translated_center_cond=trimatic.create_point(center_cond.coordinates)
trimatic.translate(translated_center_cond,[0,0,1])


# Create a plane in the condyles area
cond_plane=trimatic.create_plane_3_points(medial_pt,translated_center_cond,lateral_pt)
cond_plane.name="condyles plane"
trimatic.delete(translated_center_cond)

sag_plane=trimatic.create_plane_2_points_perpendicular_1_plane(head_pt,center_cond,mid_shaft_plane)
sag_plane.name="saggital plane"

cut_femur=trimatic.cut((femur),(cond_plane))
#Hide all the parts and planes and keep the part of interest
objs = trimatic.get_objects()
for obj in objs:
	obj.visible = False
cut_femur[1].visible = True
condyles=cut_femur[1]
condyles.name="condyles"

The next script is an updated version of the “Working with planes” script. It allows you to run the script without the preprocessing steps to create the surface “head”.

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")

#Define the marked area and create new surface.
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 operation")
marked_triangles=trimatic.get_selection()
sphere=trimatic.create_sphere_fit(entities=marked_triangles)
head_pt=trimatic.create_point((sphere.center))

#perform indicate coordinates to create points on the condyles
print("Indicate the medial point on the femur")
medial_pt=trimatic.indicate_coordinate()
medial_pt=trimatic.create_point(coords=medial_pt)
print("Indicate the lateral point on the femur")
lateral_pt=trimatic.indicate_coordinate()
lateral_pt=trimatic.create_point(coords=lateral_pt)

# Create a midshaft plane
mid_shaft_plane=trimatic.create_plane_midplane(point1=head_pt,point2=medial_pt)
mid_shaft_plane.name="midshaft"

# Create a midplane in condyles
mid_cond_plane=trimatic.create_plane_midplane(point1=medial_pt,point2=lateral_pt)
center_cond=trimatic.create_point(mid_cond_plane.origin)
center_cond.name="c_cond"
translated_center_cond=trimatic.create_point(center_cond.coordinates)
trimatic.translate(translated_center_cond,[0,0,1])

# Create a saggital plane
sag_plane=trimatic.create_plane_2_points_perpendicular_1_plane(head_pt,center_cond,mid_shaft_plane)
sag_plane.name="saggital plane"


# Create a plane in the condyles area
cond_plane=trimatic.create_plane_3_points(medial_pt,translated_center_cond,lateral_pt)
cond_plane.name="condyles plane"
trimatic.delete(translated_center_cond)
femur=trimatic.cut((femur),(sag_plane))
cut_femur=trimatic.cut((femur),(cond_plane))

#Hide all the parts and planes and keep the part of interest
objs = trimatic.get_objects()
for obj in objs:
	obj.visible = False
cut_femur[1].visible = True
condyles=cut_femur[1]
condyles.name="condyles"