Macro Extract Wires from Mesh/it: Difference between revisions

From FreeCAD Documentation
No edit summary
(Created page with "==Descrizione==")
Line 2: Line 2:
{{Macro/it|Icon=Text-x-python|Name=Macro Extract Wires from Mesh|Name/it=Macro Estrai Wire da Mesh|Description=Estrae i bordi wire dai mesh selezionati|Author=Yorik|Version=1}}
{{Macro/it|Icon=Text-x-python|Name=Macro Extract Wires from Mesh|Name/it=Macro Estrai Wire da Mesh|Description=Estrae i bordi wire dai mesh selezionati|Author=Yorik|Version=1}}


==Description==
==Descrizione==


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.
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.

Revision as of 21:28, 22 December 2016

File:Text-x-python Macro Extract Wires from Mesh

Descrizione
Estrae i bordi wire dai mesh selezionati

Versione macro: 1
Autore: Yorik
Autore
Yorik
Download
None
Link
Versione macro
1
Data ultima modifica
None
Versioni di FreeCAD
None
Scorciatoia
Nessuna
Vedere anche
Nessuno

Descrizione

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

#!/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()
Other languages: