Hi,
I'm using this code to find AutoCAD Dwg Links (3D or 2D) :
foreach (Category c in Doc1.Settings.Categories)
{
if (c.Name.ToLower().EndsWith(".dwg"))
{
TaskDialog.Show("debug", "New ==>" + c.Name);
}
}
But I cannot find the pathname.
Also if a dwg link is in a A.rvt linked to the Main.rvt, How to find the related father A.rvt file ? Actually we have a way to find all linked .dwg files at different levels, but we don<t know how to get their respective parents.
Philippe Meigneux.
Solved! Go to Solution.
Hi,
I'm using this code to find AutoCAD Dwg Links (3D or 2D) :
foreach (Category c in Doc1.Settings.Categories)
{
if (c.Name.ToLower().EndsWith(".dwg"))
{
TaskDialog.Show("debug", "New ==>" + c.Name);
}
}
But I cannot find the pathname.
Also if a dwg link is in a A.rvt linked to the Main.rvt, How to find the related father A.rvt file ? Actually we have a way to find all linked .dwg files at different levels, but we don<t know how to get their respective parents.
Philippe Meigneux.
Solved! Go to Solution.
Solved by Dale.Bartlett. Go to Solution.
Dear Philippe,
Thank you for your query.
For the DWG files, one simple possible solution would be to use the operating system directory traversal tools to find the DWG file, assuming that you know that it is located within or underneath some specific directory, or collection of directories.
I am afraid that I am not aware of any other possibility right now.
I am somewhat surprised that I could not find a wish list item for this functionality, so I created one and asked the development team for ideas:
I submitted the wish list item CF-4080 [API wish: determine full pathname of linked dwg file] on your behalf for the functionality you suggest, as this issue requires exploration and possibly a modification to our software. Please make a note of this number for future reference.
You are welcome to request an update on the status of this issue or to provide us with additional information at any time quoting the wish list item number or this thread.
This issue is important to me. What can I do to help?
This issue needs to be assessed by our engineering team, and prioritised against all of the other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:
This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.
I hope this helps.
Best regards,
Jeremy
Dear Philippe,
Thank you for your query.
For the DWG files, one simple possible solution would be to use the operating system directory traversal tools to find the DWG file, assuming that you know that it is located within or underneath some specific directory, or collection of directories.
I am afraid that I am not aware of any other possibility right now.
I am somewhat surprised that I could not find a wish list item for this functionality, so I created one and asked the development team for ideas:
I submitted the wish list item CF-4080 [API wish: determine full pathname of linked dwg file] on your behalf for the functionality you suggest, as this issue requires exploration and possibly a modification to our software. Please make a note of this number for future reference.
You are welcome to request an update on the status of this issue or to provide us with additional information at any time quoting the wish list item number or this thread.
This issue is important to me. What can I do to help?
This issue needs to be assessed by our engineering team, and prioritised against all of the other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:
This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.
I hope this helps.
Best regards,
Jeremy
Unless I am misundertanding the question, this returns DWG link paths. I haven't looked at nested links. Dale
// collect all (immediate) external references in the model ICollection<ElementId> externalReferences = transData.GetAllExternalFileReferenceIds(); int n = externalReferences.Count; // content += string.Format("has {0} external reference{1}{2}", n, PluralSuffix(n), DotOrColon(n)); links = new List<string>(n); // DWG foreach (ElementId refId in externalReferences) { ExternalFileReference extRef = transData.GetLastSavedReferenceData(refId); // DWG if (extRef.ExternalFileReferenceType == ExternalFileReferenceType.CADLink) { // get absolute path to check for validity string lstrLinkFileNameAbsolute = ModelPathUtils.ConvertModelPathToUserVisiblePath(extRef.GetAbsolutePath()); links.Add(lstrLinkFileNameAbsolute); } }
Unless I am misundertanding the question, this returns DWG link paths. I haven't looked at nested links. Dale
// collect all (immediate) external references in the model ICollection<ElementId> externalReferences = transData.GetAllExternalFileReferenceIds(); int n = externalReferences.Count; // content += string.Format("has {0} external reference{1}{2}", n, PluralSuffix(n), DotOrColon(n)); links = new List<string>(n); // DWG foreach (ElementId refId in externalReferences) { ExternalFileReference extRef = transData.GetLastSavedReferenceData(refId); // DWG if (extRef.ExternalFileReferenceType == ExternalFileReferenceType.CADLink) { // get absolute path to check for validity string lstrLinkFileNameAbsolute = ModelPathUtils.ConvertModelPathToUserVisiblePath(extRef.GetAbsolutePath()); links.Add(lstrLinkFileNameAbsolute); } }
Cool!
Thank you, Dave!
Please confirm, Philippe.
Cheers,
Jeremy
Cool!
Thank you, Dave!
Please confirm, Philippe.
Cheers,
Jeremy
sorry, mistake.
Sorry, DaLe,
I know very well, but somehow my fingers went off on their own accord, with no consultation with 'higher' instances.
They think they are Satoshi, too, you know!
All ten of them, even though I only use index plus middle for typing, and thumbs for some spaces or upper case... but they all insist regardless.
Sorry about that!
Cheers,
Jeremy
Sorry, DaLe,
I know very well, but somehow my fingers went off on their own accord, with no consultation with 'higher' instances.
They think they are Satoshi, too, you know!
All ten of them, even though I only use index plus middle for typing, and thumbs for some spaces or upper case... but they all insist regardless.
Sorry about that!
Cheers,
Jeremy
To round off this, here is another code snippet demonstrating an equivalent solution:
FilteredElementCollector fec1 = new FilteredElementCollector(doc); fec1.OfClass(typeof(ImportInstance)); Element element = fec1.FirstElement(); Element elementType = doc.GetElement(element.GetTypeId()); ExternalFileReference exRefType = null; try { exRefType = elementType.GetExternalFileReference(); } catch (Exception e) { } TaskDialog.Show("ExtFileRef", "Type: " + ModelPathUtils.ConvertModelPathToUserVisiblePath( exRefType.GetPath()));
Cheers,
Jeremy
To round off this, here is another code snippet demonstrating an equivalent solution:
FilteredElementCollector fec1 = new FilteredElementCollector(doc); fec1.OfClass(typeof(ImportInstance)); Element element = fec1.FirstElement(); Element elementType = doc.GetElement(element.GetTypeId()); ExternalFileReference exRefType = null; try { exRefType = elementType.GetExternalFileReference(); } catch (Exception e) { } TaskDialog.Show("ExtFileRef", "Type: " + ModelPathUtils.ConvertModelPathToUserVisiblePath( exRefType.GetPath()));
Cheers,
Jeremy
Can't find what you're looking for? Ask the community or share your knowledge.