mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 09:02:44 +00:00
Fix bug where copying objects did not necessarily retain the existing context assignment
This commit is contained in:
@@ -26,6 +26,7 @@ from blenderbim.tool.ifc import Ifc
|
||||
from blenderbim.tool.material import Material
|
||||
from blenderbim.tool.misc import Misc
|
||||
from blenderbim.tool.owner import Owner
|
||||
from blenderbim.tool.root import Root
|
||||
from blenderbim.tool.style import Style
|
||||
from blenderbim.tool.surveyor import Surveyor
|
||||
from blenderbim.tool.type import Type
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of BlenderBIM Add-on.
|
||||
#
|
||||
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# BlenderBIM Add-on is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import blenderbim.core.tool
|
||||
import blenderbim.core.geometry
|
||||
import blenderbim.tool as tool
|
||||
from mathutils import Vector
|
||||
|
||||
|
||||
class Root(blenderbim.core.tool.Root):
|
||||
@classmethod
|
||||
def add_dynamic_opening_voids(cls, element, obj):
|
||||
for rel in element.VoidsElements:
|
||||
building_obj = tool.Ifc.get_object(rel.RelatingBuildingElement)
|
||||
try:
|
||||
modifier = next(m for m in obj.modifiers if m.type == "BOOLEAN" and m.object == obj)
|
||||
except StopIteration:
|
||||
modifier = building_obj.modifiers.new("IfcOpeningElement", "BOOLEAN")
|
||||
modifier.object = obj
|
||||
finally:
|
||||
modifier.operation = "DIFFERENCE"
|
||||
modifier.solver = "EXACT"
|
||||
modifier.use_self = True
|
||||
modifier.operand_type = "OBJECT"
|
||||
|
||||
@classmethod
|
||||
def does_type_have_representations(cls, element):
|
||||
return bool(element.RepresentationMaps)
|
||||
|
||||
@classmethod
|
||||
def get_element_type(cls, element):
|
||||
return ifcopenshell.util.element.get_type(element)
|
||||
|
||||
@classmethod
|
||||
def get_object_context(cls, obj):
|
||||
if obj.data and obj.data.BIMMeshProperties.ifc_definition_id:
|
||||
return tool.Ifc.get().by_id(obj.data.BIMMeshProperties.ifc_definition_id).ContextOfItems
|
||||
|
||||
@classmethod
|
||||
def is_opening_element(cls, element):
|
||||
return element.is_a("IfcOpeningElement")
|
||||
|
||||
@classmethod
|
||||
def run_geometry_add_representation(cls, obj=None, context=None):
|
||||
return blenderbim.core.geometry.add_representation(
|
||||
tool.Ifc, tool.Geometry, tool.Style, tool.Surveyor, obj=obj, context=context
|
||||
)
|
||||
Reference in New Issue
Block a user