This commit is contained in:
Andrej730
2025-01-24 12:25:10 +05:00
parent 35d20e649d
commit c12636f4cc
6 changed files with 27 additions and 30 deletions
@@ -18,11 +18,7 @@ import xml.etree.ElementTree as ET
sio_port = 8080 # default port
sio = socketio.AsyncServer(
cors_allowed_origins="*",
async_mode="aiohttp",
max_http_buffer_size=10000000
)
sio = socketio.AsyncServer(cors_allowed_origins="*", async_mode="aiohttp", max_http_buffer_size=10000000)
app = web.Application()
sio.attach(app)
+20 -14
View File
@@ -43,6 +43,7 @@ from bonsai.bim.module.geometry.decorator import ItemDecorator
from typing import Optional, Union, Literal
from lark import Lark, Transformer
def create_bmesh_from_vertices(vertices, is_closed=False):
bm = bmesh.new()
@@ -59,6 +60,7 @@ def create_bmesh_from_vertices(vertices, is_closed=False):
bm.edges.index_update()
return bm
def get_wall_preview_data(context, relating_type):
# Get properties from object type
model_props = context.scene.BIMModelProperties
@@ -185,6 +187,7 @@ def get_wall_preview_data(context, relating_type):
return data
def get_slab_preview_data(context, relating_type):
props = context.scene.BIMModelProperties
x_angle = 0 if tool.Cad.is_x(props.x_angle, 0, tolerance=0.001) else props.x_angle
@@ -235,7 +238,7 @@ def get_slab_preview_data(context, relating_type):
bm = create_bmesh_from_vertices(polyline_vertices, is_closed)
bm.verts.ensure_lookup_table()
if x_angle:
bmesh.ops.rotate(bm, cent=Vector(bm.verts[0].co), verts=bm.verts, matrix=Matrix.Rotation(x_angle, 3, 'X'))
bmesh.ops.rotate(bm, cent=Vector(bm.verts[0].co), verts=bm.verts, matrix=Matrix.Rotation(x_angle, 3, "X"))
new_faces = bmesh.ops.contextual_create(bm, geom=bm.edges)
new_faces = bmesh.ops.extrude_face_region(bm, geom=bm.edges[:] + bm.faces[:])
new_verts = [e for e in new_faces["geom"] if isinstance(e, bmesh.types.BMVert)]
@@ -250,6 +253,7 @@ def get_slab_preview_data(context, relating_type):
data["tris"] = tris
return data
def get_vertical_profile_preview_data(context, relating_type):
material = ifcopenshell.util.element.get_material(relating_type)
try:
@@ -567,16 +571,16 @@ class PolylineOperator:
self.snap_angle = None
self.snapping_points = []
self.instructions = {
'Cycle Input': {'icons':True, 'keys': ['EVENT_TAB']},
'Distance Input': {'icons':True, 'keys': ['EVENT_D']},
'Angle Lock': {'icons':True, 'keys': ['EVENT_A']},
'Increment Angle': {'icons':True, 'keys': ['EVENT_SHIFT', 'MOUSE_MMB_SCROLL']},
'Modify Snap Point': {'icons':True, 'keys': ['EVENT_M']},
'Close Polyline': {'icons':True, 'keys': ['EVENT_C']},
'Remove Point': {'icons':True, 'keys': ['EVENT_BACKSPACE']},
"Cycle Input": {"icons": True, "keys": ["EVENT_TAB"]},
"Distance Input": {"icons": True, "keys": ["EVENT_D"]},
"Angle Lock": {"icons": True, "keys": ["EVENT_A"]},
"Increment Angle": {"icons": True, "keys": ["EVENT_SHIFT", "MOUSE_MMB_SCROLL"]},
"Modify Snap Point": {"icons": True, "keys": ["EVENT_M"]},
"Close Polyline": {"icons": True, "keys": ["EVENT_C"]},
"Remove Point": {"icons": True, "keys": ["EVENT_BACKSPACE"]},
}
self.info = [
self.info = [
"Axis: ",
"Plane: ",
"Snap: ",
@@ -645,7 +649,9 @@ class PolylineOperator:
self.tool_state.axis_method = None
tool.Blender.update_viewport()
def handle_instructions(self, context: bpy.types.Context, custom_instructions: dict = {}, custom_info: str = "") -> None:
def handle_instructions(
self, context: bpy.types.Context, custom_instructions: dict = {}, custom_info: str = ""
) -> None:
self.info = [
f"Axis: {self.tool_state.axis_method}",
f"Plane: {self.tool_state.plane_method}",
@@ -663,7 +669,7 @@ class PolylineOperator:
self.layout.label(text=action)
else:
key = settings["keys"][0]
self.layout.label(text=key+action)
self.layout.label(text=key + action)
self.layout.label(text="|")
@@ -910,9 +916,9 @@ class PolylineOperator:
def set_offset(self, context: bpy.types.Context, relating_type: ifcopenshell.entity_instance) -> None:
props = bpy.context.scene.BIMModelProperties
if tool.Model.get_usage_type(relating_type) == "LAYER2":
offset_type = "offset_type_vertical"
offset_type = "offset_type_vertical"
elif tool.Model.get_usage_type(relating_type) == "LAYER3":
offset_type = "offset_type_horizontal"
offset_type = "offset_type_horizontal"
else:
return
@@ -926,7 +932,7 @@ class PolylineOperator:
props.offset = self.offset / self.unit_scale
tool.Blender.update_viewport()
def modal(self, context: bpy.types.Context, event: bpy.types.Event) -> Union[set[str], None]:
PolylineDecorator.update(event, self.tool_state, self.input_ui, self.snapping_points[0])
tool.Blender.update_viewport()
+1 -4
View File
@@ -873,7 +873,6 @@ class DrawPolylineSlab(bpy.types.Operator, PolylineOperator):
)
DumbSlabPlaner().regenerate_from_occurence(element, material_set_usage)
def modal(self, context, event):
if not self.relating_type:
self.report({"WARNING"}, "You need to select a slab type.")
@@ -904,9 +903,7 @@ class DrawPolylineSlab(bpy.types.Operator, PolylineOperator):
props.offset_type_horizontal = items[((index + 1) % size)]
self.set_offset(context, self.relating_type)
custom_instructions = {
'Choose Axis': {'icons':True, 'keys': ['EVENT_X', 'EVENT_Y']}
}
custom_instructions = {"Choose Axis": {"icons": True, "keys": ["EVENT_X", "EVENT_Y"]}}
slab_config = [
f"Direction: {props.direction_sense}",
+1 -3
View File
@@ -427,9 +427,7 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
props.offset_type_vertical = items[((index + 1) % size)]
self.set_offset(context, self.relating_type)
custom_instructions = {
'Choose Axis': {'icons':True, 'keys': ['EVENT_X', 'EVENT_Y']}
}
custom_instructions = {"Choose Axis": {"icons": True, "keys": ["EVENT_X", "EVENT_Y"]}}
wall_config = [
f"Direction: {props.direction_sense}",
@@ -2400,8 +2400,8 @@ class MeasureTool(bpy.types.Operator, PolylineOperator):
return {"PASS_THROUGH"}
custom_instructions = {
'Choose Axis': {'icons':True, 'keys': ['EVENT_X', 'EVENT_Y', 'EVENT_Z']},
'Choose Plane': {'icons':True, 'keys': ['EVENT_SHIFT', 'EVENT_X', 'EVENT_Y', 'EVENT_Z']},
"Choose Axis": {"icons": True, "keys": ["EVENT_X", "EVENT_Y", "EVENT_Z"]},
"Choose Plane": {"icons": True, "keys": ["EVENT_SHIFT", "EVENT_X", "EVENT_Y", "EVENT_Z"]},
}
self.handle_instructions(context, custom_instructions)
+2 -2
View File
@@ -350,7 +350,7 @@ class Brick(bonsai.core.tool.Brick):
@classmethod
def load_brick_file(cls, filepath):
if not BrickStore.schema: # important check for running under test cases
BrickStore.schema = tool.Blender.get_data_dir_path(Path('brick', 'Brick.ttl'))
BrickStore.schema = tool.Blender.get_data_dir_path(Path("brick", "Brick.ttl"))
BrickStore.graph = brickschema.persistent.VersionedGraphCollection("sqlite://")
with BrickStore.graph.new_changeset("SCHEMA") as cs:
cs.load_file(BrickStore.schema)
@@ -366,7 +366,7 @@ class Brick(bonsai.core.tool.Brick):
@classmethod
def new_brick_file(cls):
if not BrickStore.schema: # important check for running under test cases
BrickStore.schema = tool.Blender.get_data_dir_path(Path('brick', 'Brick.ttl'))
BrickStore.schema = tool.Blender.get_data_dir_path(Path("brick", "Brick.ttl"))
BrickStore.graph = brickschema.persistent.VersionedGraphCollection("sqlite://")
with BrickStore.graph.new_changeset("SCHEMA") as cs:
cs.load_file(BrickStore.schema)