I want to ask dynamo if there is any node that can extract the actual path of Xref

I would like to ask if your installation package has a node that can extract the actual path of Xref, because one of my changes is to write the actual path of Xref that already exists in the drawing into the EXCEL table. I don’t know if your installation package node has this function.

I would like to know if there is an installation package node that can extract the path of this (found at )instead of exporting the string of the (Saved path).Thank you.

You can use the camber package. You can get the xref document and then its path/name:

image

I have used this camber. That is, his node will export NULL .\XX.dwg. I want the real path found at

Ah I see, I did some tests with the camber nodes as well as block parameters but wasn’t able to get the info you are looking for. Seems to me that there is no straight node and will need to get into the AutoCAD API for this (haven’t really looked if there is an exposed call that will get you this)

1 Like

To my knowledge, there is not…which is why there is no node for it yet :wink:

2 Likes

This was incorrect…
Sorry, my bad.

A bit corky, but you could use regex to match the relative paths to your current document path using the python node:

current file base directory being: os.path.dirname(Application.DocumentManager.MdiActiveDocument.Name)

and the regular expression for each xref path being:
re.findall("\..\\\\", path) for files in higher-up directories and
re.findall("^\.\\\\", path) for files in current directories
Tip: use the FileSystem.FileExists node to verify that your xref is found, it may be that the resulting full file path is not found if the reference cannot be found.

you end up with something like this (not very elegant but working…):

import sys
import clr
import os
import re

clr.AddReference('AcMgd')
from Autodesk.AutoCAD.ApplicationServices import *
basedir = os.path.dirname(Application.DocumentManager.MdiActiveDocument.Name)

paths = IN[0]
base = basedir.split("\\")	

res = []

for p in paths:
	len1 = len(re.findall("\..\\\\", p))
	len2 = len(re.findall("^\.\\\\", p))
	
	if len1 > 0: 
		a = "\\".join(base[:-len1]) + "\\"
		b = p[3*len1:]
		res.append(os.path.join(a, b))
	elif len2 > 0:
		a = "\\".join(base) + "\\"
		b = p[2:]
		res.append(os.path.join(a, b))
	else: 
		res.append(p)


OUT = res #full paths
1 Like

Is this program made into a dynamo node? :laughing:

It’d been too long since I’d last crashed Civil3D, so I’ll weigh in with a possible solution… Can someone with a real project to test with give this a shot? I don’t know what sort of issues this could have with data references, images, pdfs, or other xref types. It is working for me (without regex) in the context of C3D 2023.1 with nothing but DWG references. The graph does require Camber for the Document.Xrefs node, but you can skip that if you just want a report. Also I hve no idea how this would perform on a ACC hosted project.

xrefPaths.dyn (12.4 KB)

Hopefully this circumvents the need for Regex, as while that’s a great solution (seriously great work @geert.drijfhout!), I have found regex can have issues with some characters, and it’s generally best to let the application report what it knows rather than inferring it from context.

Yes - that should work in a Python node using the IronPython engine.

Host.dwg (975.6 KB)
xref.xlsx (9.9 KB)
xref1.dwg (926.5 KB)
xref2.dwg (923.8 KB)
xref3.dwg (925.2 KB)
ImportEX_v3.dyn (63.5 KB)
Attached is my file host is the main picture, I used the Document.Xrefs node and the Xref.Path node Camber in this picture, I want to extract the real path of xref1 and xref2 of the Host picture into the EXCEL table. It may be Replace SAVE PATH with FOUND AT PATH

Did you try the graph I posted in your project? If so, what results did you get? My testing showed the last item in each sublist would be the ‘found at’ path.

1 Like

This node is available in Camber v4.2.5

5 Likes

It worked. It’s very useful. Thanks :innocent:

1 Like

Thank you for your updates :innocent:

1 Like