-3

My requirement is to convert DWG to DXF , need quick help to understand the process using Design API v3 and .net c# , and I want to use all DWG files from local computer and output also should happen locally. There is no reference for this anywhere , I am totally new to Design Automation API.

`

 var workItemStatus = await api.CreateWorkItemAsync(new WorkItem()
            {
                ActivityId = myActivity,
                Arguments = new Dictionary<string, IArgument>()
                {
                    { "input", new XrefTreeArgument() { Url = UploadUrl } },
                    { "params", new XrefTreeArgument() { Url = $"data:application/json, {JsonConvert.SerializeObject(new CrxApp.Parameters { ExtractBlockNames = true, ExtractLayerNames = true })}" } },
                    { "result", new XrefTreeArgument() { Verb=Verb.Put, Url = DownloadUrl } }
                }
            });

`

1 Answers1

0

Also want to understand the params to convert from DWG to DXF, I have no AutoCad installed. Ex. "params", new XrefTreeArgument()

  1. Send drawing input url
  2. DXFOUT
  3. Send dxf output url.

Sample Activity Spec in .NET core

private async Task<string> SetupActivityAsync(string myApp = null)
    {
        Console.WriteLine("Setting up activity...");
        var myActivity = $"{Owner}.{ActivityName}+{Label}";
        var actResponse = await this.api.ActivitiesApi.GetActivityAsync(myActivity, throwOnError: false);
        /*
         * The default or basic CommandLine syntax, for this application we don't need bundle.
         *     CommandLine = new List<string>()
                {
                    $"$(engine.path)\\accoreconsole.exe /i $(args[inputFile].path) /al $(appbundles[{PackageName}].path) /s $(settings[script].path)"
                },
         */

        var activity = new Activity()
        {
           
            CommandLine = new List<string>()
                {
                    $"$(engine.path)\\accoreconsole.exe /i $(args[inputFile].path) /s $(settings[script].path)"
                },
            Engine = TargetEngine,
            Settings = new Dictionary<string, ISetting>()
                {
                    { "script", new StringSetting() { Value = "DXFOUT\nresult.dxf\n\n" } }
                },
            Parameters = new Dictionary<string, Parameter>()
                {
                    { "inputFile", new Parameter() { Verb= Verb.Get, LocalName = "$(HostDwg)",  Required = true } },                       
                    { "outputFile", new Parameter() { Verb= Verb.Put,  LocalName = "result.dxf", Required= true} }
                },
            Id = ActivityName
        };
        if(myApp != null)
        {
            activity.Appbundles = new List<string>()
                {
                    myApp
                };
        }
        if (actResponse.HttpResponse.StatusCode == HttpStatusCode.NotFound)
        {
            Console.WriteLine($"Creating activity {myActivity}...");
            await api.CreateActivityAsync(activity, Label);
            return myActivity;
        }
        await actResponse.HttpResponse.EnsureSuccessStatusCodeAsync();
        Console.WriteLine("\tFound existing activity...");
        if (!Equals(activity, actResponse.Content))
        {
            Console.WriteLine($"\tUpdating activity {myActivity}...");
            await api.UpdateActivityAsync(activity, Label);
        }
        return myActivity;

        
    }
Madhukar Moogala
  • 635
  • 1
  • 5
  • 11
  • Thank you Madhukar. Are below the places where I can give my local folder and file names : { "inputFile", new Parameter() { Verb= Verb.Get, LocalName = "$(HostDwg)", Required = true } }, { "outputFile", new Parameter() { Verb= Verb.Put, LocalName = "result.dxf", Required= true} } And do I need to do anything here ? : { "script", new StringSetting() { Value = "DXFOUT\nresult.dxf\n\n" } – prasanta mohanty Jun 25 '20 at 13:17
  • Here is what I tried and got error: 1. I have passed input and output through SubmitWorkItemAsync 2. and SetupActivityAsync is as per your code But getting error -- System.Net.Http.HttpRequestException: 'The server returned the non-success status code 400 (Bad Request). More error details: {"inputFile":["Required parameter 'inputFile' has no matching argument. (Parameter 'inputFile')"]} – prasanta mohanty Jun 26 '20 at 06:06
  • @prasantamohanty - I have created full sample for you, play around. https://github.com/MadhukarMoogala/acadio-snippets/blob/v3/Convert%20DWG%20to%20DXF.md https://github.com/MadhukarMoogala/acadio-snippets/tree/v3/NETCore/ClientV3 >The server returned the non-success status code 400 (Bad Request) This because you arguments are mismatching between activity spec and workitem spec. – Madhukar Moogala Jun 26 '20 at 06:55