FixRevitTINs patch now also flips normals for surface TINs instead of solid TINs.

Minor fixes to use view_layer.object.active etc instead of context.active_object when running via Blender UI (it seems when you run the patch recipe from the Blender UI at least in later versions, context does not have an "active_object" property.
This commit is contained in:
Dion Moult
2023-11-30 14:58:17 +11:00
parent 0679956add
commit 7aa6be8e8a
3 changed files with 48 additions and 20 deletions
@@ -275,7 +275,7 @@ class UpdateRepresentation(bpy.types.Operator, Operator):
ifc_representation_class: bpy.props.StringProperty()
def _execute(self, context):
if context.active_object and context.active_object.mode != "OBJECT":
if context.view_layer.objects.active and context.view_layer.objects.active.mode != "OBJECT":
# Ensure mode is object to prevent invalid mesh data causing CTD
bpy.ops.object.mode_set(mode="OBJECT", toggle=False)
@@ -87,6 +87,9 @@ class ExecuteIfcPatch(bpy.types.Operator):
input_file = props.ifc_patch_input
file = ifcopenshell.open(props.ifc_patch_input)
# Store this in case the patch recipe resets the Blender session, such as by loading a new project.
ifc_patch_output = props.ifc_patch_output
output = ifcpatch.execute(
{
"input": input_file,
@@ -96,7 +99,7 @@ class ExecuteIfcPatch(bpy.types.Operator):
"log": os.path.join(context.scene.BIMProperties.data_dir, "process.log"),
}
)
ifcpatch.write(output, props.ifc_patch_output)
ifcpatch.write(output, ifc_patch_output)
return {"FINISHED"}