framework/cg/freecad/Frames/normalEstimator

57 lines
No EOL
1.1 KiB
Text

import FreeCAD
import FreeCADGui
#creation liste piece
LP = []
#LC = ['planesParallel','circularEdge']
LP2=[]
for object in FreeCAD.ActiveDocument.Objects:
if 'objectType' in object.PropertiesList:
LP.append(object.Label)
if 'Type' in object.PropertiesList:
LP2.append(object.Object1)
LP2.append(object.Object2)
n=len(LP)
for i in range (n):
LP[i] = "b_"+str(LP[i]+"_")
print(LP)
print("le nombre de pièce= : ", len(LP))
#Matrice X
X = [0] * n
for i in range (n):
X[i] = [0] * n
#print(X)
#♣Matrice Y
Y = [0] * n
for i in range (n):
Y[i] = [0] * n
#print(Y)
#Matrice Z
Z = [0] * n
for i in range (n):
Z[i] = [0] * n
#print(Z)
#Remplisage matrice X
for k in range (0,len(LP2),2):
if k+1 < (len(LP2)) :
i=LP.index(LP2[k])
j=LP.index(LP2[k+1])
X[i][j] = 1
#print(X)
u=[0]
v=[0]
LN=[]
for object in FreeCAD.ActiveDocument.Objects:
if 'Type' not in object.PropertiesList:
maFace = object.Shape.Face[1]
myNormal = maFace.normalAt (u, v)
LN.append(myNormal)