Worksharing Central Filename

Here is a simple question that several people stumbled over and apparently can use some clarification:

Question: In Revit 2012, I used the Document WorksharingCentralFilename property to get the location of the central file.

This is marked as deprecated in Revit 2013, and the API suggests using GetWorksharingCentralModelPath instead.

In my experiments with a central file, I can use this function to obtain a ModelPath object which provides a property named CentralServerPath, but it is blank.

How can I recreate the functionality of the deprecated WorksharingCentralFilename property?

Answer: CentralServerPath is the wrong thing to call to get the path to the central model.
It is the path to Revit Server itself.

You obviously need to be clear about whether you are using Revit Server or file-based centrals.
The central server path for a file-based central is obviously blank.

The ModelPath class belongs to the

linked model related functionality
provided
in the Revit 2012 API, which also includes the ModelPathUtils class.

A ModelPath stores a path to a location on disk, a network drive, or a Revit Server location.

ModelPathUtils provides methods for converting between ModelPath and String.

When working with ModelPath objects, you can use the Compare method to test for equality or for ordering, the predicates IsServerPath and IsFilePath to test whether the path is file-based or server-based, and the ModelPathUtils ConvertModelPathToUserVisiblePath method to convert a ModelPath to a string.

The latter is demonstrated in the discussion of

listing linked files and the TransmissionData class
.

Other examples of using ModelPathUtils are given in the

ImportExport update
,

accessing central file TransmissionData on Revit Server
,

removing DWF links
,
and most esoterically for

selecting a face in a linked file
.


Comments

6 responses to “Worksharing Central Filename”

  1. Danny Polkinhorn Avatar
    Danny Polkinhorn

    Really? ModelPathUtils.ConvertModelPathToUserVisiblePath instead of ModelPath.ToString? Who thinks up this stuff? ;-)

  2. Dear Danny,
    Presumably the factory uses creativity enhancing substances. You might want to try some yourself. Who knows what you might come up with?
    The best thing about standards is, there are so many of them to choose from.
    Or as Groucho Marx put it:
    I have my principles! And if they don’t suit you, I have others as well!
    Cheers, Jeremy.

  3. I’m struggling to find the IsServerPath and IsFilePath predicates, and these do not appear to have been documented for 2013. Are there any samples that show these?

  4. Dear Fergus,
    Sorry, that is actually referring to the Boolean ModelPath.ServerPath property, which returns ‘whether this path is a server path or a file path’.
    Cheers, Jeremy.

  5. Ok.. It took me some time to get it, but this does the trick:
    string modelPathName = ModelPathUtils.ConvertModelPathToUserVisiblePath(myDoc.GetWorksharingCentralModelPath());
    Thanks, Billy

  6. Hi Billy Byron.
    I try to read the cental file path, but it is not enabled me.
    will you help me to the read cental file path into a TaskDialog??
    If you want help, I could post my code on an email to you.
    best regards
    Asger.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading