Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding rows to a table in 2D

6 REPLIES 6
Reply
Message 1 of 7
rikard.nilsson4SLAL
148 Views, 6 Replies

Adding rows to a table in 2D

Hi,

 

I have a Table placed in the drawing and it's placed as a model state table.

I'm rying to add rows to that table.

 The code I use is just CustomTables.Rows.Add.

 

The row will be added but the cells will remain emtpy..

I don't want to add any model states just rows in the 2D.

 

Do anybody have any idea?

Or is that not possible?

 

Regards

Rikard

6 REPLIES 6
Message 2 of 7

Hi @rikard.nilsson4SLAL.  The online help page for that Rows.Add method says that all of the possible input data for that method are optional, so you do not have to supply any data to fill that row if you do not want to.  But if you did want to supply some values, the first optional one just wants an Integer to specify where to put the new row.  If you do not specify a value, it uses the value zero, which puts the new row at the end.  The second optional input is a Boolean (True/False) to indicate Before or After the first specified row index.  The third optional input would be an Array of String, with the same number of elements as there are cells in that row, to fill in their contents.  And the last optional input is simply a Double, indicating the row height.

Edit:  Below is a very simple example:

oDDoc = ThisDrawing.Document
oSheet = oDDoc.ActiveSheet
oTable = oSheet.CustomTables.Item(1)
oTable.Rows.Add()

 

Wesley Crihfield

EESignature

Message 3 of 7
rikard.nilsson
in reply to: WCrihfield

Hi!

 

Sorry. Maybe I should have written that my code works if I add the row to a Custom table that I created myself. 
The problem I have is that I want to add rows to a table that is created from Model States. 

/Rikard

Message 4 of 7
WCrihfield
in reply to: rikard.nilsson

So...to create that table, you started from the model document, edited the ModelStates table via Spreadsheet, then saved that spreadsheet out as an Excel file, then used that Excel file as the basis for creating the CustomTable in the drawing...does that sound about right?  Just trying to figure out very specifically what we are talking about here.  If so, I just duplicated that process in a drawing of a part that has 2 custom model states, creating the new table from the excel file, then modified that simple code to get CustomTables.Item(2), and it still added another empty row to the table just fine.

Wesley Crihfield

EESignature

Message 5 of 7
rikard.nilsson
in reply to: WCrihfield

Thanks for trying to help. 

here is the order. 
1 Create a part with model states. 
2 Start drawing and place a view of the part. 
3 Start General Table and pick the view. 
4 Add some commons from MS columns

5 Place table. 
6 trying to add row to table by using API. 

/Rikard

Message 6 of 7
WCrihfield
in reply to: rikard.nilsson

I am sorry to hear that it is not working for you.  There must be something else going on that is preventing it from working on your end.  I tried it several ways, and never got it to fail in my tests.  I just recorded a quick screen captured video in which I am following those steps, and showing it working OK for me.  I am using Inventor Pro 2022.3.2, if that makes any difference.

  1. Starting from a part that has a couple custom model states, I create a new drawing, and place a view of that part in it.
  2. I then click to create a new table for the drawing, and select that view as its basis.
  3. I select a few more columns to show in the table.
  4. Then I place the table in the drawing.
  5. Then I make a new iLogic rule in that drawing with the simple code from above.
  6. Then I run that rule, while the rule editor is closed, so you can watch it add the row to the table.
  7. I then edit the rule to make it put another empty row in another location, in the middle of the existing rows of data.

The mp4 video is attached.

Wesley Crihfield

EESignature

Message 7 of 7
rikard.nilsson
in reply to: WCrihfield

Hi!

 

Sorry again. English is not my first language so maybe I’m not writing in the right way. 

As I wrote in my first post. “The row will be added but the cells will remain emtpy..”

By that I mean that I can ONLY add empty rows. 
it’s row with content that is my problem. 

/Rikard

 

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

Post to forums  

Autodesk Design & Make Report