mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
black .
This commit is contained in:
@@ -18,11 +18,7 @@ import xml.etree.ElementTree as ET
|
|||||||
|
|
||||||
sio_port = 8080 # default port
|
sio_port = 8080 # default port
|
||||||
|
|
||||||
sio = socketio.AsyncServer(
|
sio = socketio.AsyncServer(cors_allowed_origins="*", async_mode="aiohttp", max_http_buffer_size=10000000)
|
||||||
cors_allowed_origins="*",
|
|
||||||
async_mode="aiohttp",
|
|
||||||
max_http_buffer_size=10000000
|
|
||||||
)
|
|
||||||
app = web.Application()
|
app = web.Application()
|
||||||
sio.attach(app)
|
sio.attach(app)
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ from bonsai.bim.module.geometry.decorator import ItemDecorator
|
|||||||
from typing import Optional, Union, Literal
|
from typing import Optional, Union, Literal
|
||||||
from lark import Lark, Transformer
|
from lark import Lark, Transformer
|
||||||
|
|
||||||
|
|
||||||
def create_bmesh_from_vertices(vertices, is_closed=False):
|
def create_bmesh_from_vertices(vertices, is_closed=False):
|
||||||
bm = bmesh.new()
|
bm = bmesh.new()
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ def create_bmesh_from_vertices(vertices, is_closed=False):
|
|||||||
bm.edges.index_update()
|
bm.edges.index_update()
|
||||||
return bm
|
return bm
|
||||||
|
|
||||||
|
|
||||||
def get_wall_preview_data(context, relating_type):
|
def get_wall_preview_data(context, relating_type):
|
||||||
# Get properties from object type
|
# Get properties from object type
|
||||||
model_props = context.scene.BIMModelProperties
|
model_props = context.scene.BIMModelProperties
|
||||||
@@ -185,6 +187,7 @@ def get_wall_preview_data(context, relating_type):
|
|||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def get_slab_preview_data(context, relating_type):
|
def get_slab_preview_data(context, relating_type):
|
||||||
props = context.scene.BIMModelProperties
|
props = context.scene.BIMModelProperties
|
||||||
x_angle = 0 if tool.Cad.is_x(props.x_angle, 0, tolerance=0.001) else props.x_angle
|
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 = create_bmesh_from_vertices(polyline_vertices, is_closed)
|
||||||
bm.verts.ensure_lookup_table()
|
bm.verts.ensure_lookup_table()
|
||||||
if x_angle:
|
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.contextual_create(bm, geom=bm.edges)
|
||||||
new_faces = bmesh.ops.extrude_face_region(bm, geom=bm.edges[:] + bm.faces[:])
|
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)]
|
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
|
data["tris"] = tris
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def get_vertical_profile_preview_data(context, relating_type):
|
def get_vertical_profile_preview_data(context, relating_type):
|
||||||
material = ifcopenshell.util.element.get_material(relating_type)
|
material = ifcopenshell.util.element.get_material(relating_type)
|
||||||
try:
|
try:
|
||||||
@@ -567,13 +571,13 @@ class PolylineOperator:
|
|||||||
self.snap_angle = None
|
self.snap_angle = None
|
||||||
self.snapping_points = []
|
self.snapping_points = []
|
||||||
self.instructions = {
|
self.instructions = {
|
||||||
'Cycle Input': {'icons':True, 'keys': ['EVENT_TAB']},
|
"Cycle Input": {"icons": True, "keys": ["EVENT_TAB"]},
|
||||||
'Distance Input': {'icons':True, 'keys': ['EVENT_D']},
|
"Distance Input": {"icons": True, "keys": ["EVENT_D"]},
|
||||||
'Angle Lock': {'icons':True, 'keys': ['EVENT_A']},
|
"Angle Lock": {"icons": True, "keys": ["EVENT_A"]},
|
||||||
'Increment Angle': {'icons':True, 'keys': ['EVENT_SHIFT', 'MOUSE_MMB_SCROLL']},
|
"Increment Angle": {"icons": True, "keys": ["EVENT_SHIFT", "MOUSE_MMB_SCROLL"]},
|
||||||
'Modify Snap Point': {'icons':True, 'keys': ['EVENT_M']},
|
"Modify Snap Point": {"icons": True, "keys": ["EVENT_M"]},
|
||||||
'Close Polyline': {'icons':True, 'keys': ['EVENT_C']},
|
"Close Polyline": {"icons": True, "keys": ["EVENT_C"]},
|
||||||
'Remove Point': {'icons':True, 'keys': ['EVENT_BACKSPACE']},
|
"Remove Point": {"icons": True, "keys": ["EVENT_BACKSPACE"]},
|
||||||
}
|
}
|
||||||
|
|
||||||
self.info = [
|
self.info = [
|
||||||
@@ -645,7 +649,9 @@ class PolylineOperator:
|
|||||||
self.tool_state.axis_method = None
|
self.tool_state.axis_method = None
|
||||||
tool.Blender.update_viewport()
|
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 = [
|
self.info = [
|
||||||
f"Axis: {self.tool_state.axis_method}",
|
f"Axis: {self.tool_state.axis_method}",
|
||||||
f"Plane: {self.tool_state.plane_method}",
|
f"Plane: {self.tool_state.plane_method}",
|
||||||
@@ -663,7 +669,7 @@ class PolylineOperator:
|
|||||||
self.layout.label(text=action)
|
self.layout.label(text=action)
|
||||||
else:
|
else:
|
||||||
key = settings["keys"][0]
|
key = settings["keys"][0]
|
||||||
self.layout.label(text=key+action)
|
self.layout.label(text=key + action)
|
||||||
|
|
||||||
self.layout.label(text="|")
|
self.layout.label(text="|")
|
||||||
|
|
||||||
|
|||||||
@@ -873,7 +873,6 @@ class DrawPolylineSlab(bpy.types.Operator, PolylineOperator):
|
|||||||
)
|
)
|
||||||
DumbSlabPlaner().regenerate_from_occurence(element, material_set_usage)
|
DumbSlabPlaner().regenerate_from_occurence(element, material_set_usage)
|
||||||
|
|
||||||
|
|
||||||
def modal(self, context, event):
|
def modal(self, context, event):
|
||||||
if not self.relating_type:
|
if not self.relating_type:
|
||||||
self.report({"WARNING"}, "You need to select a slab 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)]
|
props.offset_type_horizontal = items[((index + 1) % size)]
|
||||||
self.set_offset(context, self.relating_type)
|
self.set_offset(context, self.relating_type)
|
||||||
|
|
||||||
custom_instructions = {
|
custom_instructions = {"Choose Axis": {"icons": True, "keys": ["EVENT_X", "EVENT_Y"]}}
|
||||||
'Choose Axis': {'icons':True, 'keys': ['EVENT_X', 'EVENT_Y']}
|
|
||||||
}
|
|
||||||
|
|
||||||
slab_config = [
|
slab_config = [
|
||||||
f"Direction: {props.direction_sense}",
|
f"Direction: {props.direction_sense}",
|
||||||
|
|||||||
@@ -427,9 +427,7 @@ class DrawPolylineWall(bpy.types.Operator, PolylineOperator):
|
|||||||
props.offset_type_vertical = items[((index + 1) % size)]
|
props.offset_type_vertical = items[((index + 1) % size)]
|
||||||
self.set_offset(context, self.relating_type)
|
self.set_offset(context, self.relating_type)
|
||||||
|
|
||||||
custom_instructions = {
|
custom_instructions = {"Choose Axis": {"icons": True, "keys": ["EVENT_X", "EVENT_Y"]}}
|
||||||
'Choose Axis': {'icons':True, 'keys': ['EVENT_X', 'EVENT_Y']}
|
|
||||||
}
|
|
||||||
|
|
||||||
wall_config = [
|
wall_config = [
|
||||||
f"Direction: {props.direction_sense}",
|
f"Direction: {props.direction_sense}",
|
||||||
|
|||||||
@@ -2400,8 +2400,8 @@ class MeasureTool(bpy.types.Operator, PolylineOperator):
|
|||||||
return {"PASS_THROUGH"}
|
return {"PASS_THROUGH"}
|
||||||
|
|
||||||
custom_instructions = {
|
custom_instructions = {
|
||||||
'Choose Axis': {'icons':True, 'keys': ['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']},
|
"Choose Plane": {"icons": True, "keys": ["EVENT_SHIFT", "EVENT_X", "EVENT_Y", "EVENT_Z"]},
|
||||||
}
|
}
|
||||||
self.handle_instructions(context, custom_instructions)
|
self.handle_instructions(context, custom_instructions)
|
||||||
|
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ class Brick(bonsai.core.tool.Brick):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def load_brick_file(cls, filepath):
|
def load_brick_file(cls, filepath):
|
||||||
if not BrickStore.schema: # important check for running under test cases
|
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://")
|
BrickStore.graph = brickschema.persistent.VersionedGraphCollection("sqlite://")
|
||||||
with BrickStore.graph.new_changeset("SCHEMA") as cs:
|
with BrickStore.graph.new_changeset("SCHEMA") as cs:
|
||||||
cs.load_file(BrickStore.schema)
|
cs.load_file(BrickStore.schema)
|
||||||
@@ -366,7 +366,7 @@ class Brick(bonsai.core.tool.Brick):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def new_brick_file(cls):
|
def new_brick_file(cls):
|
||||||
if not BrickStore.schema: # important check for running under test cases
|
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://")
|
BrickStore.graph = brickschema.persistent.VersionedGraphCollection("sqlite://")
|
||||||
with BrickStore.graph.new_changeset("SCHEMA") as cs:
|
with BrickStore.graph.new_changeset("SCHEMA") as cs:
|
||||||
cs.load_file(BrickStore.schema)
|
cs.load_file(BrickStore.schema)
|
||||||
|
|||||||
Reference in New Issue
Block a user