mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
New authoring panel for adding instances and fix bug where new cube instances were missing a face
This commit is contained in:
@@ -15,6 +15,7 @@ if bpy is not None:
|
||||
"bcf": None,
|
||||
"root": None,
|
||||
"unit": None,
|
||||
"model": None,
|
||||
"georeference": None,
|
||||
"context": None,
|
||||
"drawing": None,
|
||||
@@ -33,7 +34,6 @@ if bpy is not None:
|
||||
"material": None,
|
||||
"style": None,
|
||||
"layer": None,
|
||||
"model": None,
|
||||
"owner": None,
|
||||
"pset": None,
|
||||
"qto": None,
|
||||
@@ -87,7 +87,6 @@ if bpy is not None:
|
||||
prop.ItemSlotMap,
|
||||
prop.BIMMeshProperties,
|
||||
ui.BIM_PT_section_plane,
|
||||
ui.BIM_PT_misc_utilities,
|
||||
ui.BIM_UL_generic,
|
||||
ui.BIM_UL_topics,
|
||||
ui.BIM_ADDON_preferences,
|
||||
|
||||
@@ -93,6 +93,7 @@ class BIM_PT_ifcclash(Panel):
|
||||
class BIM_PT_clash_manager(Panel):
|
||||
bl_idname = "BIM_PT_clash_manager"
|
||||
bl_label = "Clash Manager"
|
||||
bl_options = {"DEFAULT_CLOSED"}
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
bl_category = "BlenderBIM"
|
||||
|
||||
@@ -187,6 +187,7 @@ class BIM_PT_gis(Panel):
|
||||
class BIM_PT_gis_utilities(Panel):
|
||||
bl_idname = "BIM_PT_gis_utilities"
|
||||
bl_label = "Georeferencing Utilities"
|
||||
bl_options = {"DEFAULT_CLOSED"}
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
bl_category = "BlenderBIM"
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import bpy
|
||||
from . import grid, wall, stair, door, window, slab, opening, pie
|
||||
from . import operator, ui, grid, wall, stair, door, window, slab, opening, pie
|
||||
|
||||
classes = (
|
||||
operator.AddTypeInstance,
|
||||
ui.BIM_PT_authoring,
|
||||
ui.BIM_PT_misc_utilities,
|
||||
grid.BIM_OT_add_object,
|
||||
wall.BIM_OT_add_object,
|
||||
stair.BIM_OT_add_object,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import ifcopenshell.util.type
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from mathutils import Vector
|
||||
|
||||
|
||||
class AddTypeInstance(bpy.types.Operator):
|
||||
bl_idname = "bim.add_type_instance"
|
||||
bl_label = "Add Type Instance"
|
||||
|
||||
def execute(self, context):
|
||||
tprops = context.scene.BIMTypeProperties
|
||||
if not tprops.ifc_class or not tprops.relating_type:
|
||||
return {"FINISHED"}
|
||||
# A cube
|
||||
verts = [
|
||||
Vector((-1, -1, -1)),
|
||||
Vector((-1, -1, 1)),
|
||||
Vector((-1, 1, -1)),
|
||||
Vector((-1, 1, 1)),
|
||||
Vector((1, -1, -1)),
|
||||
Vector((1, -1, 1)),
|
||||
Vector((1, 1, -1)),
|
||||
Vector((1, 1, 1)),
|
||||
]
|
||||
edges = []
|
||||
faces = [
|
||||
[0, 2, 3, 1],
|
||||
[2, 3, 7, 6],
|
||||
[4, 5, 7, 6],
|
||||
[0, 1, 5, 4],
|
||||
[1, 3, 7, 5],
|
||||
[0, 2, 6, 4],
|
||||
]
|
||||
mesh = bpy.data.meshes.new(name="Instance")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj = bpy.data.objects.new("Instance", mesh)
|
||||
obj.location = context.scene.cursor.location
|
||||
context.view_layer.active_layer_collection.collection.objects.link(obj)
|
||||
self.file = IfcStore.get_file()
|
||||
instance_class = ifcopenshell.util.type.get_applicable_entities(tprops.ifc_class, self.file.schema)[0]
|
||||
bpy.ops.bim.assign_class(obj=obj.name, ifc_class=instance_class)
|
||||
bpy.ops.bim.assign_type(relating_type=int(tprops.relating_type), related_object=obj.name)
|
||||
return {"FINISHED"}
|
||||
@@ -0,0 +1,39 @@
|
||||
from bpy.types import Panel
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class BIM_PT_authoring(Panel):
|
||||
bl_idname = "BIM_PT_authoring"
|
||||
bl_label = "Authoring"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
bl_category = "BlenderBIM"
|
||||
|
||||
def draw(self, context):
|
||||
tprops = context.scene.BIMTypeProperties
|
||||
col = self.layout.column(align=True)
|
||||
col.prop(tprops, "ifc_class", text="", icon="FILE_VOLUME")
|
||||
col.prop(tprops, "relating_type", text="", icon="FILE_3D")
|
||||
col.operator("bim.add_type_instance", icon="ADD")
|
||||
|
||||
|
||||
class BIM_PT_misc_utilities(Panel):
|
||||
bl_idname = "BIM_PT_misc_utilities"
|
||||
bl_label = "Miscellaneous"
|
||||
bl_options = {"DEFAULT_CLOSED"}
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
bl_category = "BlenderBIM"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
props = context.scene.BIMProperties
|
||||
|
||||
row = layout.row()
|
||||
row.prop(props, "override_colour", text="")
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.set_override_colour")
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.set_viewport_shadow_from_sun")
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.snap_spaces_together")
|
||||
@@ -4,6 +4,7 @@ from bpy.types import Panel
|
||||
class BIM_PT_qto_utilities(Panel):
|
||||
bl_idname = "BIM_PT_qto_utilities"
|
||||
bl_label = "Quantity Take-off"
|
||||
bl_options = {"DEFAULT_CLOSED"}
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
bl_category = "BlenderBIM"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import bpy
|
||||
from bpy.types import Panel
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
|
||||
|
||||
class BIM_PT_search(Panel):
|
||||
|
||||
@@ -7,17 +7,17 @@ classes = (
|
||||
operator.EnableEditingType,
|
||||
operator.DisableEditingType,
|
||||
operator.SelectSimilarType,
|
||||
operator.AddTypeInstance,
|
||||
prop.BIMTypeProperties,
|
||||
prop.BIMTypeObjectProperties,
|
||||
ui.BIM_PT_type,
|
||||
)
|
||||
|
||||
|
||||
def register():
|
||||
bpy.types.Object.BIMTypeProperties = bpy.props.PointerProperty(type=prop.BIMTypeProperties)
|
||||
bpy.types.VIEW3D_MT_mesh_add.append(ui.add_object_button)
|
||||
bpy.types.Scene.BIMTypeProperties = bpy.props.PointerProperty(type=prop.BIMTypeProperties)
|
||||
bpy.types.Object.BIMTypeProperties = bpy.props.PointerProperty(type=prop.BIMTypeObjectProperties)
|
||||
|
||||
|
||||
def unregister():
|
||||
del bpy.types.Scene.BIMTypeProperties
|
||||
del bpy.types.Object.BIMTypeProperties
|
||||
bpy.types.VIEW3D_MT_mesh_add.remove(ui.add_object_button)
|
||||
|
||||
@@ -5,8 +5,6 @@ import ifcopenshell.api
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from ifcopenshell.api.type.data import Data
|
||||
from ifcopenshell.api.geometry.data import Data as GeometryData
|
||||
from blenderbim.bim.module.type.prop import getIfcTypes, getAvailableTypes, updateTypeInstanceIfcClass
|
||||
from mathutils import Vector
|
||||
|
||||
|
||||
class AssignType(bpy.types.Operator):
|
||||
@@ -115,47 +113,3 @@ class SelectSimilarType(bpy.types.Operator):
|
||||
if obj.BIMObjectProperties.ifc_definition_id in related_objects:
|
||||
obj.select_set(True)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddTypeInstance(bpy.types.Operator):
|
||||
bl_idname = "bim.add_type_instance"
|
||||
bl_label = "Add Type Instance"
|
||||
ifc_class: bpy.props.EnumProperty(items=getIfcTypes, name="IFC Class", update=updateTypeInstanceIfcClass)
|
||||
relating_type: bpy.props.EnumProperty(items=getAvailableTypes, name="Relating Type")
|
||||
|
||||
def execute(self, context):
|
||||
if not self.ifc_class or not self.relating_type:
|
||||
return {"FINISHED"}
|
||||
# A cube
|
||||
verts = [
|
||||
Vector((-1, -1, -1)),
|
||||
Vector((-1, -1, 1)),
|
||||
Vector((-1, 1, -1)),
|
||||
Vector((-1, 1, 1)),
|
||||
Vector((1, -1, -1)),
|
||||
Vector((1, -1, 1)),
|
||||
Vector((1, 1, -1)),
|
||||
Vector((1, 1, 1)),
|
||||
]
|
||||
edges = []
|
||||
faces = [
|
||||
[0, 2, 3, 1],
|
||||
[2, 3, 7, 6],
|
||||
[4, 5, 7, 6],
|
||||
[0, 1, 5, 4],
|
||||
[1, 3, 7, 5],
|
||||
]
|
||||
mesh = bpy.data.meshes.new(name="Instance")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj = bpy.data.objects.new("Instance", mesh)
|
||||
obj.location = context.scene.cursor.location
|
||||
context.view_layer.active_layer_collection.collection.objects.link(obj)
|
||||
self.file = IfcStore.get_file()
|
||||
instance_class = ifcopenshell.util.type.get_applicable_entities(self.ifc_class, self.file.schema)[0]
|
||||
bpy.ops.bim.assign_class(obj=obj.name, ifc_class=instance_class)
|
||||
bpy.ops.bim.assign_type(relating_type=int(self.relating_type), related_object=obj.name)
|
||||
return {"FINISHED"}
|
||||
|
||||
def invoke(self, context, event):
|
||||
wm = context.window_manager
|
||||
return wm.invoke_props_dialog(self)
|
||||
|
||||
@@ -88,6 +88,11 @@ def updateTypeDropdowns(self, context):
|
||||
|
||||
|
||||
class BIMTypeProperties(PropertyGroup):
|
||||
ifc_class: bpy.props.EnumProperty(items=getIfcTypes, name="IFC Class", update=updateTypeInstanceIfcClass)
|
||||
relating_type: bpy.props.EnumProperty(items=getAvailableTypes, name="Relating Type")
|
||||
|
||||
|
||||
class BIMTypeObjectProperties(PropertyGroup):
|
||||
is_editing_type: BoolProperty(name="Is Editing Type", update=updateTypeDropdowns)
|
||||
relating_type_class: EnumProperty(items=getApplicableTypes, name="Relating Type Class")
|
||||
relating_type: EnumProperty(items=getRelatingTypes, name="Relating Type")
|
||||
|
||||
@@ -89,27 +89,6 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
||||
row.prop(self, "should_hide_empty_props")
|
||||
|
||||
|
||||
class BIM_PT_misc_utilities(Panel):
|
||||
bl_idname = "BIM_PT_misc_utilities"
|
||||
bl_label = "Miscellaneous"
|
||||
bl_space_type = "VIEW_3D"
|
||||
bl_region_type = "UI"
|
||||
bl_category = "BlenderBIM"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
props = context.scene.BIMProperties
|
||||
|
||||
row = layout.row()
|
||||
row.prop(props, "override_colour", text="")
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.set_override_colour")
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.set_viewport_shadow_from_sun")
|
||||
row = layout.row(align=True)
|
||||
row.operator("bim.snap_spaces_together")
|
||||
|
||||
|
||||
def ifc_units(self, context):
|
||||
scene = context.scene
|
||||
props = context.scene.BIMProperties
|
||||
|
||||
Reference in New Issue
Block a user