файлы для работы над верстаком разметки
This commit is contained in:
parent
04270f214a
commit
136279f3e9
3 changed files with 145 additions and 0 deletions
81
cg/freecad/Frames/import FreeCAD.py
Normal file
81
cg/freecad/Frames/import FreeCAD.py
Normal file
|
@ -0,0 +1,81 @@
|
|||
import FreeCAD
|
||||
import Part
|
||||
import ImportGui
|
||||
|
||||
class GeometryValidateUseCase:
|
||||
def __init__(self):
|
||||
self.doc = None
|
||||
|
||||
|
||||
|
||||
|
||||
def import_step_and_check(self, file_path):
|
||||
# Очистить сцену перед импортом новой сборки
|
||||
FreeCAD.closeDocument("Unnamed")
|
||||
|
||||
# Создать новый документ FreeCAD
|
||||
self.doc = FreeCAD.newDocument("Unnamed")
|
||||
|
||||
# Импортируйте STEP-файл
|
||||
ImportGui.open(file_path, "Unnamed")
|
||||
|
||||
# Отобразите объект в 3D-виде
|
||||
FreeCAD.ActiveDocument.recompute()
|
||||
Gui.SendMsgToActiveView("ViewFit")
|
||||
|
||||
# Получить список тел в сборке
|
||||
bodies = getBodies(self.doc)
|
||||
|
||||
# Проверить пересечения между телами
|
||||
intersections = self.check_intersections(bodies)
|
||||
self.print_intersections(intersections)
|
||||
|
||||
# Проверить тела на нулевой объем
|
||||
zero_volume_bodies = self.check_zero_volume(bodies)
|
||||
self.print_zero_volume(zero_volume_bodies)
|
||||
|
||||
# Сохранить документ
|
||||
self.save_checked_document(file_path)
|
||||
|
||||
|
||||
def getBodies(doc):
|
||||
bodies = []
|
||||
for obj in doc.Objects:
|
||||
if hasattr(obj, 'TypeId') and obj.TypeId == "Part::Feature":
|
||||
bodies.append(obj)
|
||||
return bodies
|
||||
|
||||
|
||||
|
||||
def check_intersections(self, bodies):
|
||||
intersections = []
|
||||
for i in range(len(bodies)):
|
||||
for j in range(i + 1, len(bodies)):
|
||||
if bodies[i].intersects(bodies[j]):
|
||||
intersections.append((i + 1, j + 1))
|
||||
return intersections
|
||||
|
||||
def check_zero_volume(self, bodies):
|
||||
zero_volume_bodies = [i + 1 for i, body in enumerate(bodies) if body.Volume == 0]
|
||||
return zero_volume_bodies
|
||||
|
||||
def print_intersections(self, intersections):
|
||||
for i, j in intersections:
|
||||
print("Тела пересекаются: Body {} и Body {}".format(i, j))
|
||||
|
||||
def print_zero_volume(self, zero_volume_bodies):
|
||||
for i in zero_volume_bodies:
|
||||
print("Тело {} имеет нулевой объем".format(i))
|
||||
|
||||
def save_checked_document(self, original_file_path):
|
||||
checked_file_path = original_file_path.replace(".step", "_checked.FCStd")
|
||||
FreeCAD.saveDocument(self.doc, checked_file_path)
|
||||
print("Проверенная сборка сохранена в файл:", checked_file_path)
|
||||
FreeCAD.closeDocument("Unnamed")
|
||||
|
||||
|
||||
|
||||
use_case = GeometryValidateUseCase()
|
||||
step_file_path = "/home/mark-voltov/Загрузки/Telegram Desktop/test_asm.STEP"
|
||||
use_case.import_step_and_check(step_file_path)
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
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)
|
7
markup_workbench/env.json
Normal file
7
markup_workbench/env.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"aspPath":"/home/mark-voltov/Рабочий стол/out/",
|
||||
"gripperName": "Gripper01"
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue