Search code examples
c#autodesk-forgeautodesk-designautomationautodesk-inventor

Using InventorServer.MeasureTools in an AppBundle uploaded to Autodesk Platform Services


I have an Inventor plugin written in C#. One of the lines is MeasureTools MT = App.MeasureTools;, where App is an InventorServer object. However, when I upload it as an AppBundle to APS, I get the following error when trying to run a WorkItem:

[10/02/2023 15:04:34]     InventorCoreConsole.exe Error: 0 : SamplePlugin .dll : Processing failed. System.NotImplementedException: Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL))
[10/02/2023 15:04:34]    at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
[10/02/2023 15:04:34]    at Inventor.InventorServerObject.get_MeasureTools()
[10/02/2023 15:04:34]    at SamplePlugin.SampleAutomation..ctor(PartDocument partDoc) in Path/To/Plugin/SampleAutomation.cs:line 112
[10/02/2023 15:04:34]    at ClassifyExtrusionFeaturesPlugin.PluginEntryPoint.RunWithArguments(Document doc, NameValueMap map) in Path/To/Plugin/PluginEntryPoint.cs:line 81

Is MeasureTools not supported in APS?

I have tried to run the plugin locally as an addin in my local Inventor app. I use the exact same code, including InventorServer objects instead of Application objects, etc. It works fine locally.


Solution

  • That object has dependency on UI libraries that are not available in Inventor Server - this is not Design Automation, but Inventor Server specific, i.e. would be the same if you tried to use it from a Vault Job Processor that uses Inventor Server
    (Configurator 360 had similar limitations: "iLogic Measure functions are not available." - https://help.autodesk.com/view/CFG360/ENU/?guid=GUID-96EA0CAA-73BB-42C2-94D8-73CC76791DC7)

    What you could do is use the underlying functions instead:

    instead of ...
      ThisServer.MeasureTools.GetMinimumDistance(workPoint1, workPoint2)
    ... you could do
      workPoint1.Point.DistanceTo(workPoint2.Point)
    
    instead of ...  
      ThisServer.MeasureTools.GetMinimumDistance(workAxis1, workPoint1)
    ... you could do
      workAxis1.Line.DistanceTo(workPoint1.Point)
    
    etc