This commit is contained in:
Andrej730
2025-09-04 10:38:20 +05:00
parent 5304072892
commit 90e6838ddb
4 changed files with 22 additions and 8 deletions
+2 -2
View File
@@ -1552,7 +1552,7 @@ class BIM_PT_snappping(Panel):
return context.mode == "OBJECT" return context.mode == "OBJECT"
def draw(self, context): def draw(self, context):
prop = context.scene.BIMSnapProperties prop = tool.Snap.get_snap_props()
layout = self.layout layout = self.layout
col = layout.column(align=True) col = layout.column(align=True)
col.prop(prop, "vertex", toggle=True, icon="SNAP_VERTEX") col.prop(prop, "vertex", toggle=True, icon="SNAP_VERTEX")
@@ -1560,7 +1560,7 @@ class BIM_PT_snappping(Panel):
col.prop(prop, "edge_center", toggle=True, icon="SNAP_MIDPOINT") col.prop(prop, "edge_center", toggle=True, icon="SNAP_MIDPOINT")
col.prop(prop, "edge_intersection", toggle=True, icon="SNAP_GRID") col.prop(prop, "edge_intersection", toggle=True, icon="SNAP_GRID")
col.prop(prop, "face", toggle=True, icon="SNAP_FACE") col.prop(prop, "face", toggle=True, icon="SNAP_FACE")
groups = context.scene.BIMSnapGroups groups = tool.Snap.get_snap_groups()
row = layout.row(align=True) row = layout.row(align=True)
row.label(text="Bonsai Target Selection") row.label(text="Bonsai Target Selection")
row = layout.row(align=True) row = layout.row(align=True)
+1 -1
View File
@@ -56,7 +56,7 @@ from collections.abc import Iterable, Callable, Generator, Sequence, Sized
if TYPE_CHECKING: if TYPE_CHECKING:
from sun_position.properties import SunPosProperties from sun_position.properties import SunPosProperties
import bpy.stub_internal.rna_enums as rna_enums import bpy.stub_internal.rna_enums as rna_enums
from bonsai.bim.prop import BIMProperties, BIMObjectProperties from bonsai.bim.prop import BIMProperties, BIMObjectProperties, BIMSnapProperties
from bonsai.bim.module.attribute.prop import BIMAttributeProperties from bonsai.bim.module.attribute.prop import BIMAttributeProperties
from bonsai.bim.module.constraint.prop import BIMConstraintProperties, BIMObjectConstraintProperties from bonsai.bim.module.constraint.prop import BIMConstraintProperties, BIMObjectConstraintProperties
from bonsai.bim.module.covetool.prop import CoveToolProperties from bonsai.bim.module.covetool.prop import CoveToolProperties
+2 -2
View File
@@ -86,8 +86,8 @@ class Ifc(bonsai.core.tool.Ifc):
@classmethod @classmethod
def get_schema(cls) -> ifcopenshell.util.schema.IFC_SCHEMA: def get_schema(cls) -> ifcopenshell.util.schema.IFC_SCHEMA:
if IfcStore.get_file(): if ifc_file := IfcStore.get_file():
return IfcStore.get_file().schema return ifc_file.schema
@classmethod @classmethod
def clear_history(cls) -> None: def clear_history(cls) -> None:
+17 -3
View File
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>. # along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
from __future__ import annotations
import bpy import bpy
import ifcopenshell import ifcopenshell
import ifcopenshell.util.unit import ifcopenshell.util.unit
@@ -26,13 +27,26 @@ import math
import mathutils import mathutils
from mathutils import Matrix, Vector from mathutils import Matrix, Vector
from lark import Lark, Transformer from lark import Lark, Transformer
from typing import Union, Any from typing import Union, Any, TYPE_CHECKING
if TYPE_CHECKING:
from bonsai.bim.prop import BIMSnapGroups, BIMSnapProperties
class Snap(bonsai.core.tool.Snap): class Snap(bonsai.core.tool.Snap):
tool_state = None tool_state = None
snap_plane_method = None snap_plane_method = None
@classmethod
def get_snap_props(cls) -> BIMSnapProperties:
assert (scene := bpy.context.scene)
return scene.BIMSnapProperties # pyright: ignore[reportAttributeAccessIssue]
@classmethod
def get_snap_groups(cls) -> BIMSnapGroups:
assert (scene := bpy.context.scene)
return scene.BIMSnapGroups # pyright: ignore[reportAttributeAccessIssue]
@classmethod @classmethod
def set_snap_plane_method(cls, value=True): def set_snap_plane_method(cls, value=True):
cls.snap_plane_method = value cls.snap_plane_method = value
@@ -484,7 +498,7 @@ class Snap(bonsai.core.tool.Snap):
def select_snapping_points(cls, context, event, tool_state, detected_snaps): def select_snapping_points(cls, context, event, tool_state, detected_snaps):
def filter_snapping_points_by_type(snapping_points): def filter_snapping_points_by_type(snapping_points):
options = ["Plane", "Axis"] options = ["Plane", "Axis"]
props = context.scene.BIMSnapProperties props = tool.Snap.get_snap_props()
for prop in props.__annotations__.keys(): for prop in props.__annotations__.keys():
if getattr(props, prop): if getattr(props, prop):
options.append(props.rna_type.properties[prop].name) options.append(props.rna_type.properties[prop].name)
@@ -494,7 +508,7 @@ class Snap(bonsai.core.tool.Snap):
def filter_snapping_points_by_group(detected_snaps): def filter_snapping_points_by_group(detected_snaps):
options = ["Wireframe", "Axis", "Plane"] options = ["Wireframe", "Axis", "Plane"]
props = context.scene.BIMSnapGroups props = tool.Snap.get_snap_groups()
for prop in props.__annotations__.keys(): for prop in props.__annotations__.keys():
if getattr(props, prop): if getattr(props, prop):
options.append(props.rna_type.properties[prop].name) options.append(props.rna_type.properties[prop].name)