0

Is there any possibility for conversion from dwg to dgn using forge design automation api? If yes then what will be the best way to do that? Any suggestion would be helpful.

2 Answers2

0

Yes, you can use the -DGNEXPORT command in your script to accomplish this.

Albert Szilvasy
  • 461
  • 3
  • 5
0

I was trying to get a concrete codes for this question as it requires some tricks and support of seed file on Design Automation. By engineer team's help, now it is working.

Assume we test with Postman. If you are working with v2 of Design Automation, the scripts below demo the usage.

Activity:

{
  "HostApplication": "",
  "RequiredEngineVersion": "23.1",
  "Parameters": {
    "InputParameters": [{
      "Name": "HostDwg",
      "LocalFileName": "$(HostDwg)"
    }],
    "OutputParameters": [{
      "Name": "Result",
      "LocalFileName": "result.dgn"
    }]
  },
  "Instruction": {
    "CommandLineParameters": null,
    "Script":"(command \"_-DGNEXPORT\" \"_V8\" (strcat (getvar \"DWGPREFIX\") 
 \"result.dgn\") \"_Master\" \"Standard\" (strcat (getvar \"LOCALROOTPREFIX\") 
  \"Template\\\\V8-Imperial-Seed3D.dgn\"))\n"
  },
  "Version": 1,
  "Id": "CreateActByLISP"
}

WorkItem:

{
  "@odata.type": "#ACES.Models.WorkItem",
  "Arguments": {
    "InputArguments": [
      {
        "Resource": "http://forge-test.oss-cn-shanghai.aliyuncs.com/test.dwg",
        "Name": "HostDwg",
        "StorageProvider": "Generic"
      }
    ],
    "OutputArguments": [
      {
        "Name": "Result",
        "StorageProvider": "Generic",
        "HttpVerb": "POST",
        "Resource": null
      }
    ]
  },
  "ActivityId": "CreateActByLISP",
  "Id": ""
}

If working with v3 of Design Automation, the script would be as below. Note: the engine needs 23.1 (Autodesk.AutoCAD+23_1)

Activity

{
"commandLine": [
    "$(engine.path)\\accoreconsole.exe /i $(args[HostDwg].path) /s $(settings[script].path)"
],
"parameters": {
    "HostDwg": {
        "verb": "get",
        "description": "Host drawing to be loaded into acad.",
        "localName": "$(HostDwg)"
    },
    "Result": {
        "verb": "post",
        "description": "Results",
        "localName": "result.dgn"
    }
},
"engine": "Autodesk.AutoCAD+23_1",
"appbundles": [],
"settings": {
    "script": {
        "value": "(command \"_-DGNEXPORT\" \"_V8\" (strcat (getvar \"DWGPREFIX\") \"result.dgn\") \"_Master\" \"Standard\" (strcat (getvar \"LOCALROOTPREFIX\") \"Template\\\\V8-Imperial-Seed3D.dgn\"))\n"
    }
},
"description": "PlotToPdf for all layouts.",
 "id": "myexportdgn"
}

WorkItem:

{
 "activityId": "{{your nick name}}.myexportdgn+{{activity alias}}",
 "arguments": {
"HostDwg": {
  "url": "http://forge-test.oss-cn-shanghai.aliyuncs.com/test.dwg"
},
"Result": {
  "verb": "put",
  "url": "<your upload url>"
   }
 }
 }
Xiaodong Liang
  • 2,051
  • 2
  • 9
  • 14