- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
ThisServer.MeasureTools.GetMinimumDistance(...) is not working with Design Automation for Inventor
Hello all,
I have been working with Inventor server application (Forge) for a while now and have been able to get most of my automation running from the server.
I am trying to find the minimum distance between two planes in different subassemblies and then using that distance to calculate another parameter.
However, when running the following code, an error is returned.
Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oDocDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oMT As MeasureTools = ThisServer.MeasureTools
Dim oPart1 As ComponentOccurrence = oDocDef.Occurrences.ItemByName("SUB_ASSY_1") 'Instance 1 name here
Dim oPart1Def = oPart1.Definition
Dim oPart2 As ComponentOccurrence = oDocDef.Occurrences.ItemByName("SUB_ASSY_2") 'Instance 2 name here
Dim oPart2Def = oPart2.Definition
wp1 = oPart1Def.WorkPlanes.Item("WorkPlane1") 'Plane name in instance 1
wp2 = oPart2Def.workpoints.item("WorkPoint1")
Dim wp1Proxy As WorkPlaneProxy = Nothing
oPart1.CreateGeometryProxy(wp1, wp1Proxy)
Dim wp2Proxy As WorkPointProxy = Nothing
oPart2.CreateGeometryProxy(wp2, wp2Proxy)
'distance = ThisServer.MeasureTools.GetMinimumDistance(wp2Proxy, wp1Proxy)
'Logger.Error("Method 2: " & distance & " cm (database units)")
distance_2 = wp1Proxy.Plane.DistanceTo(wp2Proxy.Point)
Logger.Error("Method 3: " & distance_2 & " cm (database units)")
ThisServer.MeasureTools.GetMinimumDistance(...)
[11/16/2023 07:01:44] Details: System.NotImplementedException: Not implemented (Exception from HRESULT: 0x80004001 (E_NOTIMPL))
[11/16/2023 07:01:44] at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
[11/16/2023 07:01:44] at Inventor.InventorServerObject.get_MeasureTools()
[11/16/2023 07:01:44] at ThisRule.Main()
[11/16/2023 07:01:44] at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
[11/16/2023 07:01:44] at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Unfortunately, this also doesn't work and returns the following error.
Measure.MinimumDistance(...)
[11/16/2023 05:44:43] Details: System.ArgumentException: Measure.MinimumDistance: This function is not available in Inventor Server.
[11/16/2023 05:44:43] at iLogic.CadMeasure.ApplicationIsRequired(String callerName)
[11/16/2023 05:44:43] at iLogic.CadMeasure.MinimumDistance(Object componentName1, Object entityName1, Object componentName2, Object entityName2)
[11/16/2023 05:44:43] at ThisRule.Main()
[11/16/2023 05:44:43] at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
[11/16/2023 05:44:43] at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)
Both are working fine on my local machine. If an inbuilt function does not work, I'll probably have to find a workaround that does not break when the model changes. The model I'm working with has many possible parameter and part combinations and unfortunately, sketches and driven dimension parameters may become orphan when the model changes.
Unfortunately, my model is too large and confidential to share but I will be happy to share other code snippets or less confidential files.
Thanks!
-Hamza