Экспорт подсборок с мешами (SDF) и плана сборки (PDDL) из FreeCAD в виде архива zip
This commit is contained in:
parent
7f13c0056f
commit
e65236aab6
37 changed files with 1022 additions and 176 deletions
63
cg/freecad/Frames/usecases/get_sdf_geometry_usecase.py
Normal file
63
cg/freecad/Frames/usecases/get_sdf_geometry_usecase.py
Normal file
|
@ -0,0 +1,63 @@
|
|||
import FreeCAD as App
|
||||
from model.sdf_geometry_model import SdfGeometryModel
|
||||
|
||||
from helper.is_solid import is_object_solid
|
||||
|
||||
|
||||
class SdfGeometryUseCase:
|
||||
def call(stlPaths:dict) -> list[SdfGeometryModel]:
|
||||
materialSolid = {}
|
||||
for el in App.ActiveDocument.Objects:
|
||||
if str(el) == '<App::MaterialObjectPython object>':
|
||||
friction = el.Material.get('SlidingFriction')
|
||||
for i in el.References:
|
||||
materialSolid[i[0].Label] = friction
|
||||
geometry = []
|
||||
for el in App.ActiveDocument.Objects:
|
||||
if is_object_solid(el):
|
||||
com = el.Shape.CenterOfMass
|
||||
mass = el.Shape.Mass
|
||||
inertia = el.Shape.MatrixOfInertia
|
||||
pos = el.Shape.Placement
|
||||
inertia = el.Shape.MatrixOfInertia
|
||||
name = el.Label
|
||||
ixx = str(inertia.A11 / 1000000)
|
||||
ixy = str(inertia.A12 / 1000000)
|
||||
ixz = str(inertia.A13 / 1000000)
|
||||
iyy = str(inertia.A22 / 1000000)
|
||||
iyz = str(inertia.A23 / 1000000)
|
||||
izz = str(inertia.A33 / 1000000)
|
||||
massSDF = str(mass / 1000000)
|
||||
posX = str(pos.Base[0] / 1000000)
|
||||
posY = str(pos.Base[1] / 1000000)
|
||||
posZ = str(pos.Base[2] / 1000000)
|
||||
eulerX = str(pos.Rotation.toEuler()[0])
|
||||
eulerY = str(pos.Rotation.toEuler()[1])
|
||||
eulerZ = str(pos.Rotation.toEuler()[2])
|
||||
|
||||
geometry.append(
|
||||
SdfGeometryModel(
|
||||
stl=stlPaths.get(el.Label),
|
||||
name=name,
|
||||
ixx=ixx,
|
||||
ixz=ixz,
|
||||
ixy=ixy,
|
||||
iyy=iyy,
|
||||
iyz=iyz,
|
||||
izz=izz,
|
||||
massSDF=massSDF,
|
||||
posX=posX,
|
||||
posY=posY,
|
||||
posZ=posZ,
|
||||
eulerX=eulerX,
|
||||
eulerY=eulerY,
|
||||
eulerZ=eulerZ,
|
||||
friction=materialSolid.get(el.Label) or '',
|
||||
)
|
||||
)
|
||||
return geometry
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue