Macro Extract Wires from Mesh: Difference between revisions
m (DATE ISO 8601 YYYY-MM-DD) |
m (icon) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
<translate> |
<translate> |
||
<!--T:1--> |
<!--T:1--> |
||
{{Macro |
|||
{{Macro|Icon=Text-x-python|Name=Macro Extract Wires from Mesh|Description=Extracts boundary wires from selected meshes|Author=Yorik|Version=1|Date=2016-12-17}} |
|||
|Name=Macro Extract Wires from Mesh |
|||
|Icon=Macro_Extract_Wires_from_Mesh.png |
|||
|Description=Finds boundary wires in selected mesh objects. Boundary wires are formed from all the edges found in the mesh that are shared by only one face, that is, they are "border" edges. The found wires get added to the document (one compound per mesh object), while the mesh itself gets hidden. |
|||
|Author=Yorik |
|||
|Version=1 |
|||
|Date=2016-12-17 |
|||
|FCVersion=All |
|||
|Download=[https://www.freecadweb.org/wiki/images/2/28/Macro_Extract_Wires_from_Mesh.png ToolBar Icon] |
|||
}} |
|||
==Description== <!--T:2--> |
==Description== <!--T:2--> |
||
Line 11: | Line 20: | ||
==Script== <!--T:4--> |
==Script== <!--T:4--> |
||
</translate> |
</translate> |
||
⚫ | |||
ToolBar Icon [[Image:Macro_Extract_Wires_from_Mesh.png]] |
|||
'''Macro_Extract_Wires_from_Mesh.FCMacro''' |
|||
{{Code|code= |
|||
⚫ | |||
# This macro will extract wires from selected meshes |
# This macro will extract wires from selected meshes |
||
Line 37: | Line 52: | ||
obj.ViewObject.hide() |
obj.ViewObject.hide() |
||
}} |
}} |
||
⚫ |
Revision as of 15:02, 29 July 2019
Description |
---|
Finds boundary wires in selected mesh objects. Boundary wires are formed from all the edges found in the mesh that are shared by only one face, that is, they are "border" edges. The found wires get added to the document (one compound per mesh object), while the mesh itself gets hidden. Macro version: 1 Last modified: 2016-12-17 FreeCAD version: All Download: ToolBar Icon Author: Yorik |
Author |
Yorik |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
1 |
Date last modified |
2016-12-17 |
FreeCAD Version(s) |
All |
Default shortcut |
None |
See also |
None |
Description
Finds boundary wires in selected mesh objects. Boundary wires are formed from all the edges found in the mesh that are shared by only one face, that is, they are "border" edges. The found wires get added to the document (one compound per mesh object), while the mesh itself gets hidden.
Script
Macro_Extract_Wires_from_Mesh.FCMacro
#!/usr/bin/python
# This macro will extract wires from selected meshes
# The result is a new Part Compound containing wires, one per original mesh object
# The selected meshes will be hidden but still selected after the operation.
# Warning, it takes a bit of time...
import FreeCAD,FreeCADGui,Part,Draft,DraftGeomUtils,Mesh
for obj in FreeCADGui.Selection.getSelection():
if obj.isDerivedFrom("Mesh::Feature"):
shape = Part.Shape()
shape.makeShapeFromMesh(obj.Mesh.Topology,0.1)
edges = []
lut = {}
for f in shape.Faces:
for e in f.Edges:
lut.setdefault(e.hashCode(),[]).append(e)
for k,v in lut.items():
if len(v) == 1:
edges.extend(v)
if edges:
wires = DraftGeomUtils.findWires(edges)
if wires:
Part.show(Part.makeCompound(wires))
obj.ViewObject.hide()