Ilogic/VB excel

Ilogic/VB excel

Anonymous
Not applicable
972 Views
3 Replies
Message 1 of 4

Ilogic/VB excel

Anonymous
Not applicable

Greeting, I am having success with making Inventor do what I want up till this point.  I am successful at pulling in a Table from excel and putting it on a drawing (see following code).  

The problem is I am not sure how to search a column for a value(s), and then only have the row that contains said value(s) display in the table.

I can get the values from the source spreadsheet, but not sure how to make the cypher. 

The excel file is attached.

 

Any direction on what to try or code would be much appreciated.

 

 

SyntaxEditor Code Snippet

' Set a reference to the active drawing document
    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
    
    ' Set a reference to the active sheet
    Dim oActiveSheet As Sheet
    oActiveSheet = oDrawDoc.ActiveSheet
    
    ' Create the placement point for the table
    Dim oPoint As Point2d
    oPoint = ThisApplication.TransientGeometry.CreatePoint2d(25, 25)
    
    ' Create the table by specifying the source Excel file
    ' This assumes that the first row in the Excel sheet specifies the column headers
    ' You can specify a different row using the last argument of the AddExcelTable method
    Dim oExcelTable As CustomTable
    oExcelTable = oActiveSheet.CustomTables.AddExcelTable("K:\Inventor\ADTLETMODELDATA.xlsx", oPoint, "Evaporator Information")

 

0 Likes
Accepted solutions (1)
973 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Ok, so now i am working on a different approach.

Using ilogic and a case statement to build a table of information as user choose the information in a form.

 

However, when I do that, I only want one row to populate instead the table produces three rows, one title row that is empty,

one row full of data, and a third row that is empty.  Is there a way to hide the title row and the last row?  The code is as follows

 

I created a custom table, in the styles editor.  However, I am not sure how to reference the new table I created.  Is there another way to remove the 1st and third row.

SyntaxEditor Code Snippet

Select Case EvapModel
  Case "ADT-040"
    Dim oContents (0 To 11) As String
    oContents(0) = "ADT-040"
    oContents(1) = "29 1/2 in"
    oContents(2) = "17 1/4 in"
    oContents(3) = "-"
    oContents(4) = "-"
    oContents(5) = "1/2 in OD"
    oContents(6) = "7/8 in OD"
    oContents(7) = "3/4 in MPT"
    oContents(8) = "28"
    oContents(9) = "1"
    oContents(10) = "1.8"
    oContents(11) = "1"
    
    Dim oPoint As Point2d
    oPoint = ThisApplication.TransientGeometry.CreatePoint2d(75,15)
    Dim oCustomTable As CustomTable
    oCustomTable = oSheet.CustomTables.Add("Evap Details", oPoint, 12, 1, oContents)
    
 

End Select

 

0 Likes
Message 3 of 4

wayne.brill
Collaborator
Collaborator
Accepted solution

Hi,

 

Here is an ilogic rule that just creates the CustomTable with just the columns. (ShowTitle=False and delete row 1)  Some of the columns did not display if they had the exact same character as the preceding column. Not sure what you want in the columns title with just the underscores. Perhaps you could have some text instead. 

 

    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
    
    Dim oSheet As Sheet
    oSheet = oDrawDoc.ActiveSheet
    
    Dim oContents(0 To 11) As String
    oContents(0) = "ADT-040"
    oContents(1) = "29 1/2 in"
    oContents(2) = "17 1/4 in"
    oContents(3) = "_" 
    oContents(4) = "-" 'if this is an underscore like line above it does not create the column 
    oContents(5) = "1/2 in OD"
    oContents(6) = "7/8 in OD"
    oContents(7) = "3/4 in MPT"
    oContents(8) = "28"
    oContents(9) = "1"
    oContents(10) = "1.8"
    oContents(11) = "1 " ' needed to add a space to get the column created
    
    Dim oPoint As Point2d
    oPoint = ThisApplication.TransientGeometry.CreatePoint2d(55, 15)
    
    Dim oCustomTable As CustomTable
   ' Set oCustomTable = oSheet.CustomTables.Add("Evap Details", oPoint, 12, 1, oContents)
    oCustomTable = oSheet.CustomTables.Add("Evap Details", oPoint, 12, 1, oContents)
    
    oCustomTable.ShowTitle = False

	oCustomTable.Rows(1).Delete

Thanks,

Wayne



Wayne Brill
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 4 of 4

Anonymous
Not applicable

Great!  That works for what I was needing.  The two underscores are simply place holders.  This information is going to be part of a larger table.

0 Likes