Macro JointWire/fr: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
(Updating to match new version of source page)
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
<languages/>
<languages/>
{{VeryImportantMessage|!!! This macro needs to be corrected. !!!}}
{{VeryImportantMessage|!!! This macro needs to be corrected. !!!}}
<div class="mw-translate-fuzzy">
{{Macro/fr
{{Macro/fr
|Name=JointWire
|Name=JointWire
|Icon=Macro_JointWire.png
|Description=Cette macro permet de trouver et de mettre en collaboration, à l'aide d'une ligne tous les bords non connectés, avec le plus proche non connecté. Il faudra une entrée sous forme d'une matrice ([shape1, shape2,...])
|Description={{ColoredText|#ff0000|!!! This macro needs to be corrected. !!!}}<br/>Cette macro permet de trouver et de mettre en collaboration, à l'aide d'une ligne tous les bords non connectés, avec le plus proche non connecté. Il faudra une entrée sous forme d'une matrice ([shape1, shape2,...])
|Author=Tremblou
|Author=Tremblou
|Version=1.0
|Version=1.0
|Date=2011-08-24
|Date=2011-08-24
|FCVersion=All
|Download=[https://www.freecadweb.org/wiki/images/b/bb/Macro_JointWire.png ToolBar Icon]
}}
}}
</div>


==Description==
==Description==
Line 20: Line 21:
'''Macro_JointWire.FCMacro'''
'''Macro_JointWire.FCMacro'''


{{Code|code=
{{MacroCode|code=


def findWires(edges):
def findWires(edges):

Revision as of 11:06, 23 May 2020

!!! This macro needs to be corrected. !!!

JointWire

Description
!!! This macro needs to be corrected. !!!
Cette macro permet de trouver et de mettre en collaboration, à l'aide d'une ligne tous les bords non connectés, avec le plus proche non connecté. Il faudra une entrée sous forme d'une matrice ([shape1, shape2,...])

Version macro : 1.0
Date dernière modification : 2011-08-24
Version FreeCAD : All
Téléchargement : ToolBar Icon
Auteur: Tremblou
Auteur
Tremblou
Téléchargement
ToolBar Icon
Liens
Version Macro
1.0
Dernière modification
2011-08-24
Version(s) FreeCAD
All
Raccourci clavier
None
Voir aussi
None

Description

Cette macro permet de trouver et de mettre en collaboration, à l'aide d'une ligne tous les bords non connectés, avec le plus proche non connecté. Il faudra une entrée sous forme d'une matrice ([shape1, shape2,...])

Script

ToolBar Icon

Macro_JointWire.FCMacro

def findWires(edges):
    def verts(shape):
                return [shape.Vertexes[0].Point,shape.Vertexes[-1].Point]
        def group(shapes):
                shapesIn = shapes[:]
                pointTst = []
        pointOut =[]
        for s in shapesIn :
            pointTst=pointTst+[s.Vertexes[0].Point]
            pointTst=pointTst+[s.Vertexes[-1].Point]
        print pointTst               
        changed = False
                for s in shapesIn:
                        if len(s.Vertexes) < 2:
                print "one vertex, its a circle, just add"
                        else:                             
                                for v in verts(s):
                    twoDot=0
                                        for vv in pointTst:
                                                if v == vv:
                            twoDot=twoDot+1                           
                        if v==vv and twoDot==2 :                   
                            changed = True
                            print "found matching vert"
                            break
                                    if twoDot<2:
                        print "didn't find any matching vert..."
                        pointOut.append(v)
         print "Dots non connected", pointOut
                return(changed,pointOut)
    def joint(point):
        for p in range(len(point)/2) :
            print point
            deltI=Part.Vertex(100,100,100).Point
            pos=1
            for pp in range(len(point)-1) :
                print "position:",pp+1
                if len(point)-1>1:
                    deltN=(point[0]-point[pp+1])
                    if deltN.Length<deltI.Length:
                        deltI=deltN
                        pos=pp+1
                        print "changement",pos
                else:
                    pos=1   
            print "points a joindre",point[0],point[pos]
            if point[0]!=point[pos]:
                Part.show(Part.makePolygon([point[0],point[pos]]))
            else:
                print "WARNING les points ont la meme valeurs "
            point.pop(0)
            point.pop(pos-1)
        point=0 #to have a return normally void
        return(point)
    working = True
        edgeSet = edges
    result = group(edgeSet)
        working = result[0]
        edgeSet = result[1]
    joint(result[1])
        return result[1]