Closed koji-dan closed 3 years ago
Ah you may have an old user preferences from an older version of the BlenderBIM Add-on.
The BlenderBIM Add-on executes a few things on start up to make drawing generating easier. This has changed a few times because the drawing system has changed a few times too. Since we're still in alpha, I haven't bothered to write code to migrate old settings, so as a result people with old user startup files kinda need to refresh them.
In short, try clearing your startup settings and it should be fixed.
Thank you so much for your response ! i tried to clear starup setting as the below, but result is not good for me.
Is the BlenderBIM Add-on enabled in your add-ons settings in Edit->Preferences?
in Edit->Preference window, when BlenderBIM is not enable(disappeared or gray-down display), i don't see AttributeError on python script, but i cannot use ifc import/export of BlenderBIM. when BlenderBIM is enable, i see AttributeError on python script, and i see also similar AttributeError below on use ifc import/export ...
Error: Python: Traceback (most recent call last): File "C:\Users\r00414643\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\blenderbim\bim\operator.py", line 118, in execute settings = import_ifc.IfcImportSettings.factory(context, self.filepath, logger) File "C:\Users\r00414643\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\blenderbim\bim\import_ifc.py", line 1465, in factory scene_diff = context.scene.DiffProperties AttributeError: 'Scene' object has no attribute 'DiffProperties'
location: C:\Program Files\Blender Foundation\Blender 2.93\2.93\scripts\modules\bpy\ops.py:132
Python: Traceback (most recent call last): File "C:\Users\r00414643\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\blenderbim\bim\operator.py", line 118, in execute settings = import_ifc.IfcImportSettings.factory(context, self.filepath, logger) File "C:\Users\r00414643\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\blenderbim\bim\import_ifc.py", line 1465, in factory scene_diff = context.scene.DiffProperties AttributeError: 'Scene' object has no attribute 'DiffProperties'
location: C:\Program Files\Blender Foundation\Blender 2.93\2.93\scripts\modules\bpy\ops.py:132 Error: Python: Traceback (most recent call last): File "C:\Users\r00414643\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\blenderbim\bim\operator.py", line 118, in execute settings = import_ifc.IfcImportSettings.factory(context, self.filepath, logger) File "C:\Users\r00414643\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\blenderbim\bim\import_ifc.py", line 1465, in factory scene_diff = context.scene.DiffProperties AttributeError: 'Scene' object has no attribute 'DiffProperties'
location: C:\Program Files\Blender Foundation\Blender 2.93\2.93\scripts\modules\bpy\ops.py:132
Traceback (most recent call last):
File "
location: C:\Program Files\Blender Foundation\Blender 2.93\2.93\scripts\modules\bpy\ops.py:132
Error: File format is not supported in file 'C:\Users\r00414643\Desktop\3DD.Work\data\ifc\sample_ifc.ifc'
Blender quit
I think the first thing to do is to ensure that you do not have any errors with the pure BlenderBIM Add-on and you can import/export from the graphical interface, i.e. File->Import->IFC. Then, we can focus on the errors with your script OpeConvBlender.py
.
Can you first confirm that the BlenderBIM Add-on works by itself? If so, then we can debug your script, but you may need to post your script for me to see what is happening.
yes, i agree. from blender GUI, i tried to import/export successfully, but python script are not succeeded as the above error. my confirmation result are summarized again below. as you mentioned, i had better find solution against AttributeError when BlenderBIM is enable, before trying import/export IFC.
operation: import "sample_stl.stl" (File -> Import -> STL) and export "sample_stl2.stl"(File -> export -> STL).
[1.BlenderBIM addon is disable (Edit -> Preferences)] (1-1). operation on blender GUI => success (1-2). operation by python script => success [2.BlenderBIM addon is enable (Edit -> Preferences)] (2-1). operation on blender GUI => success (2-2). operation by python script => AttributeError (log is put in the bottom of this comment again)
the error of (2-2) is occured in the begining of script starting.
%> blender.exe --background --python OpeConvBlender.py
(OpeConvBlender.py) import bpy import os import sys import time
bpy.ops.import_mesh.stl( filepath="sample_stl.stl", filter_glob=".stl" ) bpy.ops.export_mesh.stl( filepath="sample_stl2.stl", filter_glob=".stl" )
(2-2) error log Blender 2.93.2 (hash 1eb06de2607a built 2021-08-03 23:48:49) Read prefs: C:\Users\r00414643\AppData\Roaming\Blender Foundation\Blender\2.93\config\userpref.blend Exception in module register(): C:\Users\r00414643\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\blenderbim__init.py Traceback (most recent call last): File "C:\Program Files\Blender Foundation\Blender 2.93\2.93\scripts\modules\addon_utils.py", line 386, in enable mod.register() File "C:\Users\r00414643\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\blenderbim\bim__init.py", line 131, in register module.register() File "C:\Users\r00414643\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\blenderbim\bim\module\model\init.py", line 34, in register bpy.utils.register_tool(workspace.BimTool, after={"builtin.scale_cage"}, separator=True, group=True) File "C:\Program Files\Blender Foundation\Blender 2.93\2.93\scripts\modules\bpy\utils\init__.py", line 888, in register_tool tool_converted = tool_from_class(tool_cls) File "C:\Program Files\Blender Foundation\Blender 2.93\2.93\scripts\modules\bpy\utils\init__.py", line 885, in tool_from_class cls._km_action_simple(kc_default, kc, context_descr, tool_def.label, keymap_data) File "C:\Program Files\Blender Foundation\Blender 2.93\2.93\scripts\startup\bl_ui\space_toolsystem_common.py", line 471, in _km_action_simple km = kc.keymaps.get(km_idname) AttributeError: 'NoneType' object has no attribute 'keymaps' Traceback (most recent call last): File "C:\Users\r00414643\AppData\Roaming\Blender Foundation\Blender\2.93\scripts\addons\blenderbim\bim\handler.py", line 223, in setDefaultProperties if len(bpy.context.scene.DocProperties.drawing_styles) == 0: AttributeError: 'Scene' object has no attribute 'DocProperties'
@koji-dan thanks, this is a pretty fascinating error and I'm not quite sure how to fix it.
It seems that when Blender is in background mode, the keymaps cannot be updated. As a short term fix, you can delete the lines of code you see here: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.6.0/src/blenderbim/blenderbim/bim/module/model/workspace.py#L17-L32 that I have highlighted (L17-L32).
It seems as though the existence of a bl_keymap
will cause the add-on to fail to load in background mode.
Pinging @s-leger and @Gorgious56 in case they know how to fix this.
To replicate do:
$ cat foo.py
import bpy
bpy.ops.import_ifc.bim(filepath="/home/dion/wall.ifc")
$ blender --background --python foo.py
We'll keep this open until we find a proper fix, but I hope the workaround helps you solve your immediate problem.
Easy fix, do not register the tool.
if bpy.app.background:
return
thank you so much ! i could confirm no error without --backgournd in command line according to your comment.
Hi, i always appreciate for you great works !
What i want to try is just to import/export ifc file by python console of blender, and i installed BlenderBIM addon into blender. After installing BlenderBIM, i always meet AttributeError on python script as the followings. this message is always showing on starting python script, when not only before import/export call but also not using ifc import/export. this might be based on the version combination issue ??