use path_resolve instead of eval

This commit is contained in:
Gorgious
2022-01-23 23:01:19 +01:00
parent 4ad5f5cbf4
commit cc790c0a09
2 changed files with 15 additions and 14 deletions
+5 -5
View File
@@ -30,13 +30,10 @@ def draw_attributes(props, layout, copy_operator=None):
prefs = bpy.context.preferences.addons["blenderbim"].preferences
for i, attribute in enumerate(props):
row = layout.row(align=True)
draw_attribute(attribute, row, copy_operator)
if prefs.info_mode:
info = row.operator("bim.show_attribute_documentation", icon="INFO", text="")
info.path = f"context.scene.{props.path_from_id()}[{i}].doc"
draw_attribute(attribute, row, copy_operator, prefs.info_mode)
def draw_attribute(attribute, layout, copy_operator=None):
def draw_attribute(attribute, layout, copy_operator=None, info_mode=False):
value_name = attribute.get_value_name()
if not value_name:
layout.label(text=attribute.name)
@@ -51,6 +48,9 @@ def draw_attribute(attribute, layout, copy_operator=None):
if copy_operator:
op = layout.operator(f"{copy_operator}", text="", icon="COPYDOWN")
op.name = attribute.name
if info_mode:
info_op = layout.operator("bim.show_attribute_documentation", icon="INFO", text="")
info_op.path = f"{attribute.path_from_id()}"
def import_attributes(ifc_class, props, data, callback=None):
+10 -9
View File
@@ -363,32 +363,33 @@ class RemoveIfcFile(bpy.types.Operator):
return {"FINISHED"}
class BIM_OT_open_webbrowser(bpy.types.Operator):
class BIM_OT_open_webbrowser(bpy.types.Operator):
bl_idname = "bim.open_webbrowser"
bl_label = ""
url: bpy.props.StringProperty()
def execute(self, context):
import webbrowser
webbrowser.open(self.url)
return {'FINISHED'}
return {"FINISHED"}
class BIM_OT_show_attribute_documentation(bpy.types.Operator):
class BIM_OT_show_attribute_documentation(bpy.types.Operator):
bl_idname = "bim.show_attribute_documentation"
bl_label = ""
path: bpy.props.StringProperty()
def execute(self, context):
return {'FINISHED'}
return {"FINISHED"}
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self)
def draw(self, context):
doc = eval(self.path)
doc = context.scene.path_resolve(self.path)
doc.draw(self.layout)