Determine central file type: file, server, our cloud

Determine central file type: file, server, our cloud

kudzuman
Advocate Advocate
2,166 Views
5 Replies
Message 1 of 6

Determine central file type: file, server, our cloud

kudzuman
Advocate
Advocate

At one point Autodesk.Revit.DB.Document.IsModelInCloud worked in Revit 2016. Now it is not accessible because it is friend.

I was using that and ServerPath of ModelPath to find out if a central file was file based (not in Collaboration for Revit or Revit Server).

 

What is a good way to determine if a central file is not in Collaboration for Revit or Revit Server?

 

Is GetModelGUID of ModelPath related to Collaboration for Revit or just A360 in general? Maybe if that is null or empty I know it's not in Collaboration for Revit?

0 Likes
Accepted solutions (1)
2,167 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

Dear Kudzuman,

 

Thank you for your query.

 

I was not aware of the Autodesk.Revit.DB.Document.IsModelInCloud property, nor do I see it in the Revit 2016 or 2017 API help.

 

Are you sure that is not an extension method of your own?

 

Where does it come from?

 

What version of Revit 2016 are you talking about?

 

Here are the current remarks on the ModelPath class description:

 

ModelPaths are paths to another file. They can refer to Revit models, or to any of Revit's external file references (DWG links, for example.) Paths can be relative or absolute, but they must include an extension indicating what kind of file it is. Relative paths are generally relative to the currently opened document. If the current document is workshared, paths will be treated as relative to the central model. To create a ModelPath, use the derived classes FilePath and ServerPath. The class ModelPathUtils contains utility functions for converting ModelPaths to and from strings.

 

Have you tested what happens when you cast the ModelPath to one of the derived classes, FilePath or ServerPath?

 

Another piece of functionality that you should probably be aware of in the context of model paths is the TransmissionData class:

 

http://thebuildingcoder.typepad.com/blog/2011/11/access-transmissiondata-of-central-file-on-revit-se...

 

Have you explored using that?

 

Meanwhile, I'll ask the development team whether they have an offhand suggestion for you.

 

I am confident we will discover an easy resolution to this.

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 6

kudzuman
Advocate
Advocate

Thanks Jeremy.

 

I'll take a look at casting the derived classes. That may be my best bet. Everything else gives out data indicating a connection to Revit Server or not. It is the "or not" I am having trouble with. If it is not a Revit Server central file then that still leaves you 2 choices: file-based or Collaboration for Revit. I could also play with getting the central file path and examine it. There may be string patterns that indicate which of the 3 types a central file could be.

 

IsModelInCloud is not an extension method of my own. I found it via intellisense in VS referencing the dlls from the original build of Revit 2016. I suppose a subsequent update nixed it.

0 Likes
Message 4 of 6

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Kudzuman,

 

Thank you for your update.

 

Yes, exactly. Good idea.

 

Everything you say and surmise is confirmed by the development team.

 

I heard back from them already, and they say:

 

IsModelInCloud was implemented as 'public_api’ by mistake and changed to 'public_api_internal’ since 11/27/2013.

 

It is unfortunate that you were able to use it.

 

It does not belong to the officially published API, even it was temporarily visible by mistake at that time.

 

Sorry about that!

 

So how to identify whether a model is a file-based work-shared model or hosted by Collaboration for Revit or Revit Server?

 

So far, there is no exposed API for this.

 

We may expose one in the future.

 

Here is a workaround that you can try out:

 

  1. Get central ModelPath of the document;
  2. Convert ModelPath to a user visible path using 'ModelPathUtils::ConvertModelPathToUserVisiblePath(ModelPath &)'
  3. Decide based on the user visible path as follows:

 

  • Is it a unc path such as \\shareServer\central.rvt or c:\my document\central.rvt?
  • If not:
    • Starting with RSN://, it is a Revit server model
    • Starting with A360://, it is a Collaboration for Revit model 

 

The A360 prefix may be changed to BIM 360 at some point.

 

As always, when making use of workaround, you should use at your own risk and include regular (daily) unit tests in your development process to verify that this approach really does work under all circumstances that you encounter and care about.

 

I hope this helps.

 

Please do let us know whether this solved the issue for you, preferrably including a sample code snippet.

 

Thank you!

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 6

kudzuman
Advocate
Advocate

The workaround works for me, although I didn't test it against a central file in a Revit Server environment as we don't use that.

Here is the simple bit of code that tests the central file type:

    Public Shared Function ReportCentralFileType(ByVal _mpath As ModelPath) As String
        Dim strR As String = ModelPathUtils.ConvertModelPathToUserVisiblePath(_mpath)
        If strR.Substring(0, 2) = "\\" Or strR.Substring(1, 2) = ":\" Then
            strR = "File-Based: " & strR
        ElseIf strR.Substring(0, 3) = "RSN" Then
            strR = "RevitServer-Based: " & strR
        ElseIf strR.Substring(0, 4) = "A360" Then
            strR = "C4R-Based: " & strR
        Else
            strR = "Unknown: " & strR
        End If
        Return strR
    End Function
0 Likes
Message 6 of 6

jeremytammik
Autodesk
Autodesk

Wonderful! Thank you for the confirmation and working sample!



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes