1

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

M Scott
  • 45
  • 4
  • Do you have this issue recently? I think we made a change last year to allow workshared models to be opened by default. Anyway, does this [workaround](https://forge.autodesk.com/en/docs/design-automation/v3/developers_guide/troubleshooting/#revit) fit your case? – Emma Zhu Feb 18 '21 at 23:44
  • Your `picture` with the `failure message` is missing in the question. – Rahul Bhobe Feb 19 '21 at 00:24
  • @RahulBhobe, I have edited the original post and added the picture I was told that Forge API would not work on workshared models. I have not tried it recently. – M Scott Feb 19 '21 at 23:24
  • Looks like the error in the image (see at top it says: Define AppBundle and Activity only once.) is about something other than what you mention in the text. You are trying to replace the appbundle and activity with new code. You need to either delete the old appbundle and activity first or use appropriate api to `patch` them. – Rahul Bhobe Feb 20 '21 at 01:02
  • 1
    If you want to update the appbundle and activity, you need to delete the existing appbundle and activity first, then to create again... did you try to delete first? – Zhong Wu Feb 22 '21 at 01:14
  • @Zhong, Deleting the appbundle also results in failure. both deleting the app blundle and executing the plugin both result in failure. – M Scott Feb 22 '21 at 19:35

1 Answers1

2

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.

Rahul Bhobe
  • 4,165
  • 4
  • 17
  • 32