Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Issue with measure tool

Anonymous

Issue with measure tool

Anonymous
Not applicable

I am trying to create a bit of code in visual studio (VB.Net) that will allow me to select 2 or more parts in an assembly (1 primary and x number of secondary items).

 

My model tree is:

- Top level assembly

      - PCB Assembly

            - PCB

            - Components

      - PCB Screen 1

      - PCB Screen 2

 

I am trying to measure the distance between occurrence of the PCB assembly, with each occurrence of the top level assembly

 

My code is below and errors on the measure line if the first "for... each" loop in included. (e.g. If I pick a PCB (primary) and a screen (secondary) as I assume it's not reading the occurrence correctly.

 

If I pass the PCB assembly (comp_occ1) to the measure function it works (but just for the PCB occurrence).

 

Can anyone shed some light on what I'm missing?

 

 

Dim asmDoc As Inventor.AssemblyDocument = inventorApp.ActiveDocument ' Active Assembly

Dim oOccs As Inventor.ComponentOccurrences = asmDoc.ComponentDefinition.Occurrences ' Occurrences in active assembly

Dim comp_occ1 As Inventor.ComponentOccurrence ' Primary Occurrence

Dim comp_occ2 As Inventor.ComponentOccurrence 'Second Occurrence

Dim seccomparray As New ArrayList ' Array of all secondary components

Dim cont2 As Inventor.NameValueMap = inventorApp.TransientObjects.CreateNameValueMap ' Used for measure command

Dim distance2 As Double

Dim SubAsmdoc As Inventor.AssemblyDocument

Dim compdef As Inventor.AssemblyComponentDefinition

 

 

comp_occ1 = inventorApp.CommandManager.Pick(Inventor.SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Prmimary Item (E.g. PCB Assy)")

 

 

SubAsmdoc = inventorApp.Documents.ItemByName(comp_occ1.ReferencedFileDescriptor.FullFileName)

compdef = SubAsmdoc.ComponentDefinition

While True

comp_occ2 = inventorApp.CommandManager.Pick(Inventor.SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Secondary Item(s) (E.g. Screen)")

If IsNothing(comp_occ2) Then Exit While

seccomparray.Add(comp_occ2)

End While

 

For Each occ As Inventor.ComponentOccurrence In SubAsmdoc.ComponentDefinition.Occurrences

 

 

For Each seccomp In seccomparray

 

Try

 

distance2 = inventorApp.MeasureTools.GetMinimumDistance( _

occ.Name, seccomp, _

Inventor.InferredTypeEnum.kNoInference, _

Inventor.InferredTypeEnum.kNoInference, _

cont2)

Catch

Gap = "Measure Failed"

End Try

 

 

0 Likes
Reply
235 Views
0 Replies
Replies (0)