13 Dec 2017

Error "The parameter is incorrect" when using large Embedded resource

One easy way to pass information to your AutoCAD add-in is to take advantage of embedded resources (ResourceKind.Embedded) for your InputArguments
This is what the design.automation-.net-custom.activity.sample is doing too:

wi.Arguments.InputArguments.Add(new Argument()
{
  Name = "Params",//Must match the input parameter in activity
  ResourceKind = ResourceKind.Embedded, //Use data URL to send json 
  // parameters without having to upload them to storage
  Resource = @"data:application/json, " + JsonConvert.SerializeObject(
    new CrxApp.Parameters { ExtractBlockNames = true, ExtractLayerNames = true }
  ),
  StorageProvider = StorageProvider.Generic //Generic HTTP download (as opposed to A360)
});

This way you do not have to upload your json data to some server, pre-sign it in order to make it available for Design Automation and then provide the URL to the resource in the InputArgument.

However, if your json data is bigger than about 200KB then on the "container.SaveChanges();" line of your code you would get a "The parameter is incorrect" error - see above image.

This size limit is not something caused by the Design Automation API, but by the underlying technology. 

The way around it is to provide your json file the "usual" way: upload the file to some storage and make it available for the Design Automation service. The above code snippet would need to be modified like this in order to achieve that:

wi.Arguments.InputArguments.Add(new Argument()
{
  Name = "Params",//Must match the input parameter in activity
  Resource = "https://raw.githubusercontent.com/adamenagy/Container/master/myparams_400K.json",
  StorageProvider = StorageProvider.Generic //Generic HTTP download (as opposed to A360)
});

 

Related Article

Posted By

Adam Nagy

Follow @AdamTheNagy Adam Nagy joined Autodesk back in 2005 and has been providing programming support, consulting, training and evangelism to external developers. He started his career in Budapest, then worked in Prague for 3 years and now lives in South England, UK. At the moment focusing on Inventor and Fusion 360, plus cloud and mobile related technologies. Adam has a degree in Software Engineering and has...