mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
You can now use relative paths when browsing for file URIs.
This commit is contained in:
@@ -79,17 +79,18 @@ for name in modules.keys():
|
|||||||
|
|
||||||
|
|
||||||
classes = [
|
classes = [
|
||||||
operator.OpenUri,
|
operator.AddIfcFile,
|
||||||
operator.SelectDataDir,
|
|
||||||
operator.SelectSchemaDir,
|
|
||||||
operator.SelectIfcFile,
|
|
||||||
operator.OpenUpstream,
|
|
||||||
operator.BIM_OT_add_section_plane,
|
operator.BIM_OT_add_section_plane,
|
||||||
operator.BIM_OT_remove_section_plane,
|
operator.BIM_OT_remove_section_plane,
|
||||||
operator.ReloadIfcFile,
|
|
||||||
operator.AddIfcFile,
|
|
||||||
operator.RemoveIfcFile,
|
|
||||||
operator.ConfigureVisibility,
|
operator.ConfigureVisibility,
|
||||||
|
operator.OpenUpstream,
|
||||||
|
operator.OpenUri,
|
||||||
|
operator.ReloadIfcFile,
|
||||||
|
operator.RemoveIfcFile,
|
||||||
|
operator.SelectDataDir,
|
||||||
|
operator.SelectIfcFile,
|
||||||
|
operator.SelectSchemaDir,
|
||||||
|
operator.SelectURIAttribute,
|
||||||
prop.StrProperty,
|
prop.StrProperty,
|
||||||
prop.ObjProperty,
|
prop.ObjProperty,
|
||||||
prop.Attribute,
|
prop.Attribute,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import json
|
|||||||
import webbrowser
|
import webbrowser
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
import blenderbim.bim.handler
|
import blenderbim.bim.handler
|
||||||
|
import blenderbim.tool as tool
|
||||||
from . import schema
|
from . import schema
|
||||||
from blenderbim.bim.ifc import IfcStore
|
from blenderbim.bim.ifc import IfcStore
|
||||||
from blenderbim.bim.ui import IFCFileSelector
|
from blenderbim.bim.ui import IFCFileSelector
|
||||||
@@ -44,8 +45,9 @@ class SelectURIAttribute(bpy.types.Operator):
|
|||||||
bl_label = "Select URI Attribute"
|
bl_label = "Select URI Attribute"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
bl_description = "Select a local file"
|
bl_description = "Select a local file"
|
||||||
data_path: bpy.props.StringProperty(name="Data Path")
|
|
||||||
filepath: bpy.props.StringProperty(subtype="FILE_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):
|
def execute(self, context):
|
||||||
# data_path contains the latter half of the path to the string_value property
|
# 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?
|
# Do you know a better way?
|
||||||
pass
|
pass
|
||||||
if attribute:
|
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"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class TestImportReferences(NewFile):
|
|||||||
assert len(props.documents) == 1
|
assert len(props.documents) == 1
|
||||||
assert props.documents[0].ifc_definition_id == reference.id()
|
assert props.documents[0].ifc_definition_id == reference.id()
|
||||||
assert props.documents[0].name == "Unnamed"
|
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
|
assert props.documents[0].is_information is False
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ class Usecase:
|
|||||||
self.settings[key] = value
|
self.settings[key] = value
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
id_attribute = "ItemReference" if self.file.schema == "IFC2X3" else "Identification"
|
if self.file.schema == "IFC2X3":
|
||||||
attributes = {id_attribute: "X"}
|
return self.file.create_entity("IfcDocumentReference")
|
||||||
if self.file.schema != "IFC2X3":
|
return self.file.create_entity("IfcDocumentReference", ReferencedDocument=self.settings["information"])
|
||||||
attributes["ReferencedDocument"] = self.settings["information"]
|
|
||||||
return self.file.create_entity("IfcDocumentReference", **attributes)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user