Warm tip: This article is reproduced from serverfault.com, please click

How can i force design automation to open detached model?

发布于 2021-02-18 23:09:41

Question about the Design Automation API.

Is it possible to create a Design Automation script that removes worksharing so that Design Automation can work on the rest of the file and then throw that file away.

For example, can i use Design Automation to strip out the worksets and then proceed to export parameters for the file without saving over the workshared version?

Also, I am connected to the Revit Excel Import and Export Demo.

Whenever i configure the AppBundle I get a failure message as shown in the picture below:

enter image description here

Questioner
M Scott
Viewed
0
Rahul Bhobe 2021-02-19 08:32:51

To open the workshared model with worksets discarded, you will need to:

  1. Remove the /i option from the commandLine in your activity. Specify an hardcoded localName in for your input argument (say input.rvt). Like so
{
  "alias": "prod",
  "activity": {
    "id": "YourActivity",
    "commandLine": [ "$(engine.path)\\\\revitcoreconsole.exe /al $(appbundles[YourBundle].path)" ],
    "parameters": {
      "rvtFile": {
        "zip": false,
        "ondemand": false,
        "verb": "get",
        "description": "Input Revit model",
        "required": true,
        "localName": "input.rvt",
      }
    },
    "engine": "Autodesk.Revit+2020",
    "appbundles": [ "YourName.YourBundle+label" ],
    "description": "Bundle description."
  }
}
  1. Open the file input.rvt in your app bundle using DetachAndDiscardWorksets like so:
   ModelPath path = ModelPathUtils.ConvertUserVisiblePathToModelPath("input.rvt");
   var opts = new OpenOptions
   {
      DetachFromCentralOption = DetachFromCentralOption.DetachAndDiscardWorksets
   };
   var document = application.OpenDocumentFile(path, opts);

For related details, you may refer the blog announcement and an earlier related stack overflow answer.

By default, (following the blog announcement) Design Automation will try to open workshared models with DetachAndPreserveWorksets if the /i option is provided in the commandLine. This will however work only if the input file is a central file. It will not work for a local file with worksets, as the file is owned by a certain user.