Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

General Table Question on .idw

14 REPLIES 14
SOLVED
Reply
Message 1 of 15
NunoFelix
831 Views, 14 Replies

General Table Question on .idw

Is there a way of formating the columns so that the Column Header's text will be under each other, instead of continuing forward?

 

Example:

 

   Item

Number     instead of      Item Number

Nuno Felix
14 REPLIES 14
Message 2 of 15
bobvdd
in reply to: NunoFelix

if you want to wrap the column headers in a parts list table whenever there is a space in the header text, run below macro.

If tyou want to do the same in a generic table, below technique will not work unfortunately.

 

Public Sub SplitHeaderPartslist()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
Dim oPartslistTable As PartsList
Set oPartslistTable = oSheet.PartsLists.Item(1)
Dim oColumn As PartsListColumn
For Each oColumn In oPartslistTable.PartsListColumns
Dim strarray() As String
strarray = Split(oColumn.Title, " ")
oColumn.Title = ""
Dim i As Integer
For i = 0 To UBound(strarray)
oColumn.Title = oColumn.Title & strarray(i) & Chr(13) & Chr(10)
Next i
Next oColumn
End Sub

 

 

Cheers

Bob




Bob Van der Donck


Principal UX designer DMG group
Message 3 of 15
NunoFelix
in reply to: bobvdd

I wanted to do it on a generic table.

Nuno Felix
Message 4 of 15
bobvdd
in reply to: NunoFelix

Here is the modfified code to make it work on a generic table.

 

Public Sub SplitHeaderCustomTable()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
Dim oGenericTable As CustomTable
Set oGenericTable = oSheet.CustomTables.Item(1)
Dim oColumn As Column
For Each oColumn In oGenericTable.Columns
Dim strarray() As String
strarray = Split(oColumn.Title, " ")
oColumn.Title = strarray(0)
Dim i As Integer
For i = 0 To UBound(strarray)
If i > 0 Then
oColumn.Title = oColumn.Title & Chr(13) & Chr(10) & strarray(i)
End If
Next i
Next oColumn
End Sub

 

 

Enjoy

Bob




Bob Van der Donck


Principal UX designer DMG group
Message 5 of 15
NunoFelix
in reply to: bobvdd

Where do i insert that?

Nuno Felix
Message 6 of 15
bobvdd
in reply to: NunoFelix

Tools > Options > VBA editor

Copy and paste in a new module in the Default.ivb file (Application project), if you want to use this code across multiple drawings.

You can run the macro with ALT+F8.

 

Cheers

Bob




Bob Van der Donck


Principal UX designer DMG group
Message 7 of 15
NunoFelix
in reply to: bobvdd

I think i got it on the right place.

How can i use it now?

Nuno Felix
Message 8 of 15
bobvdd
in reply to: NunoFelix

Make sure you have your drawing active in Inventor and then in the editor hit the "black triangle" . See image.

 

genericlist.JPG

 

Cheers

bob




Bob Van der Donck


Principal UX designer DMG group
Message 9 of 15
NunoFelix
in reply to: bobvdd

Got it.

The only problem is the header is to long on the vertical.

Nuno Felix
Message 10 of 15
NunoFelix
in reply to: NunoFelix

 
Nuno Felix
Message 11 of 15
NunoFelix
in reply to: NunoFelix

I got the length of the heard kinda fixed. But cant edit the text to fit correctly.

See attached picture.

Nuno Felix
Message 12 of 15
bobvdd
in reply to: NunoFelix

The code systematically splits all strings that have a space in them.

If you want to have a text like "DIA. A" on a single line, your will have to enter it as "DIA._A" or change the VBA code. 

 

If you want something like this where only the first 3 strings are wrapped

 

wrap.jpg

 

 

Use this code

 

Public Sub SplitHeaderCustomTable()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
Dim oGenericTable As CustomTable
Set oGenericTable = oSheet.CustomTables.Item(1)
Dim oColumn As Column
For Each oColumn In oGenericTable.Columns
Dim strarray() As String
strarray = Split(oColumn.Title, " ")
oColumn.Title = strarray(0)
Dim i As Integer
For i = 0 To UBound(strarray)
If i > 0 And i <= 3 Then
oColumn.Title = oColumn.Title & Chr(13) & Chr(10) & strarray(i)
End If
If i > 3 Then
oColumn.Title = oColumn.Title & " " & strarray(i)
End If
Next i
Next oColumn
End Sub

 

 

 

Bob




Bob Van der Donck


Principal UX designer DMG group
Message 13 of 15
NunoFelix
in reply to: bobvdd

Still not good.

Nuno Felix
Message 14 of 15
NunoFelix
in reply to: NunoFelix

I believe i got it now.

Thank you so much.

Nuno Felix
Message 15 of 15
bobvdd
in reply to: NunoFelix

You're welcome Nuno.

Bob




Bob Van der Donck


Principal UX designer DMG group

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

Post to forums  

Autodesk Design & Make Report