Сброшены трансформации в asp_sdf_to_asset.py и унифицированы за счет freecad_to_asset.py
This commit is contained in:
parent
748fcd1351
commit
1ea7e50ecd
8 changed files with 116 additions and 121 deletions
49
cg/blender/utils/sdf_mesh_selector.py
Normal file
49
cg/blender/utils/sdf_mesh_selector.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
DESCRIPTION.
|
||||
Subassembly models setup from SDFormat file.
|
||||
Script selected subassembly models.
|
||||
Support Blender compiled as a Python Module only!
|
||||
"""
|
||||
__version__ = "0.1"
|
||||
|
||||
import logging
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
import os
|
||||
sys.path.append('../')
|
||||
from import_fcstd.importer import importer
|
||||
from mathutils import Matrix
|
||||
from utils.remove_collections import remove_collections
|
||||
from utils.cleanup_orphan_data import cleanup_orphan_data
|
||||
from remesh import asset_setup
|
||||
from export.stl import export_stl
|
||||
import bpy
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
def sdf_mesh_selector(sdf_path):
|
||||
""" Setup scene by SDFormat file description """
|
||||
mytree = ET.parse(sdf_path)
|
||||
myroot = mytree.getroot()
|
||||
|
||||
models_transforms = {}
|
||||
for models in myroot.iter('model'):
|
||||
for models_childs in models:
|
||||
if models_childs.find('pose') is not None:
|
||||
pose = models_childs.find('pose').text
|
||||
logger.debug(models.attrib['name'], pose)
|
||||
pose_vectors = [float(x) * 0.001 for x in pose.split()]
|
||||
models_transforms[models.attrib['name']] = pose_vectors
|
||||
|
||||
# TODO More cleanup and optimise
|
||||
# TODO add models <==> objects compare validation
|
||||
|
||||
for obj in bpy.context.scene.objects:
|
||||
if obj.name in models_transforms:
|
||||
obj.matrix_world = Matrix()
|
||||
else:
|
||||
bpy.data.objects.remove(bpy.data.objects[obj.name], do_unlink=True)
|
||||
logger.info(obj.name, '- is not in assemly objects. Deleted!')
|
Loading…
Add table
Add a link
Reference in a new issue