mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
Layer set usages now inherit layer sets from the type. Walls now support material layer set usages. Also minor fixes, thanks s-leger!
This commit is contained in:
@@ -8,6 +8,9 @@ from ifcopenshell.api.attribute.data import Data as AttributeData
|
|||||||
from ifcopenshell.api.type.data import Data as TypeData
|
from ifcopenshell.api.type.data import Data as TypeData
|
||||||
|
|
||||||
|
|
||||||
|
global_subscription_owner = object()
|
||||||
|
|
||||||
|
|
||||||
def mode_callback(obj, data):
|
def mode_callback(obj, data):
|
||||||
for obj in bpy.context.selected_objects + [bpy.context.active_object]:
|
for obj in bpy.context.selected_objects + [bpy.context.active_object]:
|
||||||
if (
|
if (
|
||||||
@@ -87,6 +90,8 @@ def purge_module_data():
|
|||||||
def loadIfcStore(scene):
|
def loadIfcStore(scene):
|
||||||
IfcStore.purge()
|
IfcStore.purge()
|
||||||
ifc_file = IfcStore.get_file()
|
ifc_file = IfcStore.get_file()
|
||||||
|
if not ifc_file:
|
||||||
|
return
|
||||||
IfcStore.get_schema()
|
IfcStore.get_schema()
|
||||||
[
|
[
|
||||||
IfcStore.link_element(ifc_file.by_id(o.BIMObjectProperties.ifc_definition_id), o)
|
IfcStore.link_element(ifc_file.by_id(o.BIMObjectProperties.ifc_definition_id), o)
|
||||||
@@ -182,8 +187,11 @@ def active_object_callback():
|
|||||||
|
|
||||||
@persistent
|
@persistent
|
||||||
def setDefaultProperties(scene):
|
def setDefaultProperties(scene):
|
||||||
|
global global_subscription_owner
|
||||||
active_object_key = bpy.types.LayerObjects, "active"
|
active_object_key = bpy.types.LayerObjects, "active"
|
||||||
bpy.msgbus.subscribe_rna(key=active_object_key, owner="BlenderBIM", args=(), notify=active_object_callback)
|
bpy.msgbus.subscribe_rna(
|
||||||
|
key=active_object_key, owner=global_subscription_owner, args=(), notify=active_object_callback
|
||||||
|
)
|
||||||
ifcopenshell.api.owner.settings.get_person = (
|
ifcopenshell.api.owner.settings.get_person = (
|
||||||
lambda ifc: ifc.by_id(int(bpy.context.scene.BIMOwnerProperties.user_person))
|
lambda ifc: ifc.by_id(int(bpy.context.scene.BIMOwnerProperties.user_person))
|
||||||
if bpy.context.scene.BIMOwnerProperties.user_person
|
if bpy.context.scene.BIMOwnerProperties.user_person
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import ifcopenshell.util.unit
|
|||||||
import mathutils.geometry
|
import mathutils.geometry
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from mathutils import Vector, Matrix
|
from mathutils import Vector, Matrix
|
||||||
|
from ifcopenshell.api.material.data import Data as MaterialData
|
||||||
|
|
||||||
|
|
||||||
class AddTypeInstance(bpy.types.Operator):
|
class AddTypeInstance(bpy.types.Operator):
|
||||||
@@ -83,6 +84,9 @@ class JoinWall(bpy.types.Operator):
|
|||||||
joiner.join_L()
|
joiner.join_L()
|
||||||
elif self.join_type == "V":
|
elif self.join_type == "V":
|
||||||
joiner.join_V()
|
joiner.join_V()
|
||||||
|
IfcStore.edited_objs.add(obj)
|
||||||
|
if self.join_type != "T":
|
||||||
|
IfcStore.edited_objs.add(context.active_object)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
@@ -110,7 +114,7 @@ class AlignWall(bpy.types.Operator):
|
|||||||
|
|
||||||
|
|
||||||
def recalculate_dumb_wall_origin(wall):
|
def recalculate_dumb_wall_origin(wall):
|
||||||
new_origin = wall.matrix_world @ ((Vector(wall.bound_box[3]) + Vector(wall.bound_box[0])) / 2)
|
new_origin = wall.matrix_world @ Vector(wall.bound_box[0])
|
||||||
if (wall.matrix_world.translation - new_origin).length > 0.001:
|
if (wall.matrix_world.translation - new_origin).length > 0.001:
|
||||||
wall.data.transform(
|
wall.data.transform(
|
||||||
Matrix.Translation(
|
Matrix.Translation(
|
||||||
@@ -524,14 +528,14 @@ class DumbWallGenerator:
|
|||||||
|
|
||||||
def create_wall(self):
|
def create_wall(self):
|
||||||
verts = [
|
verts = [
|
||||||
Vector((0, self.width / 2, 0)),
|
Vector((0, self.width, 0)),
|
||||||
Vector((0, -self.width / 2, 0)),
|
Vector((0, 0, 0)),
|
||||||
Vector((0, self.width / 2, self.height)),
|
Vector((0, self.width, self.height)),
|
||||||
Vector((0, -self.width / 2, self.height)),
|
Vector((0, 0, self.height)),
|
||||||
Vector((self.length, self.width / 2, 0)),
|
Vector((self.length, self.width, 0)),
|
||||||
Vector((self.length, -self.width / 2, 0)),
|
Vector((self.length, 0, 0)),
|
||||||
Vector((self.length, self.width / 2, self.height)),
|
Vector((self.length, self.width, self.height)),
|
||||||
Vector((self.length, -self.width / 2, self.height)),
|
Vector((self.length, 0, self.height)),
|
||||||
]
|
]
|
||||||
faces = [
|
faces = [
|
||||||
[1, 3, 2, 0],
|
[1, 3, 2, 0],
|
||||||
@@ -554,4 +558,6 @@ class DumbWallGenerator:
|
|||||||
element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, Name="EPset_Parametric")
|
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, Name="EPset_Parametric")
|
||||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, Properties={"Engine": "BlenderBIM.DumbWall"})
|
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, Properties={"Engine": "BlenderBIM.DumbWall"})
|
||||||
|
ifcopenshell.api.run("material.assign_material", self.file, product=element, type="IfcMaterialLayerSetUsage")
|
||||||
|
MaterialData.load(self.file)
|
||||||
return obj
|
return obj
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ def generate_dumb_wall_axis(usecase_path, ifc_file, **settings):
|
|||||||
new_settings["context"] = axis_context
|
new_settings["context"] = axis_context
|
||||||
|
|
||||||
mesh = bpy.data.meshes.new("Temporary Axis")
|
mesh = bpy.data.meshes.new("Temporary Axis")
|
||||||
start = (Vector(obj.bound_box[3]) + Vector(obj.bound_box[0])) / 2
|
start = Vector(obj.bound_box[0])
|
||||||
end = (Vector(obj.bound_box[7]) + Vector(obj.bound_box[4])) / 2
|
end = Vector(obj.bound_box[4])
|
||||||
mesh.from_pydata([start, end], [(0, 1)], [])
|
mesh.from_pydata([start, end], [(0, 1)], [])
|
||||||
|
|
||||||
new_settings["geometry"] = mesh
|
new_settings["geometry"] = mesh
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.util.element
|
||||||
|
|
||||||
|
|
||||||
class Usecase:
|
class Usecase:
|
||||||
@@ -18,7 +19,15 @@ class Usecase:
|
|||||||
material_set = self.file.create_entity(self.settings["type"])
|
material_set = self.file.create_entity(self.settings["type"])
|
||||||
self.create_material_association(material_set)
|
self.create_material_association(material_set)
|
||||||
elif self.settings["type"] == "IfcMaterialLayerSetUsage":
|
elif self.settings["type"] == "IfcMaterialLayerSetUsage":
|
||||||
material_set = self.file.create_entity("IfcMaterialLayerSet")
|
element_type = ifcopenshell.util.element.get_type(self.settings["product"])
|
||||||
|
if element_type:
|
||||||
|
element_type_material = ifcopenshell.util.element.get_material(element_type)
|
||||||
|
if element_type_material and element_type_material.is_a("IfcMaterialLayerSet"):
|
||||||
|
material_set = element_type_material
|
||||||
|
else:
|
||||||
|
material_set = self.file.create_entity("IfcMaterialLayerSet")
|
||||||
|
else:
|
||||||
|
material_set = self.file.create_entity("IfcMaterialLayerSet")
|
||||||
material_set_usage = self.create_layer_set_usage(material_set)
|
material_set_usage = self.create_layer_set_usage(material_set)
|
||||||
self.create_material_association(material_set_usage)
|
self.create_material_association(material_set_usage)
|
||||||
elif self.settings["type"] == "IfcMaterialProfileSet":
|
elif self.settings["type"] == "IfcMaterialProfileSet":
|
||||||
|
|||||||
@@ -79,10 +79,6 @@ def get_material(element):
|
|||||||
if hasattr(relating_type, "HasAssociations") and relating_type.HasAssociations:
|
if hasattr(relating_type, "HasAssociations") and relating_type.HasAssociations:
|
||||||
for relationship in relating_type.HasAssociations:
|
for relationship in relating_type.HasAssociations:
|
||||||
if relationship.is_a("IfcRelAssociatesMaterial"):
|
if relationship.is_a("IfcRelAssociatesMaterial"):
|
||||||
if relationship.RelatingMaterial.is_a("IfcMaterialLayerSetUsage"):
|
|
||||||
return relationship.RelatingMaterial.ForLayerSet
|
|
||||||
elif relationship.RelatingMaterial.is_a("IfcMaterialProfileSetUsage"):
|
|
||||||
return relationship.RelatingMaterial.ForProfileSet
|
|
||||||
return relationship.RelatingMaterial
|
return relationship.RelatingMaterial
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user