mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 19:27:10 +00:00
Styles are applied per mesh data now (potentially dangerous). Fix crash when switching to representation which has styles from an unstyled mesh.
This commit is contained in:
@@ -60,7 +60,6 @@ class MaterialCreator:
|
|||||||
|
|
||||||
def create(self, element, obj, mesh):
|
def create(self, element, obj, mesh):
|
||||||
self.mesh = mesh
|
self.mesh = mesh
|
||||||
self.obj = obj
|
|
||||||
if (hasattr(element, "Representation") and not element.Representation) or (
|
if (hasattr(element, "Representation") and not element.Representation) or (
|
||||||
hasattr(element, "RepresentationMaps") and not element.RepresentationMaps
|
hasattr(element, "RepresentationMaps") and not element.RepresentationMaps
|
||||||
):
|
):
|
||||||
@@ -140,11 +139,11 @@ class MaterialCreator:
|
|||||||
def assign_material_slots_to_faces(self):
|
def assign_material_slots_to_faces(self):
|
||||||
if "ios_materials" not in self.mesh or not self.mesh["ios_materials"]:
|
if "ios_materials" not in self.mesh or not self.mesh["ios_materials"]:
|
||||||
return
|
return
|
||||||
if len(self.obj.material_slots) == 1:
|
if len(self.mesh.materials) == 1:
|
||||||
return
|
return
|
||||||
material_to_slot = {}
|
material_to_slot = {}
|
||||||
for i, material in enumerate(self.mesh["ios_materials"]):
|
for i, material in enumerate(self.mesh["ios_materials"]):
|
||||||
slot_index = self.obj.material_slots.find(self.styles[material].name)
|
slot_index = self.mesh.materials.find(self.styles[material].name)
|
||||||
material_to_slot[i] = slot_index
|
material_to_slot[i] = slot_index
|
||||||
|
|
||||||
if len(self.mesh.polygons) == len(self.mesh["ios_material_ids"]):
|
if len(self.mesh.polygons) == len(self.mesh["ios_material_ids"]):
|
||||||
|
|||||||
@@ -681,12 +681,14 @@ class EditExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
|
|
||||||
# Only certain classes should have a footprint
|
# Only certain classes should have a footprint
|
||||||
if element.is_a() not in ("IfcSlab", "IfcRamp"):
|
if element.is_a() not in ("IfcSlab", "IfcRamp"):
|
||||||
return {"FINISHED"}
|
return
|
||||||
|
|
||||||
footprint_context = ifcopenshell.util.representation.get_context(
|
footprint_context = ifcopenshell.util.representation.get_context(
|
||||||
tool.Ifc.get(), "Plan", "FootPrint", "SKETCH_VIEW"
|
tool.Ifc.get(), "Plan", "FootPrint", "SKETCH_VIEW"
|
||||||
)
|
)
|
||||||
if footprint_context:
|
if not footprint_context:
|
||||||
|
return
|
||||||
|
|
||||||
curves = [profile.OuterCurve]
|
curves = [profile.OuterCurve]
|
||||||
if profile.is_a("IfcArbitraryProfileDefWithVoids"):
|
if profile.is_a("IfcArbitraryProfileDefWithVoids"):
|
||||||
curves.extend(profile.InnerCurves)
|
curves.extend(profile.InnerCurves)
|
||||||
@@ -706,7 +708,6 @@ class EditExtrusionProfile(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
ifcopenshell.api.run(
|
ifcopenshell.api.run(
|
||||||
"geometry.assign_representation", tool.Ifc.get(), product=element, representation=new_footprint
|
"geometry.assign_representation", tool.Ifc.get(), product=element, representation=new_footprint
|
||||||
)
|
)
|
||||||
return {"FINISHED"}
|
|
||||||
|
|
||||||
|
|
||||||
class ResetVertex(bpy.types.Operator):
|
class ResetVertex(bpy.types.Operator):
|
||||||
|
|||||||
Reference in New Issue
Block a user