0

I want to apply ctb when creating activities and converting DWG files to PDF using Design Automation API.

In the PlotToPDF activity, the script was as follows

"Instruction": {
    "CommandLineParameters": "-suppressGraphics",
    "Script": "_layoutcreateviewport 1 _tilemode 0 -export _pdf _all result.pdf\n"
}

If want to apply a CTB file and convert it to PDF, the script is How should I write ?

Autodesk Design Automation API define Plot Settings e.g. greyscale/linewidth

I tried the script written here but got an error.

[04/19/2019 00:40:15] Command: -PLOT Detailed plot configuration? [Yes/No] <No>: Y 
[04/19/2019 00:40:15] Enter a layout name or [?] <レイアウト1>: Enter an output device name or [?] <なし>: AutoCAD PDF (General Documentation).pc3 Y myCTB.ctb 
[04/19/2019 00:40:15] <AutoCAD PDF (General Documentation).pc3 Y myCTB.ctb > not found. 
[04/19/2019 00:41:15] Error: AutoCAD Core Console is shut down due to timeout. 
[04/19/2019 00:41:15] End script phase. [04/19/2019 00:41:15] Error: An unexpected error happened during phase CoreEngineExecution of job.

I adjusted the command as follows.
-PLOT Y AutoCAD PDF (General Documentation).pc3\n\n\n Y\n\n\n\nY myCTB.ctb\n

The result is an error.

[04/19/2019 01:09:45] Command: -PLOT Detailed plot configuration? [Yes/No] <No>: Y 
[04/19/2019 01:09:45] Enter a layout name or [?] <レイアウト1>: Enter an output device name or [?] <なし>: AutoCAD PDF (General Documentation).pc3 
[04/19/2019 01:09:45] Enter paper size or [?] <ANSI A (11.00 x 8.50 Inches)>: 
[04/19/2019 01:09:45] Enter paper units [Inches/Millimeters] <Millimeters>: 
[04/19/2019 01:09:45] Enter drawing orientation [Portrait/Landscape] <Portrait>: Plot upside down? [Yes/No] <No>: Y 
[04/19/2019 01:09:45] Enter plot area [Display/Extents/Layout/View/Window] <Layout>:
[04/19/2019 01:09:45] Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <1:1>: 
[04/19/2019 01:09:45] Enter plot offset (x,y) <0.00,0.00>: 
[04/19/2019 01:09:45] Plot with plot styles? [Yes/No] <No>: Y Enter plot style table name or [?] (enter . for none) <>: myCTB.ctb 
[04/19/2019 01:10:46] Error: AutoCAD Core Console is shut down due to timeout. [04/19/2019 01:10:47] End script phase. 
[04/19/2019 01:10:47] Error: An unexpected error happened during phase CoreEngineExecution of job. 
XCoder
  • 31
  • 6

3 Answers3

1

You also can put the CTB download as a reference of your host drawing input argument. Your workitem will look like this:

{
    "activityId": "AutoCAD.PlotToPDF+prod",
    "arguments": {
        "HostDwg": {
            "url": "<download url to host drawing>",
            "headers": null,
            "references": [
                {
                    "localName": "myCTB.ctb",
                    "references": null,
                    "verb": "get",
                    "url": "<download url to ctb>"
                }
            ],
            "verb": "get"
        },
        "Result": {
            "headers": null,
            "url": "<upload url for result.pdf>",
            "verb": "put"
        }
    }
}
Qun Lu
  • 31
  • 1
  • Thank you for sample json. What is an activity called 'AutoCAD.PlotToPDF+prod'? There was nothing in the API that I could get at the URL of 'https://developer.api.autodesk.com/autocad.io/us-east/v2/Activities'. – XCoder Apr 17 '19 at 08:42
0

Assume your drawing already has "Plot style table" assigned to a particular customer CTB file. To make the CTB override(s) take effect, you just need to bring the CTB file together with your drawing file to Forge DA service. You can do so by: 1. Create an eTransmit package that includes the drawing file(s) and the CTB file (or any other supporting files you wish, like font files); 2. Specify the URL to the eTransmit zip file instead of the host drawing file as the input argument; 3. You can still use the "AutoCAD.PlotToPDF" activity and your CTB plot style should work then.

Qun Lu
  • 31
  • 1
  • Thank you for the advice. However, in the environment I'm assuming, a DWG file exists alone, and that file has a CTB setting. I do not have a corresponding CTB file, so I want to force application of a grayscale CTB file. – XCoder Apr 17 '19 at 08:32
  • See my example for v2 API (too long to post as an comment here). Sorry I did not realize that you are using v2 and the above example I gave is for v3. – Qun Lu Apr 17 '19 at 17:53
