2

We have a design automation application for Revit that handles models from BIM 360 and we would like to open models using our own process so we can modify what worksets are opened, etc. We have found the link at https://www.autodesk.com/autodesk-university/class/Getting-Started-Design-Automation-Revit-Forge-2019#handout. According to that, though, you have to hard code the name of the rvt file as a specific name in order to open it. However, we have some places that the name of the model is used in the exported data so we would like to keep the name as it originally appeared.

Is it possible to reference the command arguments from within the application? Right now we have our parameter for the model on the activity defined as follows:

    "rvtFile": {
        "zip": false,
        "ondemand": false,
        "verb": "get",
        "description": "Input Revit Model",
        "required":true,
        "localName": "$(rvtFile)"
    },

And the command line looks like this:

"commandLine":["$(engine.path)\\\\revitcoreconsole.exe /i \"$(args[rvtFile].path)\" /al \"$(appbundles[{{ BundleId  }}{{ RevitVersion }}].path)\""]

So the local name is dynamic and is just opened by DA using the command line. However since we want to control the opening process we need to pull the Revit file out of the command line and be able to figure out the path to the file to be opened. I'm not sure how to do this reliably since it's dynamic; any help would be appreciated.

sfaust
  • 2,089
  • 28
  • 54

1 Answers1

1

Following the blog announcement, Design Automation for Revit (revitcoreconsoole.exe) by default preserves the worksets for /i \"$(args[rvtFile].path)\" arguments. You no longer have to use the hard coded name on the input file and try opening the model yourself. You should be able to use dynamic file name.

Improved the default behavior for opening and saving models that have worksharing enabled, in order to preserve worksets on open, and support saving the model as a new central.

Rahul Bhobe
  • 4,165
  • 4
  • 17
  • 32
  • Ok but that's not all we want to do. We want to close all worksets on open, plus we have some tests we want to do on the model before actually opening it as well. I'm assuming that would still need a manual open process right? – sfaust Jul 06 '21 at 14:52
  • Did you mean detach worksets? For detaching worksets you will still need hard coded name and manual open (as per [this answer](https://stackoverflow.com/a/66269948/11057988)). – Rahul Bhobe Jul 06 '21 at 15:01
  • Yes, I see now. You will also not be able to use `OpenOptions.SetOpenWorksetsConfiguration()` through `/i \"$(args[rvtFile].path)\"`. For any custom workset open configs you will need to hard code the name as well. – Rahul Bhobe Jul 06 '21 at 15:41
  • Hm, bummer. Is there any good way to get the original file name out of it? Would we need to pass it in some type of configuration file to the application from the outside? – sfaust Jul 08 '21 at 18:59
  • @sfaust, if I understand correctly, you just want to handle the inputs by addin itself, but the inputs' names could be variable and your addin just needs to know their names? (There seems not much related to how to open worksets since this could apply to other cases) – Emma Zhu Jul 08 '21 at 20:50
  • Basically yes. I guess you are right, while our use case is currently focused on worksets, yes it could apply to most anything that would require you to have a correctly named file and do the opening yourself. – sfaust Jul 09 '21 at 14:52
  • If this is the case, Design Automation always downloads the inputs in current working folder, your addin could just search them out from the current working folder. Or if you know the inputs name when posting WorkItem, you can also pass the names as a json argument in WorkItem and then the addin can read names from there. Do these approaches make sense? – Emma Zhu Jul 09 '21 at 16:59
  • This might also be useful: https://forge.autodesk.com/blog/handle-command-line-arguments – Adam Nagy Aug 26 '21 at 12:06