iLogic creating a table WITHOUT Excel

iLogic creating a table WITHOUT Excel

Kay_Rethmeier
Advocate Advocate
3,604 Views
8 Replies
Message 1 of 9

iLogic creating a table WITHOUT Excel

Kay_Rethmeier
Advocate
Advocate

Good morning!

 

I'm looking for a possibility to create a "table" inside an iLogic rule.

Reason for my question: Doing it with excel and all the iLogic statements is wonderful, but will take 50 times longer instead of having it directly inside a rule. (My colleague told me this.) 

 

So my question is: is there an easy way to use the fx-parameters to lookup an array/table/matrix inside a rule an get back a couple of return values?

So maybe the "table" needs to look like this or similar. I don't know.

 

And: I'm not a programmer. I can' develop silly strange code on my own, maybe read it and hopefully understand it. I'm master in iLogic with it's predefined snippets.

 

SyntaxEditor Code Snippet

{100, 95, 0},
{100, 90, 0},
{100, 85, 0},
{100, 80, 0},
{100, 75, 0},
{100, 70, 0},
{100, 65, 0},
{100, 60, 0},
{100, 55, 0},
{100, 50, 0},
{100, 45, 0},
{100, 40, 0},

Thanks in advance!

Kay

Cheers
Kay (Principal CAD-Consultant)
0 Likes
Accepted solutions (2)
3,605 Views
8 Replies
Replies (8)
Message 2 of 9

mcgyvr
Consultant
Consultant

Maybe "multi-value list" is what you are looking for..

https://knowledge.autodesk.com/support/inventor-products/learn-explore/caas/CloudHelp/cloudhelp/2015...

 

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 3 of 9

MechMachineMan
Advisor
Advisor

Something along these lines could probably get you started.

 

MSDN and google are your friends.

 

Sub Main()

    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisDoc.Document
    
    Dim oSheet As Sheet
    oSheet = oDrawDoc.ActiveSheet
    
    Dim oTitles() As String
    oTitles = {"Title1", "Title2", "Title3"}