0

Here is an example for v2:

{
  "ActivityId": "PlotToPDF",
  "Arguments": {
    "InputArguments": [
      {
        "Resource": "{\"UserId\":null,\"Version\":0,\"Resource\":\"http://mystore.mycom.com/download/mydwg.dwg\",\"LocalFileName\":\"myDwg.dwg\",\"RelatedFiles\":[{\"UserId\":null,\"Version\":0,\"Resource\":\"http://mystore.mycom.com/download/myCTB.ctb\",\"LocalFileName\":\"myCTB.ctb\",\"RelatedFiles\":[]}]}",
        "Name": "HostDwg",
        "ResourceKind": "RemoteFileResource"
      }
    ],
    "OutputArguments": [
      {
        "Name": "Result",
        "Resource": "http://mystore.mycom.com/path/item/abcd",
        "HttpVerb": "POST"
      }
    ]
  }
}
Qun Lu
  • 31
  • 1
  • Thank you for the sample for V2 API. If myCTB is set to myDwg layout, then line changes have been applied on this work item. However, what I want to know is how to force application of myCTB when myDwg layout is set up other than myCTB. ex) I would like to output Dwg with a color line specified in grayscale Please tell me know if there is a solution for this. It's very troubled. – XCoder Apr 18 '19 at 13:29
  • I want to output all layouts in PDF with myCTB settings specified forcibly. – XCoder Apr 18 '19 at 13:32
  • So your problem now evolves to how to apply a CTB override before plotting. There are two commands, CONVERTCTB and CONVERTPSTYLES, that might help. But unfortunately these commands are ARX based and they are not supported in Design Automation. You may write your own app with a command to do the work though. – Qun Lu Apr 18 '19 at 18:23
  • @XCoder Take a look of this thread https://stackoverflow.com/questions/50684052/autodesk-design-automation-api-define-plot-settings-e-g-greyscale-linewidth?noredirect=1&lq=1. The "-plot" command gives you a choice for plot-time plot style override. – Qun Lu Apr 18 '19 at 23:48
  • I used to read this article and created and implemented the activity as per the article, but it didn't work with errors. – XCoder Apr 19 '19 at 00:51
  • Error Log `[04/19/2019 00:40:15] Command: -PLOT Detailed plot configuration? [Yes/No] : Y [04/19/2019 00:40:15] Enter a layout name or [?] <レイアウト1>: Enter an output device name or [?] <なし>: AutoCAD PDF (General Documentation).pc3 Y myCTB.ctb [04/19/2019 00:40:15] not found. [04/19/2019 00:41:15] Error: AutoCAD Core Console is shut down due to timeout. [04/19/2019 00:41:15] End script phase. [04/19/2019 00:41:15] Error: An unexpected error happened during phase CoreEngineExecution of job.` – XCoder Apr 19 '19 at 00:54
  • @QunLi I adjusted the command as follows. `-PLOT Y AutoCAD PDF (General Documentation).pc3\n\n\n Y\n\n\n\nY myCTB.ctb\n` – XCoder Apr 19 '19 at 01:25
  • @QunLi The result is an error. `[04/19/2019 01:09:45] Command: -PLOT Detailed plot configuration? [Yes/No] : Y [04/19/2019 01:09:45] Enter a layout name or [?] <レイアウト1>: Enter an output device name or [?] <なし>: AutoCAD PDF (General Documentation).pc3 [04/19/2019 01:09:45] Enter paper size or [?] : [04/19/2019 01:09:45] Enter paper units [Inches/Millimeters] : [04/19/2019 01:09:45] Enter drawing orientation [Portrait/Landscape] : Plot upside down? [Yes/No] : Y` – XCoder Apr 19 '19 at 01:28
  • `[04/19/2019 01:09:45] Enter plot area [Display/Extents/Layout/View/Window] : [04/19/2019 01:09:45] Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <1:1>: [04/19/2019 01:09:45] Enter plot offset (x,y) <0.00,0.00>: [04/19/2019 01:09:45] Plot with plot styles? [Yes/No] : Y Enter plot style table name or [?] (enter . for none) <>: myCTB.ctb [04/19/2019 01:10:46] Error: AutoCAD Core Console is shut down due to timeout. [04/19/2019 01:10:47] End script phase. [04/19/2019 01:10:47] Error: An unexpected error happened during phase CoreEngineExecution of job.` – XCoder Apr 19 '19 at 01:29