You can now use relative paths when browsing for file URIs.

This commit is contained in:
Dion Moult
2022-03-15 18:58:51 +11:00
parent 53a9175802
commit 456f45b346
4 changed files with 20 additions and 16 deletions
+9 -8
View File
@@ -79,17 +79,18 @@ for name in modules.keys():
classes = [
operator.OpenUri,
operator.SelectDataDir,
operator.SelectSchemaDir,
operator.SelectIfcFile,
operator.OpenUpstream,
operator.AddIfcFile,
operator.BIM_OT_add_section_plane,
operator.BIM_OT_remove_section_plane,
operator.ReloadIfcFile,
operator.AddIfcFile,
operator.RemoveIfcFile,
operator.ConfigureVisibility,
operator.OpenUpstream,
operator.OpenUri,
operator.ReloadIfcFile,
operator.RemoveIfcFile,
operator.SelectDataDir,
operator.SelectIfcFile,
operator.SelectSchemaDir,
operator.SelectURIAttribute,
prop.StrProperty,
prop.ObjProperty,
prop.Attribute,
+7 -2
View File
@@ -22,6 +22,7 @@ import json
import webbrowser
import ifcopenshell
import blenderbim.bim.handler
import blenderbim.tool as tool
from . import schema
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.ui import IFCFileSelector
@@ -44,8 +45,9 @@ class SelectURIAttribute(bpy.types.Operator):
bl_label = "Select URI Attribute"
bl_options = {"REGISTER", "UNDO"}
bl_description = "Select a local file"
data_path: bpy.props.StringProperty(name="Data Path")
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
data_path: bpy.props.StringProperty(name="Data Path")
use_relative_path: bpy.props.BoolProperty(name="Use Relative Path", default=False)
def execute(self, context):
# data_path contains the latter half of the path to the string_value property
@@ -64,7 +66,10 @@ class SelectURIAttribute(bpy.types.Operator):
# Do you know a better way?
pass
if attribute:
attribute.string_value = self.filepath
filepath = self.filepath
if self.use_relative_path:
filepath = os.path.relpath(filepath, os.path.dirname(tool.Ifc.get_path()))
attribute.string_value = filepath
return {"FINISHED"}
def invoke(self, context, event):
+1 -1
View File
@@ -188,7 +188,7 @@ class TestImportReferences(NewFile):
assert len(props.documents) == 1
assert props.documents[0].ifc_definition_id == reference.id()
assert props.documents[0].name == "Unnamed"
assert props.documents[0].identification == "X"
assert props.documents[0].identification == "*"
assert props.documents[0].is_information is False
@@ -25,8 +25,6 @@ class Usecase:
self.settings[key] = value
def execute(self):
id_attribute = "ItemReference" if self.file.schema == "IFC2X3" else "Identification"
attributes = {id_attribute: "X"}
if self.file.schema != "IFC2X3":
attributes["ReferencedDocument"] = self.settings["information"]
return self.file.create_entity("IfcDocumentReference", **attributes)
if self.file.schema == "IFC2X3":
return self.file.create_entity("IfcDocumentReference")
return self.file.create_entity("IfcDocumentReference", ReferencedDocument=self.settings["information"])