iLogic revision tables

iLogic revision tables

Anonymous
Not applicable
2,773 Views
3 Replies
Message 1 of 4

iLogic revision tables

Anonymous
Not applicable

I have this code that I am running to speed up the revision table process.

Most of it works the way it should.

I want to add a revision table to the drawing if there isn't one already. If there is one I want to delete it and insert a new one with two rows already filled out.

I can get the initial row to display the information I want it to, but when it comes to adding a row and changing that new rows information I get stuck.

 

I don't understand how you use the count function when calling up the second row, in the first instance of count rows there is only the one row so it is ok.

 

This code has been largely borrowed from these forums.

 

Anyone throw any light on this for me?

 

SyntaxEditor Code Snippet


Sub
Main() 'check to see if this is a drawing type file, if it isn't sub routine closes. If ThisApplication.ActiveDocumentType <> kDrawingDocumentObject Exit Sub End If Dim oDoc as Document = ThisApplication.ActiveDocument Dim oUser As String: oUser=ThisApplication.GeneralOptions.UserName() Dim oRow As RevisionTableRow Dim oSheet As Sheet 'For Each osheet For Each osheet In odoc.sheets oSheet.Activate Dim oTablePt As Point2d oTablePt = ThisApplication.TransientGeometry.CreatePoint2d((oSheet.Width - 21.2), 58.4) Dim oRevTable As RevisionTable If oSheet.RevisionTables.Count = 1 Then For Each oRevTable In oSheet.RevisionTables oRevTable.Delete Next End If If oSheet.RevisionTables.Count = 0 Then oRevTable = oSheet.RevisionTables.Add(oTablePt) 'ADDS A POINT FOR THE REV TABLE TO ATTACH TO IF THERE IS NOT A REVISION TABLE IN THE DRAWING End If 'Dim oRevTable As RevisionTable = oDoc.ActiveSheet.RevisionTables.Item(1) 'oRevTable.RevisionTableRows.Add() oRow = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count) ' Make sure we have the active row If oRow.IsActiveRow Then Dim oCell1 As RevisionTableCell = oRow.Item(1) 'Set it TO 0 oCell1.text= ("0") iProperties.Value("Project", "Revision Number") = oCell1.text Dim oCell2 As RevisionTableCell = oRow.Item(2) 'Set it ISSUED FOR APPROVAL oCell2.Text= ("ISSUED FOR APPROVAL") Dim oCell3 As RevisionTableCell = oRow.Item(3) 'Set it equal to the the current date oCell3.Text= ("13/11/2017") Dim oCell4 As RevisionTableCell = oRow.Item(4) 'Set it equal to the the current date oCell4.Text= iProperties.Value("Summary", "AUTHOR") Dim oCell5 As RevisionTableCell = oRow.Item(5) 'Set it equal to the the current date oCell5.Text= ("") End If Dim oRows As RevisionTableRows = oRevTable.RevisionTableRows oRows.Add() Dim oRow1 As RevisionTableRow oRow1 = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count) If oRow1.IsActiveRow Then Dim oCell6 As RevisionTableCell = oRow1.Item(1) 'Set it TO 1 oCell6.text= (1) iProperties.Value("Project", "Revision Number") = oCell6.text Dim oCell7 As RevisionTableCell = oRow1.Item(2) 'Set it ISSUED FOR CONSTRUCTION oCell7.Text= ("ISSUED FOR CONSTRUCTION") Dim oCell8 As RevisionTableCell = oRow1.Item(3) 'Set it equal to the the current date oCell8.Text= DateTime.Now.ToString("d") Dim oCell9 As RevisionTableCell = oRow1.Item(4) 'Set it equal to the the current date oCell9.Text= iProperties.Value("Summary", "AUTHOR") Dim oCell10 As RevisionTableCell = oRow1.Item(5) 'Set it equal to the the current date oCell10.Text= ("") End If Next ActiveSheet = ThisDrawing.Sheet("Sheet:1") End Sub

 

2,774 Views
3 Replies
Replies (3)
Message 2 of 4

clutsa
Collaborator
Collaborator

This is some code I wrote to update the rev table to make sure each row was for an actual controlled revision and not just another line added to the table (this was important when we updated to using released states in vault.) It's more then what you need but it does have some examples of looping thru table rows. It's not commented the best so if you still don't understand I can try to break this down better. 

Sub customRevTableData()
    Dim doc As Document
    'Dim revTable As RevisionTable
    Set doc = ThisApplication.ActiveDocument
    Dim customrow As Boolean
    Set revTable = doc.Sheets.Item(1).RevisionTables.Item(1)
    Set revrows = revTable.RevisionTableRows
    Dim tempTable(8, 1) As String
    Dim screenPos As Point2d
    Set screenPos = revTable.Position
'capture all data in current rev table For Each r In revrows Count = Count + 1 tempTable(Count, 0) = r.Item(1).Text tempTable(Count, 1) = r.Item(2).Text If r.Custom = True Then customrow = True Next Debug.Print ("Table contains custom data: " & customrow) revTable.Delete Set ctrdef = ThisApplication.CommandManager.ControlDefinitions.Item("VaultPropertyWriteBack") 'same as clicking Vault->Update Properties Call doc.Sheets.Item(1).RevisionTables.Add2(screenPos, False, True, True, "A") Set newtable = doc.Sheets.Item(1).RevisionTables.Item(1)
'below is probably the part you want to reference For r = 1 To 8 With newtable.RevisionTableRows If .Count < r And Not tempTable(r, 0) = "" Then .Add 'if there aren't enough rows and the first column of the array of old data isn't blank then add a row If .Count = r Then .Item(r).Item(1).Text = tempTable(r, 0) 'add rev. letter to column 1 .Item(r).Item(2).Text = tempTable(r, 1) 'add rev. notes to column 2 Else Exit For End If End With Next End Sub

You may just try dropping the 

If oRow1.IsActiveRow Then

and

End If

off your code and see what happens. 

If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

0 Likes
Message 3 of 4

schakradeo
Observer
Observer

 


Hello!

Slightly related...I want to change the revision on my sheet from A0,A1,A2... to B. I want to create an ilogic rule for that. I'm trying to create an ilogic rule where you would delete all the revision rows except the first one, and rename the first column to "B" I also want to automatically save the file after changing the rev table.

 

I tried creating an ilogic rule to change the Revision number property under iProperties>Project. But that doesn't update the revision in the title block correctly. Apparently the revision number iProperty and the one displayed on the title block is different. Any help would be appreciated!

0 Likes
Message 4 of 4

A.Acheson
Mentor
Mentor

@schakradeo 

 

It might have been better to create a new post due to the age of these post and your's it will cover different content.

Do you need to preserve the contents of the old revision block? If not it might be easier to delete the rev block and add a new one in.

 

The REV iproperty and the revision Block REV are independant of each other until there linked together. The revision Block REV will drive the REV iproperty when linked. The link below shows how to do that through code, and the last button in the revision editor with tool tip "Update Property to Revision Number" does this manually. 

 

https://forums.autodesk.com/t5/inventor-customization/creating-sheet-scope-revision-table-using-ilog...

 

If you have any code attempted post it and it can be a starting point. 

Hope this helps

 

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