Part ShapeFromMesh: Difference between revisions

From FreeCAD Documentation
mNo edit summary
No edit summary
 
(34 intermediate revisions by 7 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>

<!--T:7-->
<!--T:7-->
{{Docnav
{{Docnav|[[Part BoxSelection|Part BoxSelection]]|[[Part ConvertToSolid|Convert to solid]]|[[Part_Module|Part]]|IconL=Part ExportCAD.png|IconC=Workbench_Part.svg|IconR=Part_BoxSelection.svg}}
|[[Part_BoxSelection|BoxSelection]]
|[[Part_PointsFromMesh|PointsFromMesh]]
|[[Part_Workbench|Part]]
|IconL=Part_BoxSelection.svg
|IconR=Part_PointsFromMesh.svg
|IconC=Workbench_Part.svg
}}


<!--T:2-->
<!--T:2-->
{{GuiCommand
{{GuiCommand|Name=Part ShapeFromMesh‏‎|MenuLocation=Part → Create shape from mesh...|Workbenches=[[Part Workbench|Part]]|SeeAlso=[[Part ConvertToSolid|Part ConvertToSolid]], [[Part RefineShape|Part RefineShape]], [[Part PointsFromMesh|Part PointsFromMesh]]}}
|Name=Part ShapeFromMesh‏‎
|MenuLocation=Part → Create shape from mesh...
|Workbenches=[[Part_Workbench|Part]]
|SeeAlso=[[Part_MakeSolid|Part ConvertToSolid]], [[Part_RefineShape|Part RefineShape]], [[Part_PointsFromMesh|Part PointsFromMesh]]
}}


==Introduction== <!--T:3-->
==Introduction== <!--T:14-->
This 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 (also see [[#Notes|Notes]]).


==Use== <!--T:4-->
<!--T:3-->
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.

<!--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-->
# Analyzing and repairing the mesh object, if needed, should be done before launching this command. Appropriate tools for this task are available in the [[File:Workbench_Mesh.svg|16px]] [[Mesh_Workbench|Mesh Workbench]].
# Select the mesh object.
# Select the mesh object.
# Choose {{MenuCommand|Part → [[Image:Part_ShapeFromMesh.png|16px]] Create shape from mesh}} from the top menu.
# Select the {{MenuCommand|Part → [[File:Part_ShapeFromMesh.svg|16px]] Create shape from mesh}} option from the menu.
# The {{MenuCommand|Shape from mesh}} dialog opens.
# A popup-menu will ask for the tolerance for sewing shape (default value: 0,1)
# Optionally check the {{MenuCommand|Sew shape}} checkbox and specify a tolerance:
# A shape from the mesh object is created as a seperate new object.
#* This option is usually not needed. It is meant for mesh objects that are not watertight and have small gaps between edges.
#* If the option is selected a compound of shells, instead of a compound of faces, is created.
#* The sewing operation may be computationally demanding.
# Press the {{Button|OK}} button.
# A [[Shape|shape]] is created as a separate new object.
# Optionally turn this object into a solid with [[File:Part_MakeSolid.svg|16px]] [[Part_MakeSolid|Part MakeSolid]].
# Optionally use [[File:Part_RefineShape.svg|16px]] [[Part_RefineShape|Part RefineShape]] on the final object.


==Limitations== <!--T:5-->
== Links == <!--T:17-->
There will be no analyzing or validating of the mesh object.


<!--T:11-->
<!--T:18-->
* [https://www.youtube.com/watch?v=5lwENZeNiNg&feature=youtu.be Edit STL Files In FreeCAD] video by AllVisuals4U.
Analyzing and repairing of the mesh (if needed) should be done manually before conversion.


<!--T:12-->
==Scripting== <!--T:13-->
Appropriate tools are available in the [[Mesh Workbench|Mesh Workbench]].


==Notes== <!--T:6-->
<!--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.
After creation of a shape, it may be useful to use [[Part ConvertToSolid|Convert to solid]] (necessary for [[Glossary#Boolean Operation|Boolean operations]]) and [[Part RefineShape|Refine shape]] tools.


<!--T:8-->
<!--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.
{{Docnav|[[Part BoxSelection|Part BoxSelection]]|[[Part ConvertToSolid|Convert to solid]]|[[Part_Module|Part]]|IconL=Part ExportCAD.png|IconC=Workbench_Part.svg|IconR=Part_BoxSelection.svg}}


</translate>
<!--T:9-->
{{Code|code=
{{Part Tools navi}}
import FreeCAD as App
import Part


doc = App.newDocument()
<!--T:10-->
mesh = doc.addObject("Mesh::Cube", "Mesh")
{{Userdocnavi}}
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-->
{{Docnav
|[[Part_BoxSelection|BoxSelection]]
|[[Part_PointsFromMesh|PointsFromMesh]]
|[[Part_Workbench|Part]]
|IconL=Part_BoxSelection.svg
|IconR=Part_PointsFromMesh.svg
|IconC=Workbench_Part.svg
}}


</translate>
</translate>
{{Part Tools navi{{#translation:}}}}
{{Userdocnavi{{#translation:}}}}
{{clear}}
{{clear}}

Latest revision as of 12:44, 30 January 2024

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 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 from the Mesh Workbench.

Usage

  1. Analyzing and repairing the mesh object, if needed, should be done before launching this command. Appropriate tools for this task are available in the Mesh Workbench.
  2. Select the mesh object.
  3. Select the Part → Create shape from mesh option from the menu.
  4. The Shape from mesh dialog opens.
  5. Optionally check the Sew shape checkbox and specify a tolerance:
    • This option is usually not needed. It is meant for mesh objects that are not watertight and have small gaps between edges.
    • If the option is selected a compound of shells, instead of a compound of faces, is created.
    • The sewing operation may be computationally demanding.
  6. Press the OK button.
  7. A shape is created as a separate new object.
  8. Optionally turn this object into a solid with Part MakeSolid.
  9. Optionally use Part RefineShape on the final object.

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