Adding revision rows

Adding revision rows

christian_a6KG7M
Participant Participant
787 Views
5 Replies
Message 1 of 6

Adding revision rows

christian_a6KG7M
Participant
Participant

Hi,

 

I am struggling with a problem to automate revision rows.

i have made a code so that when the revision is 0 or 1 the code adds a revision table and then for every new revision added to the part the revision number on the drawing is also counted up and a new revision row is added.

christian_a6KG7M_0-1710323021053.png

but if I accidentally delete the revision table and then run the code again the code does not add new rows but instead it just change revision number on the first row in the table to active revision number.

christian_a6KG7M_1-1710323126947.png

How do I code it so that even if I by accident delete the table the code will still add new rows up to the active revision number?

Here is the code:

Sub main()
InventorVb.DocumentUpdate()
iLogicVb.UpdateWhenDone = True
Dim updateCmd As ControlDefinition
updateCmd = ThisApplication.CommandManager.ControlDefinitions.Item("UpdateCopiedModeliPropertiesCmd")
updateCmd.Execute2(True)

Dim Odoc As Document = ThisDoc.Document
	Dim DrawDoc As DrawingDocument = ThisApplication.ActiveDocument
	Dim oSheet As Sheet
	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
    If ActiveSheet.Border="A4 Stående" Then
	oLocation = ThisApplication.TransientGeometry.CreatePoint2d(2, 28.55)
	Else
	oLocation = ThisApplication.TransientGeometry.CreatePoint2d(2, 1.9596)
	End If
   		oRTB = oRTBs.Add2(oLocation, False, True, True, "1")
		oRTB.UpdatePropertyToRevisionNumber = False
End Sub

Sub Stylesedit (Odoc As Document)
	Dim oDocStyles As Inventor.DrawingStylesManager
	Dim oRevStyle As RevisionTableStyle
	Dim oRevisionTable As RevisionTable
	Dim oLocation As Point2d 
	
	'Checks which border is active and change revisionstyle and position accordingly
	If ActiveSheet.Border = "A4 Stående" Then 
	oDocStyles = Odoc.StylesManager
    oRevStyle = oDocStyles.RevisionTableStyles.Item("Revision A4 Stående")
    oRevisionTable = Odoc.Sheets(1).RevisionTables(1)
	oLocation = ThisApplication.TransientGeometry.CreatePoint2d(2, 28.55)
	ActiveSheet.Sheet.RevisionTables.Item(1).Position=oLocation
	
	oRevisionTable.Style = oRevStyle
	Else
	
    oDocStyles = Odoc.StylesManager
    oRevStyle = oDocStyles.RevisionTableStyles.Item("Revision")
    oRevisionTable = Odoc.Sheets(1).RevisionTables(1)
	oLocation = ThisApplication.TransientGeometry.CreatePoint2d(2, 1.9596)
	ActiveSheet.Sheet.RevisionTables.Item(1).Position=oLocation
	
	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 r As Inventor.RevisionTableRow
	Dim oRev As RevisionTableCell = oRow.Item(1)
	
	If oRev.Text = iProperties.Value("Project", "Revision Number") Then
	Exit Sub
	
	Else If oRev.Text < iProperties.Value("Project", "Revision Number") Then
		
	Dim oRows As RevisionTableRows = oRevTable.RevisionTableRows
	r = oRows.Add()
	Dim rnmbr As Integer = Asc(r.Item(1).Text) - 63
	r.Item(1).Text = rnmbr
	
	Else If oRev.Text > iProperties.Value("Project", "Revision Number") Then
	MessageBox.Show("Obs! Antal revisioner stämmer inte med modellens revision. Kontrollera så att revisionerna stämmer överens", "Revision stämmer inte överens", OK)
	Exit Sub
	End If
End Sub







 

Thanks in advance!

 

0 Likes
788 Views
5 Replies
Replies (5)
Message 2 of 6

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Do I understand that you want to keep the history of the deleted Revision table and start the table as if it was never deleted. So that if you add a new revision for example 3 you also have revision 0 1 and 2 again in the Revision Table, Correct?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 6

christian_a6KG7M
Participant
Participant

Hi @bradeneuropeArthur ,

 

Yes that is correct.

0 Likes
Message 4 of 6

christian_a6KG7M
Participant
Participant

Anyone that can help me with this?

Thanks in advance!

0 Likes
Message 5 of 6

A.Acheson
Mentor
Mentor

In my opinion their is no way to store information in the off chance you delete the table. We'll there likely is in hidden properties but it would be adding in a complicated redundancy. It would be best to press the undo button or retrieve the table from a previous version through vault.

 

How do you currently carry out the task manually your trying to automate? If you list the detail steps it could be automated.  

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 6 of 6

christian_a6KG7M
Participant
Participant

Hm ok. But is there a possibility that the code counts number of revision rows that exists in the document and compare this with the active revision number. if there are less rows it will add as many rows as needed to get same number as the active revision number?

 

Today we are adding the new revision number in the part and then again in the drawing. We are then using a sketch symbol instead and just fill in the text and number manually. this often leads to that people forget to add the revision row.

 

My goal is to automatically add a new reivision row and then with another code during closing the drawing, check that the revision row is filled in. if not then you get a warning.

0 Likes