mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Support for moving/rotating/scaling for linked models
Example - https://imgchest.com/p/lqye6da2z4d
This commit is contained in:
@@ -1021,7 +1021,11 @@ class UnloadLink(bpy.types.Operator):
|
||||
bpy.data.scenes.remove(scene)
|
||||
|
||||
links = context.scene.BIMProjectProperties.links
|
||||
links.get(self.filepath).is_loaded = False
|
||||
link = links.get(self.filepath)
|
||||
# Let's assume that user might delete it.
|
||||
if empty_handle := link.empty_handle:
|
||||
bpy.data.objects.remove(empty_handle)
|
||||
link.is_loaded = False
|
||||
|
||||
if not any([l.is_loaded for l in links]):
|
||||
ProjectDecorator.uninstall()
|
||||
@@ -1058,14 +1062,20 @@ class LoadLink(bpy.types.Operator):
|
||||
def link_blend(self, filepath: str) -> None:
|
||||
with bpy.data.libraries.load(filepath, link=True) as (data_from, data_to):
|
||||
data_to.scenes = data_from.scenes
|
||||
link = bpy.context.scene.BIMProjectProperties.links.get(self.filepath)
|
||||
for scene in bpy.data.scenes:
|
||||
if not scene.library or scene.library.filepath.replace("\\", "/") != filepath:
|
||||
continue
|
||||
for child in scene.collection.children:
|
||||
if "IfcProject" not in child.name:
|
||||
continue
|
||||
bpy.data.scenes[0].collection.children.link(child)
|
||||
link = bpy.context.scene.BIMProjectProperties.links.get(self.filepath)
|
||||
empty = bpy.data.objects.new(child.name, None)
|
||||
empty.instance_type = "COLLECTION"
|
||||
empty.instance_collection = child
|
||||
link.empty_handle = empty
|
||||
bpy.context.scene.collection.objects.link(empty)
|
||||
break
|
||||
break
|
||||
link.is_loaded = True
|
||||
|
||||
def link_ifc(self) -> Union[set[str], None]:
|
||||
|
||||
@@ -111,6 +111,11 @@ class Link(PropertyGroup):
|
||||
is_selectable: BoolProperty(name="Is Selectable", default=True)
|
||||
is_wireframe: BoolProperty(name="Is Wireframe", default=False)
|
||||
is_hidden: BoolProperty(name="Is Hidden", default=False)
|
||||
empty_handle: PointerProperty(
|
||||
name="Empty Object Handle",
|
||||
description="We use empty object handle to allow simple manipulations with a linked model (moving, scaling, rotating)",
|
||||
type=bpy.types.Object,
|
||||
)
|
||||
|
||||
|
||||
class BIMProjectProperties(PropertyGroup):
|
||||
|
||||
Reference in New Issue
Block a user