Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Function to open RevitServer and CloudModels with xUnitRevit #36

Open
agnBIM opened this issue Jan 16, 2024 · 0 comments
Open
Labels
enhancement New feature or request question Further information is requested

Comments

@agnBIM
Copy link

agnBIM commented Jan 16, 2024

We needed to be able to open models from our Revit server with xUnitRevit and couldn't find a solution in the existing repo.

This is now the only way to open a model:

/// <summary>
/// Opens and activates a document if not open already
/// </summary>
/// <param name="filePath">Path to the file to open</param>
public static Document OpenDoc(string filePath)
{
  Assert.NotNull(Uiapp);
  Document doc = null;
  //OpenAndActivateDocument only works if run from the current context
  UiContext.Send(x => doc = Uiapp.OpenAndActivateDocument(filePath).Document, null);
  Assert.NotNull(doc);
  return doc;
}

So we added the OpenDoc() function with the correct parameters for cloud/server models from the Revit API to the xru class in the xUnitRevitUtils:

/// <summary>
/// Opens and activates a document from server or cloud
/// </summary>
/// <param name="filePath">Path to the file to open</param>
/// <param name="openOpts">Opening Options for Cloud Models</param>
/// <param name="detach">Boolean to determine if file should be detached from central</param>
public static Document OpenDoc(string filePath, OpenOptions openOpts, Boolean detach)
{
  Assert.NotNull(Uiapp);
  Document doc = null;
  //OpenAndActivateDocument only works if run from the current context
  UiContext.Send(x => doc = Uiapp.OpenAndActivateDocument(ModelPathUtils.ConvertUserVisiblePathToModelPath(filePath), openOpts, detach).Document, null);
  Assert.NotNull(doc);
  return doc;
}

Do more people feel the need for this feature? If so, we would prepare a PR for it.

@agnBIM agnBIM added enhancement New feature or request question Further information is requested labels Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant