Get batting thickness from decorator data

This commit is contained in:
Dion Moult
2023-03-02 19:01:40 +11:00
parent 1fca38625f
commit e5885db187
2 changed files with 27 additions and 2 deletions
@@ -17,6 +17,7 @@
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import bpy
import ifcopenshell.util.element
import ifcopenshell.util.representation
import blenderbim.tool as tool
@@ -27,6 +28,7 @@ def refresh():
SheetsData.is_loaded = False
SchedulesData.is_loaded = False
DrawingsData.is_loaded = False
DecoratorData.data = {}
class ProductAssignmentsData:
@@ -121,3 +123,19 @@ class SchedulesData:
@classmethod
def total_schedules(cls):
return len([d for d in tool.Ifc.get().by_type("IfcDocumentInformation") if d.Scope == "SCHEDULE"])
class DecoratorData:
data = {}
@classmethod
def get_batting_thickness(cls, obj):
result = cls.data.get(obj.name, None)
if result is not None:
return result
element = tool.Ifc.get_entity(obj)
if element:
result = ifcopenshell.util.element.get_pset(element, "BBIM_Batting", "Thickness") or 5.0
cls.data[obj.name] = result
return result
return 5.0
@@ -26,6 +26,7 @@ import bmesh
import ifcopenshell
import blenderbim.tool as tool
import blenderbim.bim.module.drawing.helper as helper
from math import acos, pi
from functools import reduce
from itertools import chain
from bpy.types import SpaceView3D
@@ -33,7 +34,7 @@ from mathutils import Vector, Matrix
from bpy_extras.view3d_utils import location_3d_to_region_2d
from gpu.types import GPUShader, GPUBatch, GPUIndexBuf, GPUVertBuf, GPUVertFormat
from gpu_extras.batch import batch_for_shader
from math import acos, pi
from blenderbim.bim.module.drawing.data import DecoratorData
def ccw(A, B, C):
@@ -1423,7 +1424,13 @@ class BattingDecorator(BaseDecorator):
verts, idxs = self.get_editmesh_geom(obj)
else:
verts, idxs = self.get_mesh_geom(obj)
self.draw_lines(context, obj, verts[:2], idxs, extra_float_kwargs={"batting_thickness": 32.0})
self.draw_lines(
context,
obj,
verts[:2],
idxs,
extra_float_kwargs={"batting_thickness": DecoratorData.get_batting_thickness(obj)},
)
class GridDecorator(BaseDecorator):