mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +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)
|
bpy.data.scenes.remove(scene)
|
||||||
|
|
||||||
links = context.scene.BIMProjectProperties.links
|
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]):
|
if not any([l.is_loaded for l in links]):
|
||||||
ProjectDecorator.uninstall()
|
ProjectDecorator.uninstall()
|
||||||
@@ -1058,14 +1062,20 @@ class LoadLink(bpy.types.Operator):
|
|||||||
def link_blend(self, filepath: str) -> None:
|
def link_blend(self, filepath: str) -> None:
|
||||||
with bpy.data.libraries.load(filepath, link=True) as (data_from, data_to):
|
with bpy.data.libraries.load(filepath, link=True) as (data_from, data_to):
|
||||||
data_to.scenes = data_from.scenes
|
data_to.scenes = data_from.scenes
|
||||||
|
link = bpy.context.scene.BIMProjectProperties.links.get(self.filepath)
|
||||||
for scene in bpy.data.scenes:
|
for scene in bpy.data.scenes:
|
||||||
if not scene.library or scene.library.filepath.replace("\\", "/") != filepath:
|
if not scene.library or scene.library.filepath.replace("\\", "/") != filepath:
|
||||||
continue
|
continue
|
||||||
for child in scene.collection.children:
|
for child in scene.collection.children:
|
||||||
if "IfcProject" not in child.name:
|
if "IfcProject" not in child.name:
|
||||||
continue
|
continue
|
||||||
bpy.data.scenes[0].collection.children.link(child)
|
empty = bpy.data.objects.new(child.name, None)
|
||||||
link = bpy.context.scene.BIMProjectProperties.links.get(self.filepath)
|
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
|
link.is_loaded = True
|
||||||
|
|
||||||
def link_ifc(self) -> Union[set[str], None]:
|
def link_ifc(self) -> Union[set[str], None]:
|
||||||
|
|||||||
@@ -111,6 +111,11 @@ class Link(PropertyGroup):
|
|||||||
is_selectable: BoolProperty(name="Is Selectable", default=True)
|
is_selectable: BoolProperty(name="Is Selectable", default=True)
|
||||||
is_wireframe: BoolProperty(name="Is Wireframe", default=False)
|
is_wireframe: BoolProperty(name="Is Wireframe", default=False)
|
||||||
is_hidden: BoolProperty(name="Is Hidden", 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):
|
class BIMProjectProperties(PropertyGroup):
|
||||||
|
|||||||
Reference in New Issue
Block a user