' Set the contents of the custom table (contents are set row-wise)
' These contents are also only in a 1-D array that the AddTables function WRAPS to the next line.
' This is not very intuitive and would make more sense if this were a 2-D Array
Dim oContents() As String oContents = {"#4", "-", "-", _ "#6", "-", "-", _ "#8", "-", "-", _ "#10", "-", "-" _ 'No comma on last entry } Dim oCustomTable As CustomTable oCustomTable = oSheet.CustomTables.Add("Sample Table", ThisApplication.TransientGeometry.CreatePoint2d(15, 15), 3, 4, oTitles, oContents) End Sub

Sub TwoDeeArray()
Dim oContents(,) As String oContents = {_
{"#4", "-", "-"}, _ {"#6", "-", "-"}, _ {"#8", "-", "-"}, _ {"#10", "-", "-"} _ 'No comma on last entry }
For i = LBOUND(oContents,1) to UBOUND(oContents,1)
For j = LBOUND(oContents,2) to UBOUND(oContents,2)
oStr = oStr & oContents(i,j) & ", "
Next
oStr = oStr & vblf
Next

MsgBox(oStr)
End Sub

 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 4 of 9

Curtis_Waguespack
Consultant
Consultant

Hi Kay.Rethmeier,

 

I knew MechMachineMan was going to beat me to this reply Smiley Happy, but here's another example anyway.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

This example expects a multivalue parameter named PlateSize, see attached Inventor 2017 file.

 

'build table data as an arraylist 
'using vertical bar char as seperator
Dim oPlateList As New ArrayList
               '(description | Part #   | Stock #)
oPlateList.add("Plate 10 mm | PL-10-123 | 56-123")
oPlateList.add("Plate 12 mm | PL-12-785 | 56-785")
oPlateList.add("Plate 14 mm | PL-14-210 | 56-210")
oPlateList.add("Plate 16 mm | PL-16-147 | 56-147")
oPlateList.add("Plate ??? | ??? | ???")

'note the first "row" in array list is 0 rather than 1
'if parameter matches then split the arraylist item 
'using the vertical bar char as the seperator

'result is an array called oSplit that holds 3 values
'example:
	'oSplit(0) = Plate 10 mm
	'oSplit(1) = PL-10-123
	'oSplit(2) = 56-123
If PlateSize = 10 Then
	oSplit = Split(oPlateList(0),"|") 
ElseIf PlateSize = 12 Then
	oSplit = Split(oPlateList(1),"|") 
ElseIf PlateSize = 14 Then
	oSplit = Split(oPlateList(2),"|") 
ElseIf PlateSize = 16 Then
	oSplit = Split(oPlateList(3),"|") 
Else
	oSplit = Split(oPlateList(4),"|") 	
End If

'use Trim to remove extra spaces
iProperties.Value("Project", "Description") = Trim(oSplit(0))
iProperties.Value("Project", "Part Number") = Trim(oSplit(1))
iProperties.Value("Project", "Stock Number") = Trim(oSplit(2))

MessageBox.Show(iProperties.Value("Project", "Description") &vbLf & _
iProperties.Value("Project", "Part Number") &vbLf & _
iProperties.Value("Project", "Stock Number"), "iLogic")

 

EESignature

Message 5 of 9

Kay_Rethmeier
Advocate
Advocate
Accepted solution

Hi Curtis,

 

thanks for your answer. But doing a selection via if then else will be horrible and in fact of longer tables a - more or less - never ending story.

But: I found a rule developed by Dieter Meuthen (our Great Grand Master of ETO). Is there a next better/shorter idea to do this?

Problem: With this I can only select through one value. By iLogic / Excel more queries are possible  😐 .

 

Here is a simplified code:

Sub Main 
'                                Length    Witdh    Height
    myTable("A1") = New TabRow(     1.0,     2.0,     3.0)
    myTable("B2") = New TabRow(     1.0,     2.0,     1.0)
    myTable("C3") = New TabRow(     1.0,     1.0,     1.0)
    
    Dim Row As TabRow 
    Dim found As Boolean = myTable.TryGetValue(Choice, Row) 
    If (found) Then
        Length    = Row.Laenge_T
        Width     = Row.Breite_T
        Height     = Row.Hoehe_T
    Else 
        MsgBox("Achtung")
    End If 
End Sub

Public myTable As New Dictionary(Of String, TabRow) 
Class TabRow 
    Public Laenge_T As Double
    Public Breite_T As Double
    Public Hoehe_T As Double
    Public Sub New( Laenge_T As Double, Breite_T As Double, Hoehe_T As Double)
        Me.Laenge_T = Laenge_T
        Me.Breite_T = Breite_T
        Me.Hoehe_T = Hoehe_T
    End Sub
End Class 

 

I added my testpart.

 

Thanks in advance!

Kay

Cheers
Kay (Principal CAD-Consultant)
0 Likes
Message 6 of 9

Kay_Rethmeier
Advocate
Advocate
Accepted solution

Hi,

 

OK, solution for more criterias is developed. Inside excel (I will create excel for a first preparation and copy this into the rule) I need to concatenate my criterias into one field. This field can be use as search field within the phrase, e.g.:

 

myTable("ohne|10")     = New TabRow(    ohne,    10,    40,    0.5)

 With a next rule and different values I can do the same inside Inventor / iLogic.

Choice = Type & "|" & CStr(Dia)

 2017-07-27 22_52_33.png

 

The xls is embedded in the IPT. 

 

Hmm....

Better, faster and more handy ideas?

Kay

 

Cheers
Kay (Principal CAD-Consultant)
0 Likes
Message 7 of 9

Anonymous
Not applicable

This is great as I needed two criteria for my table but is there any way to do this without using multivalues? Reason being while lets say I can use size 10, 12 and 14 like in your example the three types ohne, HE and HB are not available in the all sizes. 10 may only be available in HE and HB types for example.

 

Thank you.

0 Likes
Message 8 of 9

sdlF9MME
Participant
Participant

Any reason why there is an embeded spreadsheet in the part file?

0 Likes
Message 9 of 9

Kay_Rethmeier
Advocate
Advocate

Hi,


just as a small database. Sometimes customers have hugh existing lists you don't like to take over as VB-program. This might be horrible!


Bye

Kay

Cheers
Kay (Principal CAD-Consultant)
0 Likes