Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am looking to make make a event trigger that will add a revision table then the iproperty revision number are 1 and then every time the revision number are changed it should add a new row. here i have a few bumps in the road.
- first of all i want the trigger to only add a new row when the iproperty revision number changes. as it is today, the trigger ads a new row every time the trigger is run even if the value is not changed.
- Also, the value of the iproperty revision number should not be affected by adding a new row because this value is set in the part instead. Today this is being changed along with adding a new revision row.
- Next problem is the numbering of the revisions. when there is added more than 2 rows the number of previously revisions are changed to 1 and it is only the last row that has the correct revision number. how do i make it not changing the revision numbers before the last one?
here is my code:
Sub main()
Dim Odoc As Document = ThisDoc.Document
Dim DrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim RevTableCount As Integer = 0
For Each oSheet In DrawDoc.Sheets
If oSheet.RevisionTables.Count = 0 Then
oSheet.Activate
Call AddRevTable(DrawDoc, oSheet)
Call Stylesedit(Odoc)
Else
Call Stylesedit(Odoc)
Call AddRevRow(DrawDoc)
End If
Next
InventorVb.DocumentUpdate()
End Sub
Sub AddRevTable(DrawDoc As DrawingDocument, oSheet As Sheet)
Dim oRTBs As RevisionTables
Dim oLocation As Point2d
Dim oRTB As RevisionTable
oRTBs = oSheet.RevisionTables
oLocation = ThisApplication.TransientGeometry.CreatePoint2d(10, 10)
oRTB = oRTBs.Add2(oLocation, False, True, True, "1")
oRTB.UpdatePropertyToRevisionNumber = True
End Sub
Sub Stylesedit (Odoc As Document)
Dim oDocStyles As Inventor.DrawingStylesManager
Dim oRevStyle As RevisionTableStyle
Dim oRevisionTable As RevisionTable
Dim oLocation As Point2d
'Kontrollerar vilken Border ritningen har och lägger in rätt sorts revisionstabell
If ActiveSheet.Border = "A4 Stående" Then
oDocStyles = Odoc.StylesManager
oRevStyle = oDocStyles.RevisionTableStyles.Item("Revision A4 Stående")
oRevisionTable = Odoc.Sheets(1).RevisionTables(1)
oRevisionTable.Style = oRevStyle
Else
oDocStyles = Odoc.StylesManager
oRevStyle = oDocStyles.RevisionTableStyles.Item("Revision")
oRevisionTable = Odoc.Sheets(1).RevisionTables(1)
oRevisionTable.Style = oRevStyle
End If
End Sub
Sub AddRevRow(DrawDoc As DrawingDocument)
' Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
' Get the revision table
Dim oRevTable As RevisionTable = DrawDoc.ActiveSheet.RevisionTables.Item(1)
' Get last row
Dim oRow As RevisionTableRow
oRow = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count)
' Make sure we have the active row
If oRow.IsActiveRow Then
' Go through all columns in that row
For i = 1 To oRevTable.RevisionTableColumns.Count
Dim oCell As RevisionTableCell = oRow.Item(i)
' Set all cells to static
oCell.Text = oCell.Text
Next
End If
' Add another row at the end
Dim oRows As RevisionTableRows = oRevTable.RevisionTableRows
Dim r As Inventor.RevisionTableRow = oRows.Add()
Dim rnmbr As Integer = Asc(r.Item(1).Text) - 63
r.Item(1).Text = rnmbr
End Sub
Thanks in advance!
Regards,
Christian
Solved! Go to Solution.