You can now easily open associated documents with support for inherited locations

This commit is contained in:
Dion Moult
2022-03-15 19:32:29 +11:00
parent 456f45b346
commit 8f70f462cc
2 changed files with 12 additions and 1 deletions
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
import os
import bpy
import ifcopenshell
import ifcopenshell.util.schema
@@ -85,12 +86,20 @@ class ObjectDocumentData:
identification = rel.RelatingDocument.ItemReference
else:
identification = rel.RelatingDocument.Identification
location = rel.RelatingDocument.Location
if location is None and rel.RelatingDocument.ReferencedDocument:
location = rel.RelatingDocument.ReferencedDocument.Location
if location:
if not "://" in location:
if not os.path.isabs(location):
location = os.path.abspath(os.path.join(os.path.dirname(tool.Ifc.get_path()), location))
location = "file://" + location
results.append(
{
"type": rel.RelatingDocument.is_a(),
"id": rel.RelatingDocument.id(),
"identification": identification,
"name": rel.RelatingDocument.Name,
"location": location,
}
)
return results
@@ -113,6 +113,8 @@ class BIM_PT_object_documents(Panel):
row = self.layout.row(align=True)
row.label(text=document["identification"] or "*", icon="FILE")
row.label(text=document["name"] or "Unnamed")
if document["location"]:
row.operator("bim.open_uri", icon="URL", text="").uri = document["location"]
row.operator("bim.unassign_document", text="", icon="X").document = document["id"]
def draw_add_ui(self):