Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

ilogic rule for placing the Vault-Revision table on a Inventor-drawing

MarkusGreifeneder3360
Advocate

ilogic rule for placing the Vault-Revision table on a Inventor-drawing

MarkusGreifeneder3360
Advocate
Advocate

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

Reply
Accepted solutions (1)
3,313 Views
17 Replies
Replies (17)

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @MarkusGreifeneder3360,

 

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,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



MarkusGreifeneder3360
Advocate
Advocate

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

 

 

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

Hi @MarkusGreifeneder3360,

 

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,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



RoyWickrama_RWEI
Advisor
Advisor

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.

XXX.png

 

 

0 Likes

b.graaf
Advocate
Advocate

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?

MairA_DUKA
Enthusiast
Enthusiast

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?

YuhanZhang
Autodesk
Autodesk

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


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

MairA_DUKA
Enthusiast
Enthusiast

Hello

Your code not works.

I have to click with the mouse still on the right position.

0 Likes

YuhanZhang
Autodesk
Autodesk

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


If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes

MairA_DUKA
Enthusiast
Enthusiast

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.

 

0 Likes

tobias_wiesendanger
Advocate
Advocate

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.

0 Likes

david.wartaJA24W
Advocate
Advocate

Double post

D.Warta
Van Halteren Technologies Boxtel B.V., Netherlands
0 Likes

david.wartaJA24W
Advocate
Advocate

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

D.Warta
Van Halteren Technologies Boxtel B.V., Netherlands
0 Likes

YuhanZhang
Autodesk
Autodesk

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?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes

david.wartaJA24W
Advocate
Advocate

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.

D.Warta
Van Halteren Technologies Boxtel B.V., Netherlands
0 Likes

david.wartaJA24W
Advocate
Advocate

In inventor 2024 it is the same behavior

D.Warta
Van Halteren Technologies Boxtel B.V., Netherlands
0 Likes

tmuel
Advocate
Advocate

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.

https://forums.autodesk.com/t5/inventor-programming-ilogic/insert-revision-table-using-bottom-left-c...

 

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

0 Likes