ILogic rule to copy the existing vault revision table and paste it on all the other pages.

ILogic rule to copy the existing vault revision table and paste it on all the other pages.

anton.nygrenD4R97
Explorer Explorer
368 Views
5 Replies
Message 1 of 6

ILogic rule to copy the existing vault revision table and paste it on all the other pages.

anton.nygrenD4R97
Explorer
Explorer

Hi

Just noticed that now you can copy a revision table and go to the next page and press ctrl + v. It puts the table at the same place and with the same "dimensions" (how much space there is in each column). 

 

Now, is it possible to reach the revision table through iLogic. My idea is to put out a revision table (if it is not already there) and adjust the size manually so that the text fits good. Then i want the ilogic rule to copy it, and paste on the other pages. It also has to check if a revisiontable already is on the page, and remove it if there is one, as if you copy and paste it adds one over the other. 

 

Anyone tried this yet?

0 Likes
Accepted solutions (1)
369 Views
5 Replies
Replies (5)
Message 2 of 6

AndrewHumiston
Advocate
Advocate

Afternoon!

 

here is a sample code you can run to add a revtable to a sheet, and then remove an existing one for each drawing, it will use the default style as your inserted table.

 

Dim oActiveDwg As DrawingDocument = ThisApplication.ActiveDocument

Dim oSheets As Sheets = oActiveDwg.Sheets

Dim oSheet As Sheet
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(36.195, 41.91)
For Each oSheet In oSheets
    For Each oRevTable In oSheet.RevisionTables
        oSheet.RevisionTables.Item(1).Delete
    Next
    oSheet.Activate
    Call oSheet.RevisionTables.Add2(oPlacementPoint, False, True, True, "-")
Next
oSheets.Item(1).Activate

AndrewHumiston_0-1722964244627.png

Here is the Table from the inventor API help if you want to clarify the arguments for the ADD2 method.

 

i also have the point coming in at the upper right hand corner of my border, that is adjustable as well.

 

hope this helps! please accept as a solution if this helped.

 

thank you!

0 Likes
Message 3 of 6

AndrewHumiston
Advocate
Advocate

correction use this code, i had left a specific rev table to delete:

 

Dim oActiveDwg As DrawingDocument = ThisApplication.ActiveDocument

Dim oSheets As Sheets = oActiveDwg.Sheets

Dim oSheet As Sheet
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(36.195, 41.91)
For Each oSheet In oSheets
    For Each oRevTable In oSheet.RevisionTables
        oRevTable.Delete
    Next
    oSheet.Activate
    Call oSheet.RevisionTables.Add2(oPlacementPoint, False, True, True, "-")
Next
oSheets.Item(1).Activate
0 Likes
Message 4 of 6

anton.nygrenD4R97
Explorer
Explorer

Thanks, it does remove the current one and puts out a new one on a specific point. I am more interested in the function copy, as it takes the exact placement and dimensions and then paste it on to the other pages.

The problem with this code is that it reorder the table and not copy the existing one. My revisiontables needs to be different sizes depending on what is written in them, thus why i want to copy the one on the first page and make the rest as it is.

0 Likes
Message 5 of 6

AndrewHumiston
Advocate
Advocate
Anton,
My bad for not understanding you wanted a copy. here is the code that will solve the issue, it copies the rev block on the first page and then deletes the ones as needed and pastes the rev table to the sheet. Please accept as the solution if this solves it, if not lets figure it out!

'set ref to active drawing
Dim oActiveDwg As DrawingDocument= ThisApplication.ActiveDocument

'set ref to sheet 1
Dim oSheet1 As Sheet = oActiveDwg.Sheets.Item(1)

For i = 2 To oActiveDwg.Sheets.Count
'set ref to next sheet
Dim oSheeti As Sheet = oActiveDwg.Sheets.Item(i)
'activate next sheet
oActiveDwg.Sheets.Item(i).Activate
'if a rev table is here delete it
If oSheeti.RevisionTables.Count >= 1 Then
oSheeti.RevisionTables.Item(1).delete
End If
'copy sheet one rev table to sheet
Call oSheet1.RevisionTables.Item(1).CopyTo(oSheeti)
Next

'activate sheet 1
oSheet1.Activate
0 Likes
Message 6 of 6

anton.nygrenD4R97
Explorer
Explorer
Accepted solution

Thanks for the help.

i could now make my own that did as i wanted, as follows:

 

 	'Första raderna Deklarerar "Sparar vilka sidor som är aktiva"
	Dim oDrawDoc As DrawingDocument
	oDrawDoc = ThisApplication.ActiveDocument
	
	Dim myActiveSheet As Sheet
	myActiveSheet = oDrawDoc.ActiveSheet
	
	Dim oSourceDocument As DrawingDocument
    oSourceDocument = ThisApplication.ActiveDocument
	
		
	Dim oSheet1 As Sheet = oDrawDoc.Sheets.Item(1)
	
	'Iterate through the sheets.
    Dim oSheet As Sheet
    For Each oSheet In oSourceDocument.Sheets
        oSheet.Activate
		
		'Tar bort rev-rutor på alla blad utom första
		If ActiveSheet IsNot ThisDrawing.Sheet("Sheet:1")
			If oSheet.RevisionTables.Count >= 1 Then
				oSheet.RevisionTables.Item(1).Delete
			End If
		End If
		
		'Lägger till rev-rutan på första sidan på alla andra sidor
		If ActiveSheet IsNot ThisDrawing.Sheet("Sheet:1")
			Call oSheet1.RevisionTables.Item(1).CopyTo(oSheet)
		End If
		
		
		
		Next
		myActiveSheet.Activate
0 Likes