This sample enables the creation of custom geometry with custom property metadata, fully supported by ACC (Autodesk Construction Cloud) and BIM360. It empowers developers by providing access to the AutoCAD geometry engine through the Design Automation API.
Design Automation for AutoCAD allows you to generate a collaboration file containing various viewable assets. This file, recognizable by any LMV-based application, can be hosted on Autodesk Construction Cloud for model viewing.
The Model Derivative API translates over 60 file formats into derivatives (output files), including the collaboration format. While the AutoCAD API directly generates collaboration files from 3D drawings, the Design Automation service's API offers greater flexibility. It allows you to not only generate these files but also manipulate the properties of the 3D model within them.
This project focuses on removing generic properties associated with the 3D model. We retain only basic model objects with identifying properties like Name and Handle
ID. This is achieved by parsing filter.json, which contains a list of properties to be extracted.
Handles
are unique identifiers within a single AutoCAD DWG database. They are 64-bit integers introduced before AutoCAD R13 and persist across sessions. However, handles are not unique across different databases. Since all databases start with the same initial handle value, duplication is almost guaranteed.
Refer Supported Translation document.
COLLABORATION | SVF SVF2 Thumbnail |
---|
Objective: Extract data from a solid entity in an AutoCAD drawing, remove built-in properties, and add custom properties.
-
Setup
- Initialize necessary variables and constants.
- Register a custom application name ("CARBON_NEGATIVE").
-
Find Solid Entity
- Open the current document.
- Retrieve the solid entity by its handle ("14A37").
- If the entity is not found, log a message and exit.
-
Transaction Management
- Start a transaction to modify the drawing database.
- Open the block table and block table record.
- Check and register the application in the
RegAppTable
.
-
Add Custom Properties
- Check if the solid entity already has custom properties.
- If not, add custom XData properties to the solid entity.
-
Load and Hook Events
- Load
LMVExport.crx
for exporting. - Hook the
EndExtraction
event.
- Load
-
Prepare for Extraction
- Set the current working directory.
- Determine the output collaboration file path.
-
Run Export Command
- Check if running in Design Automation environment.
- Load the
filter.json
file for property extraction. - Run the
LMVEXPORT
command to extract properties based on the filter.
-
Create Collaboration Package
- Load
AcShareViewPropsCore.dll
. - Create a collaboration package using
_CREATESIMPLESHAREPACKAGE
.
- Load
-
Unhook Events
- Unhook the
EndExtraction
event.
- Unhook the
-
Handle Extraction End Event
- Log the end of the extraction process.
- Start a new transaction to read the entity.
- Add additional custom properties to the solid entity.
{
"AcDbObject": [
null,
"Handle"
]
}
This JSON filter specifies that only the Handle
property should be extracted from the solid entity.
Change directory to where the drawing file is located
mkdir Collaboration
cd Collaboration
touch filter.json
D:\LMV
│ - House.dwg
└───Collaboration
- filter.json
Steps to produce collaboration file, DWGEXTRACTOR
will produce a output directory relative to the index.json
cd "AutoCAD 2025"
accoreconsole.exe /i input.dwg
_LMVEXPORT
D:\LMV\Collaboration\filter.json
_NETLOAD
AcShareViewPropsCore.dll
_CREATESIMPLESHAREPACKAGE
D:\LMV\Collaboration
D:\LMV\Collaboration\House.collaboration
CREATESIMPLESHAREPACKAGE
is a thin AutoCAD command wrapper for the Simple Share Data Wrapper API.- Which expects a input folder, which is
output
folder created byLMVEXPORT
command. - Which expects a output file, which is
collaboration
file.
- Which expects a input folder, which is
filter.json
a config file to tellLMVEXPORT
what properties to extract from the seed drawing file.
The .collaboration
file can be uploaded to Viewer or ACC
- NOTE: Alternatively, you can execute runlocal.bat
- APS Account: Learn how to create a APS Account, activate your subscription, and create an app at this tutorial.
- Add a callback url :
http://localhost:8080/api/auth/callback
- ACC Account: must be Account Admin to add the app integration. Learn about provisioning.
- Visual Studio: Either Community 2022 (Windows) or Code (Windows, MacOS).
- .NET 8.0 basic knowledge with C#
- JavaScript basic knowledge.
Clone this project or download it. It's recommended to install GitHub Desktop. To clone it via command line, use the following (Terminal on MacOSX/Linux, Windows Terminal on Windows):
Steps to followed in VS 2022 Developer Command Prompt
git clone https://git.autodesk.com/moogalm/autocad-da-acc-model-viewer.git
cd autocad-da-acc-model-viewer
touch appsettings.user.json
- Open
appsettings.user.json
in any text editor and following JSON with your APS Credentials.
{
"APS_CLIENT_ID": "",
"APS_CLIENT_SECRET": "",
"APS_CALLBACK_URL": "http://localhost:8080/api/auth/callback",
"Forge": {
"ClientId": "",
"ClientSecret": ""
}
}
dotnet restore
dotnet build
dotnet watch --project aps-acc-da
- execute `dotnet restore && dotnet build && dotnet watch --project aps-acc-da`
Determining projects to restore...
All projects are up-to-date for restore.
Determining projects to restore...
All projects are up-to-date for restore.
aps-acc-da -> D:\Work\Projects\2024\autocad-da-acc-model-viewer\aps-acc-da\bin\Debug\net8.0\aps-acc-da.dll
LMVExtractor -> D:\Work\Projects\2024\autocad-da-acc-model-viewer\CLBPlugin\bin\Debug\net8.0-windows\LMVExtractor.dll
Zipping directory "D:\Work\Projects\2024\autocad-da-acc-model-viewer\CLBPlugin\Bundle" to "D:\Work\Projects\2024\autocad-da-acc-model-viewer\aps-acc-da\App_Data\LMVExtractor.bundle.zip".
-rw-rw-r-- 0 0 0 899 Jul 09 02:16 LMVExtractor.bundle/PackageContents.xml
-rw-rw-r-- 0 0 0 915 Jul 09 02:16 LMVExtractor.bundle/Contents/filter.json
-rw-rw-r-- 0 0 0 1788 Jul 09 15:41 LMVExtractor.bundle/Contents/LMVExtractor.deps.json
-rw-rw-r-- 0 0 0 8704 Jul 09 15:41 LMVExtractor.bundle/Contents/LMVExtractor.dll
-rw-rw-r-- 0 0 0 12028 Jul 09 15:41 LMVExtractor.bundle/Contents/LMVExtractor.pdb
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.75
dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.
💡 Press "Ctrl + R" to restart.
dotnet watch 🔧 Building...
Determining projects to restore...
All projects are up-to-date for restore.
aps-acc-da -> D:\Work\Projects\2024\autocad-da-acc-model-viewer\aps-acc-da\bin\Debug\net8.0\aps-acc-da.dll
dotnet watch 🚀 Started
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://localhost:8080
info: Microsoft.Hosting.Lifetime[0]
Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
Content root path: D:\Work\Projects\2024\autocad-da-acc-model-viewer\aps-acc-da
-
Download the project or clone from Github
-
Open
autocad-da-acc-model-viewer.sln
in Visual StudioOpen Your Project:
- Open your project in Visual Studio.
-
Add
appsettings.user.json
File:- Right-click on your project in the Solution Explorer.
- Select Add > New Item.
-
Choose JSON File Template:
- In the dialog that appears, select JSON File.
- Name the file
appsettings.user.json
. - Click Add.
-
Edit
appsettings.user.json
File:- Once added, the
appsettings.user.json
file will appear in your Solution Explorer. - Double-click the file to open it in the editor.
- Add your configuration settings in JSON format with APS credentials.
- Here is an example configuration
- Once added, the
{
"APS_CLIENT_ID": "",
"APS_CLIENT_SECRET": "",
"APS_CALLBACK_URL": "http://localhost:8080/api/auth/callback",
"Forge": {
"ClientId": "",
"ClientSecret": ""
}
}
-
Make sure the
appsettings.user.json
file is set to Copy to Output Directory if needed. Right-click the file, select Properties, and set Copy to Output Directory to Copy if newer. -
Modify
Startup.cs
to Load Configuration: -
Ensure your
Startup.cs
file is configured to load theappsettings.user.json
file -
appsettings.user.json
serves two purposes-
You can inject the
IConfiguration
service to access the settings in yourappsettings.user.json
file to anyController
class. -
Forge
section in theappsettings.user.json
file is injected by the APS Design Automation SDK to facilitate DA API requests.
-
-
Setup Project Profile:
-
Right-click on your project in the Solution Explorer and select "Properties" from the context menu.
-
Alternatively, you can select the project and press
Alt+Enter
. -
In the properties window, go to the "Debug" tab. This tab allows you to configure different settings for debugging and running your project.
-
In the "Launch" section, you will see different profiles such as "Project", "IIS Express", etc.
- Select the profile you want to configure from the drop-down menu or click on "Create new profile" to set up a custom profile.
Once the NuGet packages are restored, you can build the project:
-
Build the Solution:
- Using Solution Explorer:
- Right-click on the solution or the specific project in Solution Explorer.
- Select
Build
orRebuild
.
- Using the Menu:
- Go to
Build
on the top menu. - Select
Build Solution
(shortcut:Ctrl+Shift+B
). - Alternatively, select
Rebuild Solution
to clean and build the solution from scratch.
- Go to
- Using Solution Explorer:
-
Check the Output Window:
- After starting the build process, you can monitor the progress and see any errors or warnings in the Output window.
- Go to
View
>Output
or pressCtrl+Alt+O
to open the Output window.
- Missing NuGet Packages:
- Ensure that the NuGet package sources are correctly configured.
- Go to
Tools
>NuGet Package Manager
>Package Manager Settings
and check thePackage Sources
.
- Build Errors:
- Review the errors in the Error List window (
View
>Error List
orCtrl+\\
+Ctrl+E
). - Address any missing references, incorrect configurations, or syntax errors as indicated.
- Review the errors in the Error List window (
-
Clean Solution:
- If you encounter build issues, try cleaning the solution before rebuilding.
- Go to
Build
>Clean Solution
.
-
Project Dependencies:
- Ensure that project dependencies are correctly configured in Solution Explorer.
- Right-click the solution, select
Project Dependencies
, and verify the dependencies.
-
Rebuild All Projects:
- If you have multiple projects, you can rebuild all of them by selecting
Rebuild Solution
instead of building individual projects.
- If you have multiple projects, you can rebuild all of them by selecting
git clone https://git.autodesk.com/moogalm/autocad-da-acc-model-viewer.git
cd autocad-da-acc-model-viewer
cd CLBPlugin
dotnet build
runlocal.bat
-
Open the Browser:
- Navigate to http://localhost:8080 in your web browser.
-
Login:
- Click the
Login
button. - Follow the subsequent steps in the authentication flow.
- Click the
-
Access the Hubs Browser:
- In the sidebar, a Tree panel will appear, displaying the hubs browser.
-
Select a Folder:
- To traverse through the projects, select any folder by clicking on the
+
buttons to expand the tree items.
- To traverse through the projects, select any folder by clicking on the
-
Submit for Design Automation:
- Click the
submit
button. This action initiates a Design Automation process by submitting a workitem with details such as hub, project, and folder data. This process allows for the upload of a collaboration file created by executing an activity designed to run AutoCAD core commands.
- Click the
-
Notification:
- A notification bubble will appear on the selected folder, indicating that an item has been created.
-
View and Copy Logs:
- You can click the
copy
button to copy the log. - Scroll down to view the Design Automation workitem log.
- You can click the
Madhukar Moogala