Create custom table using user input

Create custom table using user input

Fazlur_Rahaman
Advocate Advocate
743 Views
9 Replies
Message 1 of 10

Create custom table using user input

Fazlur_Rahaman
Advocate
Advocate

Hi guys,

I am looking to see if there is a way to create/place custom table using Forms or iLogic or combination of both without creating or using user Parameters. Something like the picture below.

 

 

frahaman_1-1701641255561.png

 

0 Likes
744 Views
9 Replies
Replies (9)
Message 2 of 10

A.Acheson
Mentor
Mentor

Here is the vba API sample converted to ilogic below. As for the inputs you can use single input listboxes or if you have visual studio then create the winform there. Alternatively you can create a form directly in ilogic environment manually but it is a lot of work. 

' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
 oDrawDoc = ThisApplication.ActiveDocument

' Set a reference to the active sheet.
Dim oSheet As Sheet
 oSheet = oDrawDoc.ActiveSheet

' Set the column titles
Dim oTitles(2) As String
oTitles(0) = "Part Number"
oTitles(1) = "Quantity"
oTitles(2) = "Material"

' Set the contents of the custom table (contents are set row-wise)
Dim oContents(8) As String
oContents(0) = "1"
oContents(1) = "1"
oContents(2) = "Brass"
oContents(3) = "2"
oContents(4) = "2"
oContents(5) = "Aluminium"
oContents(6) = "3"
oContents(7) = "1"
oContents(8) = "Steel"

' Set the column widths (defaults to the column title width if not specified)
Dim oColumnWidths(2) As Double
oColumnWidths(0) = 2.5
oColumnWidths(1) = 2.5
oColumnWidths(2) = 4

' Create the custom table
Dim oCustomTable As CustomTable
 oCustomTable = oSheet.CustomTables.Add("My Table", ThisApplication.TransientGeometry.CreatePoint2d(15, 15), _
3, 3, oTitles, oContents, oColumnWidths)

' Change the 3rd column to be left justified.
oCustomTable.Columns.Item(3).ValueHorizontalJustification = kAlignTextLeft

' Create a table format object
Dim oFormat As TableFormat
oFormat = oSheet.CustomTables.CreateTableFormat

' Set inside line color to red.
oFormat.InsideLineColor = ThisApplication.TransientObjects.CreateColor(255, 0, 0)

' Set outside line weight.
oFormat.OutsideLineWeight = 0.1

' Modify the table formats
oCustomTable.OverrideFormat = oFormat

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 10

Fazlur_Rahaman
Advocate
Advocate

Hi @A.Acheson ,

Thank you for the suggestion. I am not a programmer and basic iLogic is the extend of my coding skills. But I can definitely give a try and it does look like there are lots of tutorial online that i can follow on how to create Winform in Visual Basic.

 

Before I start that journey, does it have the ability to share the form with organization and control future updates via Vault?

 

Or do you think it might be better to stick with iLogic given that in both cases I have lot of learning to do?

 

Thanks in advance.

0 Likes
Message 4 of 10

A.Acheson
Mentor
Mentor

Tbh I haven't done much in the way of using visual studio other than to create a more complicated form and then use the code created so that everything can be self contained in one ilogic rule. I wouldn't think there would be a need to put any of the form and ilogic rules into vault but maybe other users can point out methods for this. 

 

Tbh ilogic has its limits when it comes to forms there interactions and where the data is held. They involve alot of parameter creations and certainly don't have the custom ability that windows forms have so the sooner you learn that aspect the better. Your forms will be more efficient and professional looking. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 5 of 10

WCrihfield
Mentor
Mentor

Hi @Fazlur_Rahaman.  I pretty much agree.  The iLogic forms are the quickest and simplest to create, and they also work fluently with Inventor, because they are part of the iLogic add-in within Inventor.  However, they also have the least options and functionality possibilities of all similar choices.  The next step is probably the VBA Userform, but since VBA for Inventor is on its way out, and no longer being maintained, I no longer use it for much anymore.  They did allow us more design flexibility, and when using those, the list source data could be internal, instead of needing to have a multi-value parameter in the document.  However, they were also more complex to design, and required more advanced coding abilities to write the code needed behind every element you put into them to enable and support their functionality.  The option with the most dynamic options and functionality, but probably also the most complicated to create if you are not a professional software designer, is to design your form with something like Visual Studio, then create something like a DLL file that you can reference from an iLogic rule.  I also do not have much experience with Visual Studio yet though.  I did create a few fairly basic (relative term I know) Windows Forms completely from scratch by just typing in all the vb.net code for them into an iLogic rule, then tons of trial & error testing along the way, to get it looking and functioning as I wanted.  But that is honestly really complicated to do if you are not really familiar with all that stuff.

 

On a lighter note, what about just using Excel?  You can add drop-down lists to cells in Excel fairly easily, and Inventor works with Excel quite a bit.  We also have a special set of basic iLogic tools just for interacting with Excel.  Once the Excel file is shown, filled in, and ready, you can create and run an iLogic rule that could (in theory) access that Excel file, get the needed data from it, and create the table in your drawing based on that data.  That idea would also take a pretty good amount of time to implement, and get working just right, but is probably a lot simpler than some of the alternatives to iLogic forms.  Just another thought.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 10

Fazlur_Rahaman
Advocate
Advocate

I never thought of using Excel, that is great idea. I will play around it to see how it might work.

 

Btw, i saw this thread:https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-gui-or-form-for-user-input/td-p/98...

 

Is there a way to modify it to work for case?

0 Likes
Message 7 of 10

A.Acheson
Mentor
Mentor

You just need a pot of coffee/tea and lots of time, run the solution check what works. You can search stackoverflow and Microsoft help files for methods you need, combo boxes, labels etc. Obviously if your using visual studio then that would help building the form. But otherwise it is a little trial and error and just starting building out the code using that sample as a starting point. 

Here is a sample form built in the same way as your link entirely by code. If you get stuck anywhere with your implementation then post the code here for some help. 

AAcheson_0-1701821347198.png

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 8 of 10

Fazlur_Rahaman
Advocate
Advocate

Hi @A.Acheson ,

I have bitten the bullet and decided to go down the winform route. After doing more research, i figure the things I will learn from the exercise will help me in the future for more complex automation i want to do.

 

I am starting small and trying to build up on it. I started with single user input and trying to load up in Inventor. I got the code on the winform to work, but i can't seem to load the form in Inventor using iLogic. I suspect I am not using the  'ShowDialog' accurately. Would you be able to look at my code below and tell me what im doing wrong?

 

AddReference "C:\Users\fazlur.rahaman\Documents\Inventor Training\FirstForm\FirstForm\FirstForm\bin\Debug\net6.0-windows\FirstForm.dll"
Using inputForm As New FirstForm.Form1


Dim FormResult As System.Windows.Forms.DialogResult = inputForm.ShowDialog()

If FormResult = vbOK Then
	DialogResultOK = True
End If

End Using

 

 

This is the error i get: 

frahaman_0-1702252735797.png

 

It says error on line 14, i don't have line 14 in my code 😐

 

0 Likes
Message 9 of 10

A.Acheson
Mentor
Mentor

I would suggest to follow rhe full sample listed above. Delete functions not needed as you go but make sure to keep the class and show dialog subs intact. The code you posted looks like it is partially complete so please post the full code where possible. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 10 of 10

punam_bansode
Contributor
Contributor


The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) Iam getting this error at CustomTable .add line. everything is same copy and paste even not working?

0 Likes