Hi,
I need an ilogic rule that places the Vault-Revision-Table on the first page (or active page) of the opened Inventor-drawing.
The insert point should be related to the right/lower corner of the sheet and the insert Point can be modified in the ilogic rule (x/y)
Can someone help?
Thank you for your advice
Markus
Solved! Go to Solution.
Solved by chandra.shekar.g. Go to Solution.
Try the following iLogic rule to insert / add Revision Table.
Dim oDrawingDoc As DrawingDocument oDrawingDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet oSheet = oDrawingDoc.ActiveSheet Dim oTablePt As Point2d oTablePt = ThisApplication.TransientGeometry.CreatePoint2d(2, 3) Dim oRevTable As RevisionTable oRevTable = oSheet.RevisionTables.Add(oTablePt)
Please feel free to contact if there is any doubt.
If solves problem, click on "Accept as solution" / give a "Kudo".
Thanks and regards,
Thank you Chandra,
works nearly perfect for me!
Could you please expand the code with 2 issues:, to make it perfect:
- Position should be related to the right/lower edge of the sheet (actual left/lower)
- Check bevor placing, if there is a "Revision table" already existing, if YES don't set it again
Thanks in advance
Best regards
Markus
Changes made to iLogic rule as per the requirement. Check the same.
Dim oDrawingDoc As DrawingDocument oDrawingDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet oSheet = oDrawingDoc.ActiveSheet Dim oTablePt As Point2d oTablePt = ThisApplication.TransientGeometry.CreatePoint2d((oSheet.Width - 17), 3) If oSheet.RevisionTables.Count = 0 Then Dim oRevTable As RevisionTable oRevTable = oSheet.RevisionTables.Add(oTablePt) Else MessageBox.Show("Revision Table already exist", "Autodesk Inventor") End If
Please feel free to contact if there is any doubt.
If solves problem, click on "Accept as solution" / give a "Kudo".
Thanks and regards,
I used the code. with oTable as shown below:
SyntaxEditor Code Snippet
oTablePt = ThisApplication.TransientGeometry.CreatePoint2d((oSheet.Width-7.75*2.54), 3.4375*2.54)
Horizontally, it is perfect. Vertically, revision table is as shown blow.
Could you help to place the revision block at BOTTOM-LEFT (or BOTTOM-RIGHT) corner.
Hello,
I was looking for something like this.
But if I use the code, I get the "normal" revision table, not the Vault revision table. Or at least it starts with a Revision number of 1, while the Vault revision scheme starts with 0.
Is this a error in the code, or a setting in Inventor/Vault?
Hello
With your code I will get a normal RevisionTable and not the Vault-RevisionTable.
I tried this code to get the correct RevisionTable:
ThisApplication.CommandManager.ControlDefinitions.Item("VaultRevisionBlock").Execute
Now in the drawing I must click to positionate the RevisionTable.
Is it possible to automate this so that the RevisionTable is inserted on a certain 2D-point?
Can you try if below iLogic code works there:
Sub Main()
Dim oCls As New WindowsFunc(ThisApplication)
oCls.PlaceRevTable
End Sub
Class WindowsFunc
Private Declare Auto Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Sub mouse_event Lib "user32"(ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private oApp As Inventor.Application
Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
Sub New(m_App As Inventor.Application)
oApp = m_App
End Sub
Sub PlaceRevTable
Dim x As Long = oApp.Left + oApp.Width / 2
Dim y As Long = oApp.Top + oApp.Height / 2
SetCursorPos(x, y)
oApp.CommandManager.ControlDefinitions.Item("VaultRevisionBlock").Execute
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
End Sub
End Class
Hello
Your code not works.
I have to click with the mouse still on the right position.
Try below iLogic code:
Sub Main()
Dim oCls As New WindowsFunc(ThisApplication)
oCls.PlaceRevTable
End Sub
Class WindowsFunc
Private Declare Auto Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Sub mouse_event Lib "user32"(ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private oApp As Inventor.Application
Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
Sub New(m_App As Inventor.Application)
oApp = m_App
End Sub
Sub PlaceRevTable
Dim x As Long = oApp.Left + oApp.Width / 2
Dim y As Long = oApp.Top + oApp.Height / 2
SetCursorPos(x, y)
Dim i As Integer
Do While i < 50
If i = 0
oApp.CommandManager.ControlDefinitions.Item("VaultRevisionBlock").Execute2(False)
End If
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
i = i +1
Loop
End Sub
End Class
Hello
This is not the solution that I am searching.
Your code will place the Vault-RevisionTable on the center of the screen.
I want place the RevisionTable on a certain X- and Y-Position on the Layout from the Inventor-Drawing.
Thanks for your helb, but I will positionate the RevisionTable manually.
This should be possible if you placed it. After that you can search over your sheet by the name of it. Something like this:
Sub UpdateCustomTable()
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
Dim oTable As RevisionTable
Dim oTablePosition As Point2d
Set oTablePosition = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
For Each oTable In oSheet.RevisionTables
If oTable.Title = "REVISION HISTORY" Then
oTable.Position = oTablePosition
End If
Next
End Sub
Im wondering if there isnt a better way than to use the direct command to place it. This feels like a bad workaround for not allowing any option inside of the normal revision table to choose what to place.
Dear Rocky Zhang,
Your code does the trick for placing a vault revision table. However I would like to move the revision table after it is placed. Currently I use code given by tobias.wiesendanger.
If I try to run the to codes in sequence using
iLogicVb.RunExternalRule("Rule1")
iLogicVb.RunExternalRule("Rule2")
But it does not move the revision table. When I start the rules separately is does work? Any ideas to have one rule to sequence them both. Do I need to activate the sheet again after the placing of the revision table?
thanks in advance,
D.Warta
You can merge Tobias's code into my iLogic rule, like below:
Sub Main()
Dim oCls As New WindowsFunc(ThisApplication)
oCls.PlaceRevTable
' Move the revision table to proper position.
UpdateCustomTablePosition(0,0)
End Sub
Sub UpdateCustomTablePosition(PosX As Double, PosY As Double )
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisDoc.Document
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
Dim oTable As RevisionTable
Dim oTablePosition As Point2d
' Specify the position to move the revision table to.
oTablePosition = ThisApplication.TransientGeometry.CreatePoint2d(PosX, PosY)
For Each oTable In oSheet.RevisionTables
If oTable.Title = "REVISION HISTORY" Then
oTable.Position = oTablePosition
End If
Next
End Sub
Class WindowsFunc
Private Declare Auto Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Sub mouse_event Lib "user32"(ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private oApp As Inventor.Application
Const MOUSEEVENTF_LEFTDOWN = &H2 ' left button down
Const MOUSEEVENTF_LEFTUP = &H4 ' left button up
Sub New(m_App As Inventor.Application)
oApp = m_App
End Sub
Sub PlaceRevTable
Dim x As Long = oApp.Left + oApp.Width / 2
Dim y As Long = oApp.Top + oApp.Height / 2
SetCursorPos(x, y)
Dim i As Integer
Do While i < 50
If i = 0
oApp.CommandManager.ControlDefinitions.Item("VaultRevisionBlock").Execute2(False)
End If
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
i = i +1
Loop
End Sub
End Class
Can you try it there to check if it works well?
Thanks for responding. I tried it, but unfortunately it does not move the revision table. It does place the revison table but does not move it. If I run the script twice it will place another revision table and move the old one.
Btw. I'm still using inventor 2020.
In inventor 2024 it is the same behavior
I am able to get this to work using Inventor 2022 and 2024.
Use the code from this thread to place a revision table with the API options for a normal revision table.
Modify to use the DRAWING scope, instead of SHEET scope.
oRevTable = oSheet.RevisionTables.Add2(oTablePt, FALSE, True, True, "0", oRevTableStyle, )
If your Vault revision tables are configured properly, and you have revisions for this file in Vault, right click over the rev table and you should see the same option to "Populate Vault Data" that you see if you had manually placed a "Vault Revision Table".
Now change the state and cycle the revisions a few times, open the drawing and you will see it populates automatically. Now, manually place a "Vault Revision table" with the same style - you should see that they are identical.
I hope that helps someone else as much as the referenced post helped me.
Tim
Can't find what you're looking for? Ask the community or share your knowledge.