Custom table creator in *idw using iLogic

Custom table creator in *idw using iLogic

MASL9LCSZ
Explorer Explorer
553 Views
2 Replies
Message 1 of 3

Custom table creator in *idw using iLogic

MASL9LCSZ
Explorer
Explorer

Hi,

I am fresh into iLogic, but I hope you can help me in my case. 

 

I got assembly of big tank and in this assembly I got multiple pairs of user parameters defined (height of the component and angle of the component).

I want to have a solution that after running the rule, simple table is pasted in the drawing - location of pasting not specified, it will be dragged and dropped after paste.

The table should contain 3 columns and as many rows, as many pair of parameters I have defined.

(COMPONENT | HEIGHT | ANGLE)

'Component' column should consists part names (with occurrence ID, as I got multiple instances of the same part in assembly)

'Height' and 'angle' columns should consist the nominal values of parameters.

Can anybody help me with the code for the first rows that I can develop further?

0 Likes
554 Views
2 Replies
Replies (2)
Message 2 of 3

dalton98
Collaborator
Collaborator

Here is a good example to follow:

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-to-create-custom-table/td-p/8...

 

I tried creating something simmilar to what you wanted. Instead of a parameter named "HEIGHT" and "ANGLE" i just used one named "d4". It was a bit annoying because it would only recognize strings for the table contents. lmk if you have any questions

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

Dim oView As DrawingView = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "pick view")
Dim oAss As AssemblyDocument
oAss = oView.ReferencedDocumentDescriptor.ReferencedDocument

' Set the column titles
Dim oTitles(2) As String
oTitles(0) = "COMPONENT"
oTitles(1) = "HEIGHT"
oTitles(2) = "ANGLE"

' Set the contents of the custom table (contents are set row-wise)
Dim oContents As New List (Of String)
For Each oOcc In oAss.ComponentDefinition.Occurrences
'	Dim oPartComp As PartComponentDefinition
	oPartComp = oOcc.Definition
	Try
	height = oPartComp.Parameters.Item("d4")
'	angle = oPartComp.Parameters.Item("ANGLE")
	oContents.Add(oOcc.Name)
	oContents.Add(oPartComp.Parameters.Item("d4").Value)
	oContents.Add(1)
	Catch
		'doesnt have height AND angle
	End Try
Next

Dim oContents1(oContents.Count - 1) As String
For i As Integer = 0 To oContents.Count - 1
	oContents1(i) = oContents(i)
Next


' 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

oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(15, 15)

' Create the custom table
Dim oCustomTable As CustomTable
oCustomTable = oSheet.CustomTables.Add("My Table", oPlacementPoint, _
3, oContents1.Length/3, oTitles, oContents1)

' 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
0 Likes
Message 3 of 3

dalton98
Collaborator
Collaborator

made it a bit cleaner

0 Likes