Difference between revisions of "Part ShapeFromMesh"

From FreeCAD Documentation
Jump to navigation Jump to search
(Appropriate tools are available in the Mesh Workbench)
 
(9 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
<!--T:7-->
 
<!--T:7-->
 
{{Docnav
 
{{Docnav
|[[Part BoxSelection|Part BoxSelection]]
+
|[[Part_BoxSelection|Part BoxSelection]]
|[[Part PointsFromMesh|PointsFromMesh]]
+
|[[Part_PointsFromMesh|PointsFromMesh]]
 
|[[Part_Module|Part]]
 
|[[Part_Module|Part]]
 
|IconL=Part_BoxSelection.svg
 
|IconL=Part_BoxSelection.svg
Line 15: Line 15:
 
|Name=Part ShapeFromMesh‏‎
 
|Name=Part ShapeFromMesh‏‎
 
|MenuLocation=Part → Create shape from mesh...
 
|MenuLocation=Part → Create shape from mesh...
|Workbenches=[[Part Workbench|Part]]
+
|Workbenches=[[Part_Workbench|Part]]
|SeeAlso=[[Part ConvertToSolid|Part ConvertToSolid]], [[Part RefineShape|Part RefineShape]], [[Part PointsFromMesh|Part PointsFromMesh]]
+
|SeeAlso=[[Part_MakeSolid|Part ConvertToSolid]], [[Part_RefineShape|Part RefineShape]], [[Part_PointsFromMesh|Part PointsFromMesh]]
 
}}
 
}}
  
==Introduction== <!--T:3-->
+
==Introduction== <!--T:14-->
The {{Button|[[Image:Part_ShapeFromMesh.svg|16px]] [[Part ShapeFromMesh|Part ShapeFromMesh]]}} command creates a shape from a [[Glossary#Mesh|mesh object]]. Mesh objects have limited editing capabilities in FreeCAD, converting them to shapes will allow their use with many more tools in FreeCAD (see [[#Notes|Notes]]).
 
  
==Usage== <!--T:4-->
+
<!--T:3-->
# Select the mesh object.
+
The {{Button|[[Image:Part_ShapeFromMesh.svg|16px]] [[Part_ShapeFromMesh|Part ShapeFromMesh]]}} command creates a shape from a [[Mesh|mesh object]]. Mesh objects have limited editing capabilities in FreeCAD, converting them to [[Shape|shapes]] will allow their use with many more boolean and modification tools.
# Choose {{MenuCommand|Part → [[Image:Part_ShapeFromMesh.svg|16px]] Create shape from mesh}} from the top menu.
 
# A popup-menu will ask for the tolerance for sewing shape (default value: 0,1)
 
# A shape from the mesh object is created as a separate new object.
 
  
==Limitations==
+
<!--T:21-->
 +
The inverse operation is {{Button|[[File:Mesh_FromPartShape.svg|16px]] [[Mesh_FromPartShape|Mesh FromPartShape]]}} from the [[File:Workbench_Mesh.svg|24px]] [[Mesh_Workbench|Mesh Workbench]].
 +
 
 +
==Usage== <!--T:15-->
 +
 
 +
<!--T:4-->
 +
# Select the mesh object in the [[tree_view|tree view]].
 +
# Go to the menu, {{MenuCommand|Part → [[File:Part_ShapeFromMesh.svg|16px]] Create shape from mesh}}.
 +
# A popup-menu will ask for the tolerance for sewing shape; the default value is {{Value|0.1}}.
 +
# A [[Shape|shape]] from the mesh object is created as a separate new object.
  
 
<!--T:5-->
 
<!--T:5-->
There will be no analyzing or validating of the mesh object. Analyzing and repairing of the mesh, if needed, should be done manually before launching {{Button|[[File:Part_ShapeFromMesh.svg|16px]] [[Part_ShapeFromMesh|ShapeFromMesh]]}}.
+
Analyzing and repairing of the mesh, if needed, should be done manually before launching {{Button|[[File:Part_ShapeFromMesh.svg|16px]] [[Part_ShapeFromMesh|ShapeFromMesh]]}}. Appropriate tools for this task are available in the [[File:Workbench_Mesh.svg|24px]] [[Mesh_Workbench|Mesh Workbench]].
  
<!--T:12-->
+
<!--T:16-->
Appropriate tools are available in the [[File:Workbench_Mesh.svg|24px]] [[Mesh_Workbench|Mesh Workbench]].
+
After creation of a [[Shape|Shape]], it may be useful to use {{Button|[[Part_MakeSolid|Convert to solid]]}} (necessary for [[Part_Boolean|boolean operations]]) and {{Button|[[File:Part_RefineShape.svg|16px]] [[Part_RefineShape|Refine shape]]}}.
  
==Notes== <!--T:6-->
+
== Links == <!--T:17-->
After creation of a shape, it may be useful to use [[Part ConvertToSolid|Convert to solid]] (necessary for [[Glossary#Boolean Operation|Boolean operations]]) and [[Image:Part_RefineShape.svg|24px]] [[Part RefineShape|Refine shape]] tools.
+
 
 +
<!--T:18-->
 +
* [https://www.youtube.com/watch?v=5lwENZeNiNg&feature=youtu.be Edit STL Files In FreeCAD] video by  AllVisuals4U.
  
 
==Scripting== <!--T:13-->
 
==Scripting== <!--T:13-->
 +
 +
<!--T:19-->
 +
Creating a [[Shape|Shape]] from a [[Mesh|Mesh]] can be done by using the {{incode|makeShapeFromMesh}} method from a [[Part_TopoShape|Part TopoShape]]; you need to specify the source mesh and tolerance, and assign the result to a new [[Part_Feature|Part Feature]] object.
 +
 +
<!--T:20-->
 +
Notice that the mesh must be recalculated before it is converted to a Shape, otherwise there won't be topology information, and the conversion won't be successful.
 +
 +
</translate>
 +
{{Code|code=
 +
import FreeCAD as App
 +
import Part
 +
 +
doc = App.newDocument()
 +
mesh = doc.addObject("Mesh::Cube", "Mesh")
 +
mesh.recompute()
 +
 +
solid = doc.addObject("Part::Feature", "Shape")
 +
shape = Part.Shape()
 +
shape.makeShapeFromMesh(mesh.Mesh.Topology, 0.1)
 +
 +
solid.Shape = shape
 +
solid.Placement.Base = App.Vector(15, 0, 0)
 +
solid.purgeTouched()
 +
doc.recompute()
 +
}}
 +
<translate>
  
 
<!--T:8-->
 
<!--T:8-->
 
{{Docnav
 
{{Docnav
|[[Part BoxSelection|Part BoxSelection]]
+
|[[Part_BoxSelection|Part BoxSelection]]
|[[Part PointsFromMesh|PointsFromMesh]]
+
|[[Part_PointsFromMesh|PointsFromMesh]]
 
|[[Part_Module|Part]]
 
|[[Part_Module|Part]]
 
|IconL=Part_BoxSelection.svg
 
|IconL=Part_BoxSelection.svg

Latest revision as of 21:38, 16 October 2020

Other languages:
Deutsch • ‎English • ‎français • ‎italiano • ‎română • ‎русский

Part ShapeFromMesh.svg Part ShapeFromMesh‏‎

Menu location
Part → Create shape from mesh...
Workbenches
Part
Default shortcut
None
Introduced in version
-
See also
Part ConvertToSolid, Part RefineShape, Part PointsFromMesh


Introduction

The Part ShapeFromMesh.svg Part ShapeFromMesh command creates a shape from a mesh object. Mesh objects have limited editing capabilities in FreeCAD, converting them to shapes will allow their use with many more boolean and modification tools.

The inverse operation is Mesh FromPartShape.svg Mesh FromPartShape from the Workbench Mesh.svg Mesh Workbench.

Usage

  1. Select the mesh object in the tree view.
  2. Go to the menu, Part → Part ShapeFromMesh.svg Create shape from mesh.
  3. A popup-menu will ask for the tolerance for sewing shape; the default value is 0.1.
  4. A shape from the mesh object is created as a separate new object.

Analyzing and repairing of the mesh, if needed, should be done manually before launching Part ShapeFromMesh.svg ShapeFromMesh. Appropriate tools for this task are available in the Workbench Mesh.svg Mesh Workbench.

After creation of a Shape, it may be useful to use Convert to solid (necessary for boolean operations) and Part RefineShape.svg Refine shape.

Links

Scripting

Creating a Shape from a Mesh can be done by using the makeShapeFromMesh method from a Part TopoShape; you need to specify the source mesh and tolerance, and assign the result to a new Part Feature object.

Notice that the mesh must be recalculated before it is converted to a Shape, otherwise there won't be topology information, and the conversion won't be successful.

import FreeCAD as App
import Part

doc = App.newDocument()
mesh = doc.addObject("Mesh::Cube", "Mesh")
mesh.recompute()

solid = doc.addObject("Part::Feature", "Shape")
shape = Part.Shape()
shape.makeShapeFromMesh(mesh.Mesh.Topology, 0.1)

solid.Shape = shape
solid.Placement.Base = App.Vector(15, 0, 0)
solid.purgeTouched()
doc.recompute()