[iLogic] Deleting Custom Table & Entering Values

[iLogic] Deleting Custom Table & Entering Values

Anonymous
Not applicable
4,073 Views
6 Replies
Message 1 of 7

[iLogic] Deleting Custom Table & Entering Values

Anonymous
Not applicable

Hello all,

 

I need to insert a table on one of my Inventor drawings, however, it will vary in size (Fixed colums, variable number of rows). I have searched the forum and found this snippet of code to add a 2x20 table.

 

Sub Main()
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

' Set the column titles
Dim oTitles() As String = {"Member","Pos. From Datum A"}

Dim oPoint As Point2d
oPoint = ThisApplication.TransientGeometry.CreatePoint2d(1, 28.7)

' Create the custom table
Dim oCustomTable As CustomTable

oCustomTable = oSheet.CustomTables.Add("Infill Spacing", oPoint, 2, 20, oTitles)
End Sub

 The Problem

 

I now need to be able to do two things:

1. Delete all custom tables that may be on the drawing ( I may have more than 1 custom table on the drawing)

2. Access the individual rows and colums in a specific table so I can write a variable into them.

 

I have searched high and low for the API commands, but cant seem to find them. As always, any help is appreciated.

 

Many Thanks

 

 

0 Likes
4,074 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

Hello,

 

After some extensive searching, I have found a bit of code hidden away in the help section of Inventor to create a custom table and then edit the values in the table. I had to modify it slightly to remove some error messages, I think it was written for an older version of VB.NET? (I have attached the code should it be of use to anyone)

 

However, the number of rows will change depending on the model (which i will edit the code to do). But I still need to be able to delete it, and re-run the code to add the new table.

 

Is there a command which will delete ALL custom tables on the sheet? (not the parts list). I am using Inventor 2012.

 

Many Thanks

0 Likes
Message 3 of 7

Anonymous
Not applicable

Hi,

Thanks for posting this code, i do not have a use for it at this moment in time, however it may be useful in the future.

I cut and pasted the code into a rule within a idw , ran the rule and nothing appeared to happen, is there a step i missed?

I am using Inventor/Ilogic 2009

 

thanks

Message 4 of 7

Anonymous
Not applicable

Forget my last post, it created the table, but off the "paper" i just didnt see it

0 Likes
Message 5 of 7

Anonymous
Not applicable

No Problem, this snippet of code may also be worth keeping in storage. It will delete a table from your drawing

 

' 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

If (oSheet.CustomTables.Count > 0) Then
  	oSheet.CustomTables.item(1).Delete
End If

 

However, if you have more than 1 table in the drawing, you will have to run the code twice! Im still trying to change the code so it will delete ALL tables in one instance. I'll let you know if i find a solution 😉

 

 

Message 6 of 7

Anonymous
Not applicable

Hi, thanks for the code!

I made a small adjustment to it to delete all tables on the drawing sheet

 

' 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

Dim

numtables As Integer

Dim

i As Integer

numtables

= oSheet.CustomTables.Count

For

i = 1 To numtables

oSheet.CustomTables.item

(1).Delete

next

0 Likes
Message 7 of 7

S7RM7RPR
Advocate
Advocate

I realize this is an old post and I'm rather new to programming but I hope someone can give me an answer.

 

Why not simplify the code to what I have below? It seems pointless to have to declare variables that don't need declaring... I'm guessing it's a difference between Inventor coding and straight up VB coding...

 

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet

'deletes any tables
For J = 1 To oSheet.CustomTables.Count
    oSheet.CustomTables.item(1).Delete
Next
0 Likes