Skip to content

Sample Revit Addin for exporting views (2D & 3D) to DWG via the Design Automation for Revit

License

Notifications You must be signed in to change notification settings

ADN-DevTech/revit-automation-dwg-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sample - Export DWG from Revit files with Design Automation

Design-Automation

Windows .NET Revit

Advanced MIT

Descriptions

This sample demonstrates how to implement Revit DWG exporter using Revit API.

Note

This project is just a code sample demonstrating the possibilities of implementing an Revit DWG exporter using Revit API, and run it on APS Design Automation API for Revit, which means we don't cover all tests on this sample. So, it would be fail in particular cases that we don't consider or we don't cover in the tests.

Therefore, please don't use it on your production applications directly. If you want to use this sample directly on your production applications, then you must use this sample at your own risk.

Thumbnail

  • Revit 3D view to 3D DWG

    thumbnail

  • Revit 2D view to 2D DWG

    thumbnail-2

APS DA Setup

Activity via POST activities

{
    "commandLine": [
        "$(engine.path)\\\\revitcoreconsole.exe /i \"$(args[inputFile].path)\" /al \"$(appbundles[DwgExporter].path)\""
    ],
    "parameters": {
        "inputFile": {
            "verb": "get",
            "description": "Input Revit File",
            "required": true,
            "localName": "$(inputFile)"
        },
        "inputJson": {
            "verb": "get",
            "description": "input Json parameters",
            "localName": "params.json"
        },
        "outputDwg": {
            "zip": true,
            "verb": "put",
            "description": "Exported DWG files",
            "localName": "exportedDwgs"
        }
    },
    "id": "yoursalias.DwgExporterActivity+dev",
    "engine": "Autodesk.Revit+2021",
    "appbundles": [
        "yoursalias.DwgExporter+dev"
    ],
    "settings": {},
    "description": "Activity of exporting DWG from RVT",
    "version": 1
}

Workitem via POST workitems

  • Export DWG by predefined export DWG setup and given view set name
{
    "activityId": "yoursalias.DwgExporterActivity+dev",
    "arguments": {
   "inputFile": {
     "verb": "get",
     "url": "https://developer.api.autodesk.com/oss/v2/signedresources/...?region=US"
   },
   "inputJson": {
     "verb": "get",
     "url": "data:application/json,{ 'exportSettingName': 'my-dwg-export', 'viewSetName': 'CAD Export' }"
   },
   "outputDwg": {
     "verb": "put",
     "url": "https://developer.api.autodesk.com/oss/v2/signedresources/...?region=US"
   }
 }
}
  • Export DWG by given view set name and active predefined export DWG setup
{
    "activityId": "yoursalias.DwgExporterActivity+dev",
    "arguments": {
   "inputFile": {
     "verb": "get",
     "url": "https://developer.api.autodesk.com/oss/v2/signedresources/...?region=US"
   },
   "inputJson": {
     "verb": "get",
     "url": "data:application/json,{ 'viewSetName': 'CAD Export' }"
   },
   "outputDwg": {
     "verb": "put",
     "url": "https://developer.api.autodesk.com/oss/v2/signedresources/...?region=US"
   }
 }
}
  • Export DWG by predefined export DWG setup and specific view ids
{
    "activityId": "yoursalias.DwgExporterActivity+dev",
    "arguments": {
   "inputFile": {
     "verb": "get",
     "url": "https://developer.api.autodesk.com/oss/v2/signedresources/...?region=US"
   },
   "inputJson": {
     "verb": "get",
     "url": "data:application/json,{ 'exportSettingName': 'my-dwg-export', 'viewIds': [ '44745acb-ebea-4fb9-a091-88d28bd746c7-000ea86d', 'c3f5348f-6947-4ddf-aa1e-749882f86acc-00000138' ] }"
   },
   "outputDwg": {
     "verb": "put",
     "url": "https://developer.api.autodesk.com/oss/v2/signedresources/...?region=US"
   }
 }
}
  • Export DWG by modifying predefined export DWG setup on the fly and specific view ids
{
    "activityId": "yoursalias.DwgExporterActivity+dev",
    "arguments": {
   "inputFile": {
     "verb": "get",
     "url": "https://developer.api.autodesk.com/oss/v2/signedresources/...?region=US"
   },
   "inputJson": {
     "verb": "get",
     "url": "data:application/json,{ exportSettingName': 'my-dwg-export', 'viewIds': [ '44745acb-ebea-4fb9-a091-88d28bd746c7-000ea86d' ], 'applyCustomSettings': true, 'customSettings': { 'solidMode': 'ACIS' }}"
   },
   "outputDwg": {
     "verb": "put",
     "url": "https://developer.api.autodesk.com/oss/v2/signedresources/...?region=US"
   }
 }
}
  • Export DWG by creating export DWG setup on the fly and specific view ids
{
    "activityId": "yoursalias.DwgExporterActivity+dev",
    "arguments": {
   "inputFile": {
     "verb": "get",
     "url": "https://developer.api.autodesk.com/oss/v2/signedresources/...?region=US"
   },
   "inputJson": {
     "verb": "get",
     "url": "data:application/json,{ 'viewIds': [ '44745acb-ebea-4fb9-a091-88d28bd746c7-000ea86d' ], 'applyCustomSettings': true, 'customSettings': { 'useSharedCoords': true, 'targetUnit': 'millimeter' }}"
   },
   "outputDwg": {
     "verb": "put",
     "url": "https://developer.api.autodesk.com/oss/v2/signedresources/...?region=US"
   }
 }
}
  • Export DWG using default export DWG setup for all Revit views
{
    "activityId": "yoursalias.DwgExporterActivity+dev",
    "arguments": {
   "inputFile": {
     "verb": "get",
     "url": "https://developer.api.autodesk.com/oss/v2/signedresources/...?region=US"
   },
   "inputJson": {
     "verb": "get",
     "url": "data:application/json,{ 'exportAllViews': true, 'includingRenderingViews': false }"
   },
   "outputDwg": {
     "verb": "put",
     "url": "https://developer.api.autodesk.com/oss/v2/signedresources/...?region=US"
   }
 }
}

Tips & Tricks

  1. This sample was only tested with Revit 2023, if you want to use it with newer Revit versions (e.g. Revit 2024), you must recompile the source code with corresponding Revit API version.

  2. This addin will find below export DWG setups in the input RVT file. if nothing matched found , it will use default settings of Revit API.

    • Export DWG setup with the given name in the exportSettingName of the inputJson.
    • Active predefined export DWG setup.
    • If there is no predefined export DWG setup found in the RVT file, it will create an export DWG setup with default configurations.
  3. You can specify views to be exported by either viewIds or viewSetName of the inputJson.

  4. To export Revit 3D view to 3D DWG and have the elements being exported as 3d solids, the solid style of export DWG setups must be ACIS solids (see AKN).

  5. You can specify "exportAllViews": true in the inputJson to export all views within the RVT file. By default, it will exclude all views of rendering view type, which are created by Autodesk Render. If you wan to included rendered images of the rendering views, you can specify "includingRenderingViews": true in the inputJson

Limits

  • Currently, this add-in supports creating/modifying export DWG setup on the fly, but only TargetUnit, UseSharedCoords and SolidMode of CustomSettings.cs are tested. Feel free to add more options by uncommenting codes at MainApp.cs#L321.

License

This sample is licensed under the terms of the MIT License. Please see the LICENSE file for full details.

Written by

Eason Kang in/eason-kang-b4398492/, Developer Advocacy and Support Team

About

Sample Revit Addin for exporting views (2D & 3D) to DWG via the Design Automation for Revit

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages