Limitations of MeasureTools.GetMinimumDistance

Limitations of MeasureTools.GetMinimumDistance

AlexFielder
Advisor Advisor
692 Views
5 Replies
Message 1 of 6

Limitations of MeasureTools.GetMinimumDistance

AlexFielder
Advisor
Advisor

Hi All,

 

I am working on a problem with some otherwise fully functioning code of mine.

 

I have an iLogic rule that places a series of sub-assemblies in an assembly file. This works fine.

 

The same rule allows you to select a sub-assembly and an adjacent sub-assembly and place a series of sub-assemblies between them. This also works fine.

 

I have code that collects the relevant WorkPlaneProxy objects, and then use the following: 

 

dim distance as double = ThisApplication.MeasureTools.GetMinimumDistance(RunOfSystemsRunDetails.RightDatumWPProxy, RunOfSystemsRunDetails.LeftDatumWPProxy) * 10

This code runs just fine if the measurement is between sub-assembly > sub-assembly, but fails with "the parameter is incorrect" if it runs demoted-sub-assembly > sub-assembly.

 

I can carry out this measurement using Inventor's measure tool manually, yet I cannot do so using iLogic.

 

Am I missing something obvious with the API?

 

Thanks,

 

Alex.

0 Likes
Accepted solutions (2)
693 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor
Accepted solution

Hi @AlexFielder.  It sounds to me like you would just have to dig one extra layer deeper to get the WorkPlaneProxy of the WorkPlaneProxy so that you are measuring within the context of the main assembly's model space.  I don't use 'demote'/'promote' much, but I know that when you demote a sub assembly, it creates a new top level component to replace the sub assembly, and creates a new assembly file to save that component to disk, then the result is that your original sub-assembly is now one level deeper within the main assembly than it was before.  So it seems logical to me that you would then have to dig down to that original assembly's level to get a WorkPlaneProxy from it to the new component's level, then create a WorkPlaneProxy of that within the main assembly for the new component that represents it at the top level, so you can measure using that top level WorkPlaneProxy .  Does that make sense to you too?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

SevInventor
Advocate
Advocate

maybe the workplanes are not parallel?

it could be checked with something like this

Dim oParallel As Boolean = RunOfSystemsRunDetails.RightDatumWPProxy.Plane.IsParallelTo(RunOfSystemsRunDetails.LeftDatumWPProxy.Plane, 0.01)

 

0 Likes
Message 4 of 6

AlexFielder
Advisor
Advisor
I was considering that too, but the "placed assemblies" are positioned parallel to the same AutoCAD geometry.

Thank you for the input/sample 🙂
0 Likes
Message 5 of 6

AlexFielder
Advisor
Advisor
As usual, no sooner had I posted the OP than I realised the same mis-step in my approach thus-far. I am currently looking at creating a WorkPlaneProxy for the WorkplaneProxy as you suggested.

Thanks,

Alex.
0 Likes
Message 6 of 6

AlexFielder
Advisor
Advisor
Accepted solution

So, the tricky part was remembering to get the sub-sub-assembly (which would otherwise be a sub-assembly were it not demoted) as a ComponentOccurrenceProxy object like so:

 

Dim WeldedCornerFirstOcc As ComponentOccurrenceProxy = (From occ As ComponentOccurrenceProxy In OppositeCornerSystem.SubOccurrences
Let occname As String = occ.Name
Where occname = OppositeCornerSystem.Name.Replace(":1",":2")
Select occ).FirstOrDefault()

I then pass that object to the following command:

GetPlacementWorkGeometryFromSelectedSystem(WeldedCornerFirstOcc, Nothing, Nothing, Nothing, LeftDatumWPProxy:=LeftDatumWPProxyProxy, LeftDatumPlaneName :="AngleLeftDatumWP")

and after null checking the LeftDatumWPProxyProxy object, do this:

WeldedCornerFirstOcc.CreateGeometryProxy(LeftDatumWPProxyProxy, LeftDatumWPProxy)

After another null check, this then works as normal:

ThisApplication.MeasureTools.GetMinimumDistance(RunOfSystemsRunDetails.RightDatumWPProxy, RunOfSystemsRunDetails.LeftDatumWPProxy, Nothing, Nothing, Nothing) * 10

 

Thanks,

 

Alex.