Mesh PolyTrim: Difference between revisions

From FreeCAD Documentation
(Removed 'in progress'.)
(Button text.)
 
(12 intermediate revisions by 4 users not shown)
Line 2: Line 2:
<translate>
<translate>


<!--T:1-->
{{Docnav
{{Docnav
|[[Mesh_PolyCut|Mesh PolyCut]]
|[[Mesh_PolyCut|PolyCut]]
|[[Mesh_TrimByPlane|Mesh TrimByPlane]]
|[[Mesh_TrimByPlane|TrimByPlane]]
|[[Mesh_Workbench|Mesh]]
|[[Mesh_Workbench|Mesh]]
|IconL=Mesh_PolyCut.svg
|IconL=Mesh_PolyCut.svg
|IconR=
|IconR=Mesh_TrimByPlane.svg
|IconC=Workbench_Mesh.svg
|IconC=Workbench_Mesh.svg
}}
}}


<!--T:2-->
{{GuiCommand
{{GuiCommand
|Name=Mesh PolyTrim
|Name=Mesh PolyTrim
|Empty=1
|MenuLocation=Meshes → Cutting → Trim mesh
|MenuLocation=Meshes → Cutting → Trim mesh
|Workbenches=[[Mesh_Workbench|Mesh]]
|Workbenches=[[Mesh_Workbench|Mesh]]
Line 19: Line 20:
}}
}}


==Description==
==Description== <!--T:3-->


<!--T:4-->
The '''Mesh PolyTrim''' command trims faces and parts of faces from mesh objects.
The '''Mesh PolyTrim''' command trims faces and parts of faces from mesh objects.


==Usage==
==Usage== <!--T:5-->


<!--T:6-->
# During the command the [[3D_view|3D view]] cannot be changed. It is advisable to properly line up the 3d view first.
# During the command the [[3D_view|3D view]] cannot be changed. It is advisable to properly line up the 3d view first.
# Select one or more mesh objects.
# Select one or more mesh objects.
# There are several ways to invoke the command:
# Select the {{MenuCommand|Meshes → Cutting → Trim mesh}} option from the menu.
#* Press the {{Button|[[Image:Mesh_PolyTrim.svg|16px]] [[Mesh_PolyTrim|Trim mesh]]}} button.
#* Select the {{MenuCommand|Meshes → Cutting → [[Image:Mesh_PolyTrim.svg|16px]] Trim mesh}} option from the menu.
# Define a polygon by picking points in the 3D view.
# Define a polygon by picking points in the 3D view.
# Select an option from the 3D view context menu:
# Select an option from the 3D view context menu:
Line 35: Line 40:
#* {{MenuCommand|Cancel}}: cancels the command.
#* {{MenuCommand|Cancel}}: cancels the command.


==Scripting== <!--T:8-->


<!--T:9-->
See also: [[FreeCAD_Scripting_Basics|FreeCAD Scripting Basics]].

<!--T:10-->
To trim a mesh with a polygon use its {{incode|trim}} method.

</translate>
{{Code|code=
import FreeCAD as App
import Mesh

# Create a non-parametric box-shaped mesh:
msh = App.ActiveDocument.addObject("Mesh::Feature", "Mesh")
msh.Mesh = Mesh.createBox(30, 40, 50)
msh.ViewObject.DisplayMode = "Flat Lines"

# Define some points:
p1 = App.Vector(0, 0, 0)
p2 = App.Vector(60, 0, 0)
p3 = App.Vector(60, 60, 0)

# We need to work on a copy of the msh.Mesh object:
new_msh = msh.Mesh.copy()

# Trim that copy:
new_msh.trim([p1, p2, p3], 0) # 2nd argument: 0=inner, 1=outer.

# Update msh.Mesh:
msh.Mesh = new_msh
}}
<translate>


<!--T:7-->
{{Docnav
{{Docnav
|[[Mesh_PolyCut|Mesh PolyCut]]
|[[Mesh_PolyCut|PolyCut]]
|[[Mesh_TrimByPlane|Mesh TrimByPlane]]
|[[Mesh_TrimByPlane|TrimByPlane]]
|[[Mesh_Workbench|Mesh]]
|[[Mesh_Workbench|Mesh]]
|IconL=Mesh_PolyCut.svg
|IconL=Mesh_PolyCut.svg
|IconR=
|IconR=Mesh_TrimByPlane.svg
|IconC=Workbench_Mesh.svg
|IconC=Workbench_Mesh.svg
}}
}}
Line 48: Line 88:
{{Mesh Tools navi{{#translation:}}}}
{{Mesh Tools navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
{{clear}}

Latest revision as of 16:43, 25 November 2023

Other languages:

Mesh PolyTrim

Menu location
Meshes → Cutting → Trim mesh
Workbenches
Mesh
Default shortcut
None
Introduced in version
-
See also
Mesh PolyCut, Mesh TrimByPlane

Description

The Mesh PolyTrim command trims faces and parts of faces from mesh objects.

Usage

  1. During the command the 3D view cannot be changed. It is advisable to properly line up the 3d view first.
  2. Select one or more mesh objects.
  3. There are several ways to invoke the command:
    • Press the Trim mesh button.
    • Select the Meshes → Cutting → Trim mesh option from the menu.
  4. Define a polygon by picking points in the 3D view.
  5. Select an option from the 3D view context menu:
    • Inner: removes the faces and parts of faces that are inside the polygon.
    • Outer: removes the faces and parts of faces that are outside the polygon.
    • Split: removes the faces and parts of faces that are outside the polygon, and creates a new mesh object containing them.
    • Cancel: cancels the command.

Scripting

See also: FreeCAD Scripting Basics.

To trim a mesh with a polygon use its trim method.

import FreeCAD as App
import Mesh

# Create a non-parametric box-shaped mesh:
msh = App.ActiveDocument.addObject("Mesh::Feature", "Mesh")
msh.Mesh = Mesh.createBox(30, 40, 50)
msh.ViewObject.DisplayMode = "Flat Lines"

# Define some points:
p1 = App.Vector(0, 0, 0)
p2 = App.Vector(60, 0, 0)
p3 = App.Vector(60, 60, 0)

# We need to work on a copy of the msh.Mesh object:
new_msh = msh.Mesh.copy()

# Trim that copy:
new_msh.trim([p1, p2, p3], 0) # 2nd argument: 0=inner, 1=outer.

# Update msh.Mesh:
msh.Mesh = new_msh