Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic code help with lookup tables

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
1503 Views, 4 Replies

ilogic code help with lookup tables

Picture two coins, one flat on the table and the other standing on the other like an inverted "T".

 

I have two equations, one gives me a minimum radius (standing up coin) and the other gives me a maximum diameter (lying down coin).

 

My standard parts are = Penny, Nickel, Dime and Quarter.

 

How can I write an Ilogic code that will take the minimum radius and maximum diameter equation answers and compare them to the standard parts to return the correct assembly (Penny flat and quarter standing or Nickel flat and Dime standing, etc...)?

 

Using Excel I use Index and Match for the radius equation and Vlookup for the diameter equation, both with an array.

 

Can anyone help with this?

4 REPLIES 4
Message 2 of 5
MjDeck
in reply to: Anonymous

If you place the parts in an iAssembly, then you can use the iAssembly.FindRow function.  The iAssembly table would have a column named MinimumRadius and another one named MaximumDiameter.

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 5
Anonymous
in reply to: Anonymous

Mike,

 

My explanation above is exactly what I need. If I could make Iparts and Iassemblies out of this, I would.

 

I have a skeletal assembly that also has sub-assemblies.

 

All of the parameters of the individual parts are being controlled by equations, through Ilogic.

 

I have a part in the assembly that has a cylindrical base (Reference to the bottom coin and diameter) and a spherical top on it (Reference to the coin standing on the other and the radius), This is one solid part with two features.

 

I have two calculation outputs, one might be 5.84 Min radius. The other might be 2.821 Max diameter.

 

Right now I use;

 

=INDEX(Sheet2!J2:J10,MATCH(J16,Sheet2!J2:J10,1)+1)

 

in Excel to choose the closest "standard" radii in the table J2 to J10.

 

J2=3

J3=4

J4=4.5

J5=6

J6=8

J7=8

J8=10

J9=10

J10=12

 

This formula would return J5 (6). Remember, it's a MIN radius so I would need it to take the next HIGHEST radius.

 

The other half of this formula is to find the diameter.

 

I used =VLOOKUP(Q6,Sheet2!F2:F10,Sheet2!F2:F10)

 

in Excel to choose the closest "standard" diameter in the table F2 to F9.

 

F2=.625          J2=3

F3=.875          J3=4

F4=1               J4=4.5

F5=1.125        J5=6

F6=1.5            J6=8

F7=1.5            J7=8

F8=1.875        J8=10

F9=2.5            J9=10

F10=3             J10=12

 

This formula would return F9 (2.5). Remember, it's a MAX diameter so I would need it to take the next LOWEST diameter.

 

So 2.821 becomes 2.5.

 

I need both of these formulas to find the right part. The 2.5 diameter is a match because its radius is 10, which is greater than the MIN 5.84.

 

So, I need to find all of the radii that are greater than the MIN value, then out of those choices find the largest diameter without going over the MAX value.

 

'"Whew!'"

Message 4 of 5
swordmaster
in reply to: Anonymous

Hi Len,

I would like to help with this, however i am finding it rather difficult to follow what you are trying to achieve!........i am sure it makes perfect sense to you.

Ok here goes, lets take the laying down coin, you have calculated the maximum diameter and now need to select the appropriate part..............is that correct?

Do you plan to use ilogic to do a component replace on the coin?

Are the coin diameters fixed or will you be adding other diameters?

 

Bruce

 

Inventor 2010 Certified Professional
Message 5 of 5
MjDeck
in reply to: Anonymous

Here's some code to do it.  I also started to put together some functions to emulate the Excel functions INDEX, MATCH and VLOOKUP in iLogic.  But what you posted using those functions doesn't look like a complete solution.  So please try this code.  It will work as long as the table is arranged in order of increasing diameter.

In this sample,  MinRadius, MaxDiameter, radius and dia  are Inventor parameters that are used in the rule.

The line  Imports System.Collections.Generic is not required in Inventor 2011.

 

Imports System.Collections.Generic

Sub Main()
Dim table As New List(Of DiaAndRadius)
table.Add(New DiaAndRadius(.625, 3))
table.Add(New DiaAndRadius(.875, 4))
table.Add(New DiaAndRadius(1, 4.5))
table.Add(New DiaAndRadius(1.125, 6))
table.Add(New DiaAndRadius(1.5, 8))
table.Add(New DiaAndRadius(1.5, 8))
table.Add(New DiaAndRadius(1.875, 10))
table.Add(New DiaAndRadius(2.5, 10))
table.Add(New DiaAndRadius(3, 12))

Dim drFound As DiaAndRadius = Nothing
For Each dr As DiaAndRadius in table
  If (dr.Radius >= MinRadius AndAlso dr.Diameter <= MaxDiameter) Then
    drFound = dr
  End If
Next

If (drFound Is Nothing) Then
  MessageBox.Show(String.Format("No diameter and radius was found for MinRadius = {0} and MaxDiameter = {1}", MinRadius, MaxDiameter), "iLogic")
  Return
End If

radius = drFound.Radius
dia = drFound.Diameter

End Sub

Class DiaAndRadius
  Public Diameter As Double
  Public Radius As Double
  Public Sub New(diaA as Double, radA as Double)
    Me.Diameter = diaA
    Me.Radius = radA
  End Sub
End Class

 


Mike Deck
Software Developer
Autodesk, Inc.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report