adding comments

This commit is contained in:
IDONTSUDO 2023-07-05 16:03:51 +03:00
parent 9eaf12a4fa
commit 12482ff40f
7 changed files with 102 additions and 75 deletions

View file

@ -3,6 +3,7 @@ import json
import re
from pyquaternion import Quaternion
def importObjAtPath(path: str):
import importOBJ
importOBJ.insert(u"" + path, App.ActiveDocument.Label)
@ -14,7 +15,7 @@ def getFullPathObj(assemblyFolder: str, name: str):
return assemblyFolder + 'sdf/meshes/' + name + '.obj'
def computedStabiliti(refElement, childElement):
def computedStability(refElement, childElement):
b = childElement.Shape.BoundBox
App.activeDocument().addObject("Part::MultiCommon", "Common")
App.activeDocument().Common.Shapes = [refElement, childElement, ]
@ -34,16 +35,24 @@ def computedStabiliti(refElement, childElement):
def main():
App.newDocument()
# загрузка env интерфейса
env = json.loads((open('./env.json')).read())
coordinatsFilePath = env.get('pathToTheSimulationCoordinatesFile')
assemblyFolder = env.get('generationFolder')
buildNumber = int(re.findall(r'\d', coordinatsFilePath)[0])
# получение пути координат файла
coordinatesFilePath = env.get('pathToTheSimulationCoordinatesFile')
# получение папки сборки
assemblyFolder = env.get('generationFolder')
buildNumber = int(re.findall(r'\d', coordinatesFilePath)[0])
# загрузка последовательности сборки ввиде списка строк деталей
assemblyStructure = json.loads(
(open(assemblyFolder + 'step-structure.json')).read())
# получение номера тестируемой сборки
assemblyNumber = int(buildNumber)
# получение тестируемой детали в сборке
activeDetail = assemblyStructure[assemblyNumber]
subassemblyNotParticipatingInMarkup = assemblyStructure[0:assemblyNumber - 1]
detailOfTheMarkingZoneOfWhich = assemblyStructure[assemblyNumber - 1]
importObjAtPath(getFullPathObj(assemblyFolder, activeDetail))
@ -57,22 +66,24 @@ def main():
importObjAtPath(el)
for el in App.ActiveDocument.Objects[2:App.ActiveDocument.Objects.__len__()]:
el.ViewObject.ShapeColor = (0.32, 0.05, 0.38)
coordinats = json.loads((open(coordinatsFilePath)).read())
# загрузка координат
coordinates = json.loads((open(coordinatesFilePath)).read())
inc = 1
# перемещение обьектов в документе на точки стабильность полученные из pybullet
for el in App.ActiveDocument.Objects:
pos = coordinats[inc]['position']
qua = coordinats[inc]['quaternion']
pos = coordinates[inc]['position']
qua = coordinates[inc]['quaternion']
new_quaternion = Quaternion(qua[0], qua[1], qua[2], qua[3])
rotation_matrix = new_quaternion.rotation_matrix
current_position = el.Placement.Base
new_position = App.Vector(current_position.x, current_position.y, current_position.z)
new_position = App.Vector(
current_position.x, current_position.y, current_position.z)
new_placement = App.Placement(new_position, rotation_matrix)
el.Placement = new_placement
App.ActiveDocument.recompute()
el.Placement.move(App.Vector(pos[0], pos[1], pos[2]))
print(computedStabiliti(meshMark, meshDetailOfTheMarkZone))
# вычисление стабильность
computedStability(meshMark, meshDetailOfTheMarkZone)
pass