[Blender] Доработаны процедуры ретопологии мешей

This commit is contained in:
brothermechanic 2023-05-19 18:35:03 +00:00 committed by Igor Brylyov
parent 45e0d29ea0
commit 6560a4359d
9 changed files with 188 additions and 204 deletions

View file

@ -21,10 +21,19 @@ logging.basicConfig(level=logging.INFO)
def import_hierarchy(fc_obj, b_obj, scale):
"""FreeCAD object, Blender object, scene scale"""
if not bpy.data.collections.get('Import Hierarchy'):
hierarchy_collection = bpy.data.collections.new("Import Hierarchy")
bpy.context.scene.collection.children.link(hierarchy_collection)
bpy.context.view_layer.active_layer_collection = \
bpy.context.view_layer.layer_collection.children['Import Hierarchy']
else:
hierarchy_collection = bpy.data.collections['Import Hierarchy']
obj_parent = fc_obj.getParentGeoFeatureGroup()
obj_child_name = None
while obj_parent:
if bpy.context.scene.objects.get(obj_parent.Label):
if hierarchy_collection.objects.get(obj_parent.Label):
empty = bpy.data.objects[obj_parent.Label]
else:
bpy.ops.object.empty_add(
@ -40,11 +49,12 @@ def import_hierarchy(fc_obj, b_obj, scale):
q = (placement.Rotation.Q[3],)+placement.Rotation.Q[:3]
empty.rotation_quaternion = (q)
empty.rotation_mode = rm
if b_obj.parent:
bpy.data.objects[obj_child_name].parent = empty
else:
if not b_obj.parent:
b_obj.parent = empty
else:
bpy.data.objects[obj_child_name].parent = empty
obj_child_name = obj_parent.Label
obj_parent = obj_parent.getParentGeoFeatureGroup()
empty.select_set(False)
logger.debug('Add parent %s to object %s', empty.name, b_obj.name)