# Measurements (3-matic 14.0)

**URL:** <https://community.materialise.com/t/measurements-3-matic-14-0/65>\
**Category:** MIS - Demo Scripts\
**Tags:** orthopedics, 3-matic, measurements\
**Created:** [May 21, 2019, 11:11am UTC](https://community.materialise.com/t/measurements-3-matic-14-0/65 "2019-05-21T11:11:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtls\_jdeckx](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.materialise.com/mtls_jdeckx/32/14_2.png) [@mtls\_jdeckx](https://community.materialise.com/u/mtls_jdeckx)\
**Post date:** [May 21, 2019, 11:11am UTC](https://community.materialise.com/t/measurements-3-matic-14-0/65/1 "2019-05-21T11:11:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sofie\_desiron1](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.materialise.com/sofie_desiron1/32/17_2.png) [@sofie\_desiron1](https://community.materialise.com/u/sofie_desiron1)\
**Post date:** [June 4, 2019, 2:53pm UTC](https://community.materialise.com/t/measurements-3-matic-14-0/65/2 "2019-06-04T14:53:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![karel.penicka](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@karel.penicka](https://community.materialise.com/u/karel.penicka)\
**Post date:** [February 11, 2024, 10:46am UTC](https://community.materialise.com/t/measurements-3-matic-14-0/65/3 "2024-02-11T10:46:59Z")

</div>

Hi , How can I add **user\_defined\_cs** and **measurement\_coordinates**?  
MDFA = trimatic.create\_angle\_measurement\_line\_to\_line(line\_from=femur\_joint\_line , line\_to= MAOF\_line , measurement\_coordinates= ??? , user\_defined\_cs = ??? )  
I want to measure **mech.medial distal femoral angle** Between **mechanical axis femur** and **joint line femur** on **Femur plane**.  
As **user\_defined\_cs** I use my **Femur plane** , but How can I set up **XY of femur plane** to my measurement.  
Thank you

---

<div class="post-metadata">

**Author:** ![imaninanoh](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.materialise.com/imaninanoh/32/123_2.png) [@imaninanoh](https://community.materialise.com/u/imaninanoh)\
**Post date:** [February 26, 2024, 9:38am UTC](https://community.materialise.com/t/measurements-3-matic-14-0/65/4 "2024-02-26T09:38:43Z")

</div>

Hi Karel,

As you want to measure it on the Femur plane, you can try to set the parameter as below:

1. measurement\_coordinates = trimatic.MeasurementCoordinates.XY
2. user\_defined\_cs = Femurplane.object\_coordinate\_system

Could you let me know if this helps to achieve your goal?

Thank you,  
Imanina

---

<div class="post-metadata">

**Author:** ![karel.penicka](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@karel.penicka](https://community.materialise.com/u/karel.penicka)\
**Post date:** [February 26, 2024, 9:57am UTC](https://community.materialise.com/t/measurements-3-matic-14-0/65/5 "2024-02-26T09:57:36Z")

</div>

Yes , this work.

```python
cs_femur = APofF.object_coordinate_system
cs_femur_XY = trimatic.MeasurementCoordinates.XY
MDFA = trimatic.create_angle_measurement_line_to_line(line_from=MAOF_line, line_to=femur_joint_line, user_defined_cs=cs_femur, measurement_coordinates=cs_femur_XY, leader_line_length=140)
MDFA.name = "mMDFA"
print(MDFA.value)

```
