Merge branch 'v0.7.0' of https://github.com/c4rlosdias/IfcOpenShell into v0.7.0

This commit is contained in:
c4rlosdias
2023-10-02 13:49:32 -03:00
21 changed files with 1874 additions and 105 deletions
@@ -0,0 +1,23 @@
ISO-10303-21;
HEADER;
FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');
FILE_NAME('','2023-09-28T23:00:50',(),(),'IfcOpenShell v0.7.0-fbd8ea1ed','IfcOpenShell v0.7.0-fbd8ea1ed','');
FILE_SCHEMA(('IFC4'));
ENDSEC;
DATA;
#1=IFCPROPERTYSETTEMPLATE('1TLQmgUKf0I8Zi07bm9Jqn',$,'ePSet_ProjectedCRS','',.PSET_OCCURRENCEDRIVEN.,'IfcProject',(#2,#3,#4,#5,#6,#7));
#2=IFCSIMPLEPROPERTYTEMPLATE('2cH53PtVT3v88uf_uGFblG',$,'Name','',.P_SINGLEVALUE.,'IfcLabel',$,$,$,$,$,.READWRITE.);
#3=IFCSIMPLEPROPERTYTEMPLATE('3JsReA6vXDqR7aNC$haRYW',$,'Description','',.P_SINGLEVALUE.,'IfcText',$,$,$,$,$,.READWRITE.);
#4=IFCSIMPLEPROPERTYTEMPLATE('0u0uEsT5HFtuX5GvozO9ba',$,'GeodeticDatum','',.P_SINGLEVALUE.,'IfcIdentifier',$,$,$,$,$,.READWRITE.);
#5=IFCSIMPLEPROPERTYTEMPLATE('1JgEX9Fsf0$ggxYltdkqiY',$,'VerticalDatum','',.P_SINGLEVALUE.,'IfcIdentifier',$,$,$,$,$,.READWRITE.);
#6=IFCSIMPLEPROPERTYTEMPLATE('3ahTZjYrD0MAOo5IH6QuGH',$,'MapProjection','',.P_SINGLEVALUE.,'IfcIdentifier',$,$,$,$,$,.READWRITE.);
#7=IFCSIMPLEPROPERTYTEMPLATE('3hqJR2ghD0GAti7q4sXKj7',$,'MapZone','',.P_SINGLEVALUE.,'IfcIdentifier',$,$,$,$,$,.READWRITE.);
#8=IFCPROPERTYSETTEMPLATE('1jGHTycOj0vA8xHfRl4TNs',$,'ePSet_MapConversion','',.PSET_OCCURRENCEDRIVEN.,'IfcProject',(#9,#10,#11,#12,#13,#15));
#9=IFCSIMPLEPROPERTYTEMPLATE('0nxsULXo17JRrAvNteYtNR',$,'Eastings','',.P_SINGLEVALUE.,'IfcLengthMeasure',$,$,$,$,$,.READWRITE.);
#10=IFCSIMPLEPROPERTYTEMPLATE('26RfaGJs5CqemN0Xin12XL',$,'Northings','',.P_SINGLEVALUE.,'IfcLengthMeasure',$,$,$,$,$,.READWRITE.);
#11=IFCSIMPLEPROPERTYTEMPLATE('0ziCn3nZv3m850VEUwWH42',$,'OrthogonalHeight','',.P_SINGLEVALUE.,'IfcLengthMeasure',$,$,$,$,$,.READWRITE.);
#12=IFCSIMPLEPROPERTYTEMPLATE('3d4BOt4In8WR119ms1SaAe',$,'XAxisAbscissa','',.P_SINGLEVALUE.,'IfcReal',$,$,$,$,$,.READWRITE.);
#13=IFCSIMPLEPROPERTYTEMPLATE('1Q4Voqj2j84RQRI8l67m28',$,'XAxisOrdinate','',.P_SINGLEVALUE.,'IfcReal',$,$,$,$,$,.READWRITE.);
#15=IFCSIMPLEPROPERTYTEMPLATE('0O1Hc0$XnDNOG_jPBmbW5r',$,'Scale','',.P_SINGLEVALUE.,'IfcReal',$,$,$,$,$,.READWRITE.);
ENDSEC;
END-ISO-10303-21;
@@ -748,7 +748,6 @@ class EditOpenings(Operator, tool.Ifc.Operator):
building_objs = set()
model = tool.Ifc.get()
all_openings = model.by_type("IfcOpeningElement")
similar_openings = []
for obj in context.selected_objects:
element = tool.Ifc.get_entity(obj)
@@ -756,9 +755,7 @@ class EditOpenings(Operator, tool.Ifc.Operator):
continue
openings = [r.RelatedOpeningElement for r in element.HasOpenings]
for opening in openings:
for all_opening in all_openings:
if all_opening.ObjectPlacement == opening.ObjectPlacement:
similar_openings.append(all_opening)
similar_openings = [o for o in all_openings if o.ObjectPlacement == opening.ObjectPlacement]
opening_obj = tool.Ifc.get_object(opening)
if opening_obj:
if tool.Ifc.is_edited(opening_obj):
@@ -81,8 +81,9 @@ def update_simple_openings(element, opening_width, opening_height):
has_replaced_opening_representation = True
tool.Model.reload_body_representation(voided_objs)
with bpy.context.temp_override(selected_objects=[tool.Ifc.get_object(f) for f in fillings]):
bpy.ops.bim.recalculate_fill()
if fillings:
with bpy.context.temp_override(selected_objects=[tool.Ifc.get_object(f) for f in fillings]):
bpy.ops.bim.recalculate_fill()
def update_window_modifier_representation(context, obj):
@@ -37,6 +37,7 @@ classes = (
operator.LoadProjectElements,
operator.NewProject,
operator.RefreshLibrary,
operator.RevertProject,
operator.RewindLibrary,
operator.SaveLibraryFile,
operator.SelectLibraryFile,
@@ -676,6 +676,24 @@ class UnloadProject(bpy.types.Operator):
return {"FINISHED"}
class RevertProject(bpy.types.Operator, IFCFileSelector):
bl_idname = "bim.revert_project"
bl_label = "Revert IFC Project"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Reload currently opened IFC project discarding all unsaved changes"
@classmethod
def poll(cls, context):
if not context.scene.BIMProperties.ifc_file:
cls.poll_message_set("IFC project need to be loaded and saved on the disk.")
return False
return True
def execute(self, context):
bpy.ops.bim.load_project(should_start_fresh_session=True, filepath=context.scene.BIMProperties.ifc_file)
return {"FINISHED"}
class LoadProjectElements(bpy.types.Operator):
bl_idname = "bim.load_project_elements"
bl_label = "Load Project Elements"
@@ -73,6 +73,8 @@ def file_menu(self, context):
op = self.layout.operator("export_ifc.bim", text="Save IFC Project As...")
op.should_save_as = True
self.layout.separator()
self.layout.operator("bim.revert_project")
self.layout.separator()
class BIM_PT_project(Panel):
@@ -147,14 +147,12 @@ class RemoveOpening(bpy.types.Operator, tool.Ifc.Operator):
for building_element in decomposed_building_elements:
building_obj = tool.Ifc.get_object(building_element)
if building_obj and building_obj.data:
body = ifcopenshell.util.representation.get_representation(
building_element, "Model", "Body", "MODEL_VIEW"
)
representation = tool.Geometry.get_active_representation(building_obj)
blenderbim.core.geometry.switch_representation(
tool.Ifc,
tool.Geometry,
obj=building_obj,
representation=body,
representation=representation,
should_reload=True,
is_global=True,
should_sync_changes_first=False,
+2 -2
View File
@@ -212,7 +212,7 @@ class FileAssociate(bpy.types.Operator):
self.layout.label(text="On the next step to create file association ")
self.layout.label(text="the system console will be opened ")
self.layout.label(text=f"and you will be asked to type command")
self.layout.label(text=f'"{command}"')
self.layout.label(text=f"{command}")
self.layout.label(text="to create an association.")
def invoke(self, context, event):
@@ -241,7 +241,7 @@ class FileAssociate(bpy.types.Operator):
ps_script_path = os.path.join(src_dir, "windows_bbim_association.ps1")
# NOTE: call powershell with RunAs to get admin rights from user
subprocess.run(["powershell", "-file", ps_script_path, binary_path], shell=True)
subprocess.run(["powershell", "-ExecutionPolicy", "Bypass", "-File", ps_script_path, binary_path], shell=True)
def install_desktop_linux(self, src_dir=None, destdir="/tmp", binary_path="/usr/bin/blender"):
"""Creates linux file assocations and launcher icon"""
+5 -3
View File
@@ -125,7 +125,9 @@ def select_decomposed_elements(spatial):
#HERE STARTS SPATIAL TOOL
def generate_spaces_from_walls(ifc, spatial, collector):
container, active_obj = spatial.get_container_and_active_obj()
active_obj = bpy.context.active_object
element = ifc.get_entity(active_obj)
container = spatial.get_container(element)
if not active_obj:
self.report({"ERROR"}, "No active object. Please select a wall")
@@ -147,12 +149,12 @@ def generate_spaces_from_walls(ifc, spatial, collector):
h = active_obj.dimensions.z
selected_objects = bpy.context.selected_objects
union = spatial.get_union_shape_from_selected_objects(selected_objects)
union = spatial.get_union_shape_from_selected_objects()
for i, linear_ring in enumerate(union.interiors):
poly = spatial.get_buffered_poly_from_linear_ring(linear_ring)
bm = spatial.get_bmesh_from_polygon(poly, mat, h)
bm = spatial.get_bmesh_from_polygon(poly, h)
name = "Space" + str(i)
mesh = bpy.data.meshes.new(name=name)
+1 -2
View File
@@ -810,8 +810,7 @@ class Spatial:
def set_relative_object_matrix(cls, target_obj, relative_to_obj, matrix): pass
def show_scene_objects(cls): pass
#HERE STARTS SPATIAL TOOL
# def get_container_and_active_obj(cls): pass
def get_union_shape_from_selected_objects(cls, selected_objects): pass
def get_union_shape_from_selected_objects(cls): pass
def get_boundary_elements(cls, selected_objects): pass
def get_polygons(cls, boundary_elements): pass
def get_obj_base_points(cls, obj): pass
+1 -1
View File
@@ -416,7 +416,7 @@ class Drawing(blenderbim.core.tool.Drawing):
@classmethod
def get_drawing_group(cls, drawing):
for rel in drawing.HasAssignments or []:
if rel.is_a("IfcRelAssignsToGroup"):
if rel.is_a("IfcRelAssignsToGroup") and rel.RelatingGroup.ObjectType == "DRAWING":
return rel.RelatingGroup
@classmethod