Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

TransmissionData.SetDesiredReferenceData

14 REPLIES 14
Reply
Message 1 of 15
pmeigneux
704 Views, 14 Replies

TransmissionData.SetDesiredReferenceData

Hi,

 

When use TransmissionData.SetDesiredReferenceData witch PathType.Relative.

 

What is the reference directory?

 

Is it possible to define the reference directory?

 

Philippe.

14 REPLIES 14
Message 2 of 15
JimJia
in reply to: pmeigneux

Hi Philippe,

 

If the PathType is Relative, that means the external file resource's path is relative to the host file's location, or to the central model's location if the host is workshared.

Hope that can help you.


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 3 of 15
pmeigneux
in reply to: JimJia

hi,

 

SetDesiredReferenceData change Path for RevitLink only ?

 

I used SetDesiredReferenceData on CADLink and DWFMarkup link and cannot change the original Path..

 

Philippe.

Message 4 of 15
pmeigneux
in reply to: pmeigneux

hi,

 

How to change the path of a cad link?

Message 5 of 15
JimJia
in reply to: pmeigneux

Hi Philippe,

 

Please accept our sincerer apology for the delay! We had a backlog in the queue these days.

In order to understand exactly what you mean and be able to research possible reasons for the discrepancy between the observed and expected behavior, they require:
· A short exact description of what you are trying to achieve.
· The behavior you observe versus what you expect, and why this is a problem.
· A complete yet minimal Revit sample model to run a test in.
· A complete yet minimal macro embedded in the sample model or Visual Studio solution with add-in manifest that can be compiled, loaded, run and debugged with a single click to analyse its behavior live in the sample model.
· Detailed step-by-step instructions for reproducing the issue, e.g. which element to pick, what command to launch etc.

· What version do you use.

 

we appreciate your cooperation and patience

 

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 6 of 15
pmeigneux
in reply to: JimJia

Hi JimJia,

 

Sorry, I was in vacation.

 

In attachment Code for this problem Test in Revit 2016).

 

In Data Directory : Revit model, Dwg File and a Problem_CAD_link.png

 

Philippe.

Message 7 of 15

Phillipe, if your are changing path to relative, then it is literally relative the host file as stated, and path is set for you. If you want to "Reload From" to change the path to a different location or file, try this:

TransmissionData transdata = TransmissionData.ReadTransmissionData(modelpath);
            if (transdata != null)
            {
                ICollection<ElementId> xrefs = transdata.GetAllExternalFileReferenceIds(); //collect ALL the references
                foreach (ElementId xrefid in xrefs) //step through the collection
                {
                    ExternalFileReference xref = transdata.GetLastSavedReferenceData(xrefid); //get the Id of the link
                                 
                    if(xref.ExternalFileReferenceType == ExternalFileReferenceType.CADLink)//if its a dwg...
                    {
                        transdata.SetDesiredReferenceData(xrefid, new FilePath(dummyfile), xref.PathType, true); //"reload from"
                }
                transdata.IsTransmitted = true; //must do this, else these shenanigans wont work!
                TransmissionData.WriteTransmissionData(modelpath, transdata);
            }

"dummy" file is just filepath for whatever file you wish to load as a string.

Message 8 of 15

Hi,

 

This is exactly what I do but in addition I force the relative mode. But the absolute path appears.

 

Philippe.

Message 9 of 15
JimJia
in reply to: pmeigneux

Hi Philippe,

 

Please accept our sincerer apology for the delay! We had a backlog in the queue these days.

As we check with our engineering team with your question, they replied as below;

"User should not send in an absolute path. He should call transData.SetDesiredReferenceData(id,relativePath, PathType.Relative, true) in this case. I think he just wants “test site 2.dwg” for the path since the host and link are in the same folder. 

We don’t automatically relativize the path because SetDesiredReferenceData doesn’t know where the host file is. So you need to pass in a relative path if PathType.Relative, and an absolute path if PathType.Absolute."

 

Hope that can help you. We appreciate your cooperation and patience.


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 10 of 15
pmeigneux
in reply to: JimJia

Hi Jim,

 

Same code work perfectly for Revit link. I'm test again.

 

Philippe.

Message 11 of 15
pmeigneux
in reply to: JimJia

Hello,

 

I'm sorry but after opening the document,  the GetAbsolutePath () function return the old Path.

 

Philippe.

Message 12 of 15
pmeigneux
in reply to: pmeigneux

Hello,

 

I'm sorry but I don't receive any answer about my last reply.

 

We still have a problem after opening a document, the GetAbsolutePath () function return the old Path.

 

Thanks,

Message 13 of 15
JimJia
in reply to: pmeigneux

Please accept our sincerer apology for the delay! We had a backlog in the queue.
After our investigation, It looks there is an issue with API

TransmissionData.SetDesiredReferenceData with CAD Link. We’re checking with engineering team if it is indeed an issue or there is any other workaround. We will get back to you as soon as possible.

 


Jim Jia
Autodesk Forge Evangelist
https://forge.autodesk.com
Developer Technical Services
Autodesk Developer Network
Email: Jim.Jia@autodesk.com
Message 14 of 15
pmeigneux
in reply to: JimJia

Hello Jim,

 

Do you have any news about this issue from our engineering team?

 

Thanks for your support,

 

Message 15 of 15
draynorQNHWR
in reply to: pmeigneux

Bump, I'm running into similar issue. I'm running as an add-in to 2017, but hope it will work for all versions. We are moving to a new server and need to repath the server name for Revit & DWG links.

Thanks,

David Raynor

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community