Setting up a table with iLogic

Setting up a table with iLogic

luc_reinders
Participant Participant
591 Views
2 Replies
Message 1 of 3

Setting up a table with iLogic

luc_reinders
Participant
Participant

Hello,

 

I make drawings from my sheet metal parts. In these drawings I would like to add a table with information about bending (not the standard bendtable). I've found some rules to set up a table by using iLogic and I tried to change them to the table I want to set up, but I can't make it work. I hope I can make it work with your help.

Here is an example of how the table needs to be: 

BEND SETTINGS.JPG

 

 

 

 

 

 

 

The reason why I want to set it up with iLogic is because I want to set up table the quickly and don't want to look for the table between my files. 

 

I attached 2 files.

Rule 1 has the benefit of filling in all the 'contents'. Because as you can see I want te fill in some of the places.

But when I try to add more rows I get errors.

 

With rule 2 I have more rows, but I can't fill in the 'contents'.

 

I tried to combine the codes to make it work for me and here is my code:

If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing Document must be active for this rule (" & iLogicVb.RuleName & ") to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
	Exit Sub
End If
Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet

Dim oTitle As String = "ZET INSTELLINGEN"
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oPPoint As Point2d = oTG.CreatePoint2d(1, 28.7)
Dim oCols As Integer = 3
Dim oRows As Integer = 7
'Number of column titles supplied must match number of columns specified
'Dim oColTitles() As String = {" ", "Dimension L1", "Dimension L2", "Material", "Cost" }
'or
Dim oColTitles(oCols - 1) As String
oColTitles(0) = " " '1st column title
oColTitles(1) = "U" '2nd column title
oColTitles(2) = "V" '3rd column title




' Set the contents of the custom table (contents are set row-wise)
Dim oContents(21) As String
oContents(0) = "Groef"
oContents(1) = " "
oContents(2) = " "
oContents(3) = " "
oContents(4) = " "
oContents(5) = " "
oContents(6) = "Zetting"
oContents(7) = "Aanslag"
oContents(8) = "Zet lengte"
oContents(9) = "1"
oContents(10) = " "
oContents(11) = " "
oContents(12) = "2"
oContents(13) = " "
oContents(14) = " "
oContents(15) = "3"
oContents(16) = " "
oContents(17) = " "
oContents(18) = "4"
oContents(19) = " "
oContents(21) = " "




'Dim oColWidths() As Double = {1.25, 2.5, 2.5, 1.5, 1.25 }
'or
'could run a function here to determine how wide each column needs to be, then set them individually
Dim oColWidths(oCols - 1) As Double
oColWidths(0) = 2.5 '1st column width
oColWidths(1) = 2.5
oColWidths(2) = 2.5


'Dim oRowHeights() As Double = {.25, .25, .25, .25, .25, .25 }
'or
'could run a function here to determine how tall each row needs to be, then set them individually
Dim oRowHeights(oRows - 1) As Double
For oRow As Integer = 0 To (oRows-1)
	oRowHeights(oRow) = .25
Next

Dim oCTable As CustomTable = oSheet.CustomTables.Add(oTitle, oPPoint, oCols, oRows, oColTitles, oContents, oColWidths, oRowHeights)

 

I can't get the code to work.

Is there a way to make the table like how I want to set it up, or do you have other, smarter or faster ideas to set up the table?

 

Thanks for your help,

 

Luc

 

 

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

theo.bot
Collaborator
Collaborator
Accepted solution

is this what you needed:

Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document

Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet

Dim oColumns As Integer
Dim oRows As Integer
oColumns = 3

oAantal = InputBox("Aantal Zettingen", "Zet tabel", "1")

oRows = 3 + oAantal

'calculate number of columns cells
oCells = oColumns * oRows

Dim oTitles(oColumns - 1) As String

'Hardcoded titles 
oTitles(0) = "-"
oTitles(1) = "U"
oTitles(2) = "V"

Dim oContents(oCells - 1) As String

Dim j As Integer
j = 0
i = 1
Do Until j = oCells
	'fill cell data
	If j = 0 Then
		oContents(j) = "Groef"
	ElseIf j = 6 Then
		oContents(j) = "Zetting"
	ElseIf j = 7 Then
		oContents(j) = "Aanslag"
	ElseIf j = 8 Then
		oContents(j) = "Zet Lengte"
	ElseIf j = 9 Then
		oContents(j) = i
		i = i + 1
	ElseIf j > 9
		If j = 9 + (i - 1) * 3 Then
			oContents(j) = i
			i = i + 1
		Else
			oContents(j) = ""
		End If
	Else
		oContents(j) = ""
	End If
	j = j + 1
Loop

Dim InsP As Point2d
InsP = ThisApplication.TransientGeometry.CreatePoint2d(15, 15)

Dim oCustomTable As CustomTable
oCustomTable = oSheet.CustomTables.Add("Zet Instellingen", InsP, oColumns, oRows, oTitles, oContents)

 Adding Contents is optional, make sure that your content range is exactly the number of row * columns. in most cases this causes the problem creating the table.

0 Likes
Message 3 of 3

luc_reinders
Participant
Participant

Hello @theo.bot,

 

This is even better!

Thank you very much!

0 Likes