Help with replacing blank cell in revision table

Help with replacing blank cell in revision table

Anonymous
Not applicable
1,273 Views
10 Replies
Message 1 of 11

Help with replacing blank cell in revision table

Anonymous
Not applicable

Hi Guys,

 

I am trying to replace the empty revision number in my table using a code. Basically I want it to detect if there is any text and then if nothing is found, set it equal to 1, whereas if it already 1 or greater it will increase and so on everytime a row in the revision table is added.

 

The revision table looks like this:

13275351_1-1628804583910.png

 

This is a snippet of the code for the section I am trying to code:

	 Dim oCell1 As RevisionTableCell = oRow.Item(1)
		 
	If iProperties.Value("Project", "Revision Number") = "" Then
		iProperties.Value("Project", "Revision Number") = 1
		oCell1.Text = iProperties.Value("Project", "Revision Number") 

	ElseIf iProperties.Value("Project", "Revision Number") > 1 Then
		iProperties.Value("Project", "Revision Number") = Fruitloop
		Fruitloop = Fruitloop + 1
		iProperties.Value("Project", "Revision Number") = Fruitloop
		oCell1.Text = iProperties.Value("Project", "Revision Number")

 

 

0 Likes
1,274 Views
10 Replies
Replies (10)
Message 2 of 11

A.Acheson
Mentor
Mentor

I think you should be able to extract the relevant for loops required to loop through the revision rows from this last post.


https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/ilogic-help-with-drawing-rules/m-p/1052...

 

Can you post the whole code your using?

It can be hard for anyone to test with just a fraction of the code. 

Is the empty revision number in all your drawing going to be blank or will it likely have other revision numbers? I assume the picture would end up as 1,2,3 when it’s done? 

Are these new revision tables or existing ?

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

Anonymous
Not applicable

Hey,


Thanks for your reply... I did try that but the revision column was always left blank.

 

This is the code: 

Sub Main
	Dim oDrawDoc As DrawingDocument 
	oDrawDoc = ThisApplication.ActiveDocument
	Dim oSheet As Sheet
	oSheet = oDrawDoc.ActiveSheet
	Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
	Dim oTablePt As Point2d = oTG.CreatePoint2d(0, 0)'loosely position Table
	Dim oRevStyle As RevisionTableStyle
	Dim oRevTable As RevisionTable 
	oRevStyle = oDrawDoc.StylesManager.RevisionTableStyles.Item("Revision Table (ISO)")'You can enter in a revision style by name sample "Rev Table 1"
	Neigh = 0
	

	If oSheet.RevisionTables.Count = 1 Then
	
		Call Positiontable(oTablePt,oSheet)
		oRevTable = oSheet.RevisionTables.Item(1)
		
		'Change RevTable Style
        oRevTable.Style = oRevStyle
		
		Dim oRow As RevisionTableRow 
		oRow = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count) 
		
		'Enter 1st row Contents
		booleanParam = InputRadioBox("Pick One", "Continue Editing Current REV",  "Add REV",True, Title := "Revision Box Options")
		
		If booleanParam = True
			Call RevisionTableContents(oRow)
		ElseIf booleanParam = False
				
			Dim oRows As RevisionTableRows = oRevTable.RevisionTableRows
			
			'add new empty row
			oRows.Add()
			Call Positiontable(oTablePt,oSheet)
			'Get current Row by counting
			oRow = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count)
	        
			'Add new row contents
			Call RevisionTableContents(oRow)
				
		End If
			
	Else If oSheet.RevisionTables.Count = 0 Then
		
		 
		Dim oRTBs As RevisionTables 
		oRTBs = oSheet.RevisionTables 
		
		'add a new revision table instructions
		'RevisionTables.Add2( PlacementPoint As Point2d, [IsSheetScope] As Boolean, 
		'[AutoIndex] As Boolean, [AlphaIndex] As Boolean, [StartValue] As String, 
		'[RevisionTableStyle] As Variant, [Layer] As Variant ) As RevisionTable 
		
		Dim oRTB As RevisionTable 
		oRTB = oRTBs.Add2(oTablePt,False, True, False, "0" )'oLocation
		
		'Position Table after initial insert
		Call Positiontable(oTablePt, oSheet)
		
		oRevTable = oSheet.RevisionTables.Item(1)
		
		'Change RevTable Style
		oRevTable.Style = oRevStyle
		
		Dim oRow As RevisionTableRow 
		oRow = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count) 
		
		If oRow.IsActiveRow Then 
				
			'Enter 1st row Contents
		    Call RevisionTableContents(oRow)
			'ensure rev block is set to write to iProperty, This can be modified in two places in the editor and in the template when placing
			oRTB.UpdatePropertyToRevisionNumber = True      
		
		End If
	
	End If
	Call Positiontable(oTablePt,oSheet)
End Sub
	
	 Sub RevisionTableContents(oRow)
		 
		 Dim oCell1 As RevisionTableCell = oRow.Item(1)
		 
	If iProperties.Value("Project", "Revision Number") = "" Then
		iProperties.Value("Project", "Revision Number") = 1
		oCell1.Text = iProperties.Value("Project", "Revision Number") 

	ElseIf iProperties.Value("Project", "Revision Number") >= 1 Then
		iProperties.Value("Project", "Revision Number") = Fruitloop
		Fruitloop = Fruitloop + 1
		iProperties.Value("Project", "Revision Number") = Fruitloop
		oCell1.Text = iProperties.Value("Project", "Revision Number")
			
	End If
		 
		
		 '[Revision COL 2 Date
 		Dim oCell2 As RevisionTableCell = oRow.Item(2)
		'Set it equal to the the current date, date format change from Computer default        
		oCell2.Text= DateTime.Now.ToString("dd-MM-yyyy")
		 'dt.ToString("dd/MMMM yyyy, dddd")
		 
		'[Revision COL 3 Description
		Dim MyArrayList3 As New ArrayList
		
		MyArrayList3.Add("FOR CUSTOMER REVIEW")
		MyArrayList3.Add("FOR CUSTOMER APPROVAL")
		MyArrayList3.Add("INITIAL RELEASE")	
		MyArrayList3.Add("ENTER CUSTOM COMMENT")
		
		oArray3 = InputListBox("Select one:", MyArrayList3, "", "iLogic", "REV Description")
		
		If oArray3 = "" Then
		
	    ElseIf oArray3 = "ENTER CUSTOM COMMENT" Then
				oInput3 = UCase(InputBox("What did you change?", "REV", "UPDATED REVISION...."))
			
				If oInput3 = "" Then
				
				Else
					Dim oCell3 As RevisionTableCell = oRow.Item(3)
				oCell3.Text = oInput3
				End If
			
		Else
			Dim oCell3 As RevisionTableCell = oRow.Item(3)
				oCell3.Text = oArray3
				
		End If	
				']
			'[Revision COL 4 Approved
			Dim MyArrayList4 As New ArrayList
			MyArrayList4.Add("John")
			MyArrayList4.Add("Markinson")
			MyArrayList4.Add("Jeff")
			
				
			oArray4 = InputListBox("Select one:", MyArrayList4, "", "iLogic", "Approved By")
		
		If oArray4 = "" Then
			
		Else

			Dim oCell4 As RevisionTableCell = oRow.Item(4)
			oCell4.Text = oArray4
			
		End If
												
										']
			'[Revision COL 5 Zone	
			Dim MyArrayList5 As New ArrayList
			MyArrayList5.Add("-")
			MyArrayList5.Add("A1")
			MyArrayList5.Add("A2")
			MyArrayList5.Add("B1")
			

			oArray5 = InputListBox("Select one:", MyArrayList5, "", "iLogic", "Zone Changes ")
		
		If oArray5 = "" Then
			
		Else

			Dim oCell5 As RevisionTableCell = oRow.Item(5)
			oCell5.Text = oArray5
		End If
		
		End Sub
	']

	Private Sub	Positiontable( oTablePt As Point2d,oSheet As Sheet)

Dim oRevTableItem As RevisionTable
oRevTableItem = oSheet.RevisionTables.Item(1) 

oDrawDoc = ThisDoc.Document
For Each oSymbol In oDrawDoc.ActiveSheet.SketchedSymbols
	'look for the symbol by name
	If oSymbol.Name = "WARNING" Then
		oSymbol.Delete
	End If
Next 

End Sub

''' REMOVING SYMBOL
''' '''
0 Likes
Message 4 of 11

A.Acheson
Mentor
Mentor

I have modified the  rule you supplied above as the move sub routine had being replaced by another sub routine. Regarding Cell 1, the revision box will populate if the revision table  is new to the sheet. We are simply automating the manual process for using autoindexing shown in the image.

 

AAcheson_0-1628870245464.png

and these are the lines that carry out this

 

oRTB = oRTBs.Add2(oTablePt,False, True, False, "0" )

and here is the explanation of this call and what variable to modify 

 

'add a new revision table instructions
		'RevisionTables.Add2( PlacementPoint As Point2d, [IsSheetScope] As Boolean, 
		'[AutoIndex] As Boolean, [AlphaIndex] As Boolean, [StartValue] As String, 
		'[RevisionTableStyle] As Variant, [Layer] As Variant ) As RevisionTable 

 and this line takes the revision table REV number and places in the iproperty revision number

 

oRTB.UpdatePropertyToRevisionNumber = True 

 

 

 

So this leads to the next question are you modifying a lot of revision tables that are existing? If there is only a handful you could just delete and recreate with the auto indexing switched on. This way when you manually have to modify the revision box and add a row everything works the same.

 

Working Rule:

 

Sub Main
	Dim oDrawDoc As DrawingDocument 
	oDrawDoc = ThisApplication.ActiveDocument
	Dim oSheet As Sheet
	oSheet = oDrawDoc.ActiveSheet
	Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
	Dim oTablePt As Point2d = oTG.CreatePoint2d(0, 0)'loosely position Table
	Dim oRevStyle As RevisionTableStyle
	Dim oRevTable As RevisionTable 
	oRevStyle = oDrawDoc.StylesManager.RevisionTableStyles.Item("Revision Table (ISO)")'Revision Table (ISO)'You can enter in a revision style by name sample "Rev Table 1"
	Neigh = 0
	

	If oSheet.RevisionTables.Count = 1 Then
	
		Call Positiontable(oTablePt,oSheet)
		oRevTable = oSheet.RevisionTables.Item(1)
		
		'Change RevTable Style
        oRevTable.Style = oRevStyle
		
		Dim oRow As RevisionTableRow 
		oRow = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count) 
		
		'Enter 1st row Contents
		booleanParam = InputRadioBox("Pick One", "Continue Editing Current REV",  "Add REV",True, Title := "Revision Box Options")
		
		If booleanParam = True
			Call RevisionTableContents(oRow)
		ElseIf booleanParam = False
				
			Dim oRows As RevisionTableRows = oRevTable.RevisionTableRows
			
			'add new empty row
			oRows.Add()
			Call Positiontable(oTablePt,oSheet)
			'Get current Row by counting
			oRow = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count)
	        
			'Add new row contents
			Call RevisionTableContents(oRow)
				
		End If
			
	Else If oSheet.RevisionTables.Count = 0 Then
		
		 
		Dim oRTBs As RevisionTables 
		oRTBs = oSheet.RevisionTables 
		
		'add a new revision table instructions
		'RevisionTables.Add2( PlacementPoint As Point2d, [IsSheetScope] As Boolean, 
		'[AutoIndex] As Boolean, [AlphaIndex] As Boolean, [StartValue] As String, 
		'[RevisionTableStyle] As Variant, [Layer] As Variant ) As RevisionTable 
		
		Dim oRTB As RevisionTable 
		oRTB = oRTBs.Add2(oTablePt,False, True, False, "0" )'oLocation
		
		'Position Table after initial insert
		Call Positiontable(oTablePt, oSheet)
		
		oRevTable = oSheet.RevisionTables.Item(1)
		
		'Change RevTable Style
		oRevTable.Style = oRevStyle
		
		Dim oRow As RevisionTableRow 
		oRow = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count) 
		
		If oRow.IsActiveRow Then 
				
			'Enter 1st row Contents
		    Call RevisionTableContents(oRow)
			'ensure rev block is set to write to iProperty, This can be modified in two places in the editor and in the template when placing
			oRTB.UpdatePropertyToRevisionNumber = True  
		
		End If
	
	End If
	Call Positiontable(oTablePt,oSheet)
End Sub
	
	 Sub RevisionTableContents(oRow)
		 
		 '[Revision COL 2 Date
 		Dim oCell2 As RevisionTableCell = oRow.Item(2)
		'Set it equal to the the current date, date format change from Computer default        
		oCell2.Text= DateTime.Now.ToString("dd-MM-yyyy")
		 'dt.ToString("dd/MMMM yyyy, dddd")
		 
		'[Revision COL 3 Description
		Dim MyArrayList3 As New ArrayList
		
		MyArrayList3.Add("FOR CUSTOMER REVIEW")
		MyArrayList3.Add("FOR CUSTOMER APPROVAL")
		MyArrayList3.Add("INITIAL RELEASE")	
		MyArrayList3.Add("ENTER CUSTOM COMMENT")
		
		oArray3 = InputListBox("Select one:", MyArrayList3, "", "iLogic", "REV Description")
		
		If oArray3 = "" Then
		
	    ElseIf oArray3 = "ENTER CUSTOM COMMENT" Then
				oInput3 = UCase(InputBox("What did you change?", "REV", "UPDATED REVISION...."))
			
				If oInput3 = "" Then
				
				Else
					Dim oCell3 As RevisionTableCell = oRow.Item(3)
				oCell3.Text = oInput3
				End If
			
		Else
			Dim oCell3 As RevisionTableCell = oRow.Item(3)
				oCell3.Text = oArray3
				
		End If	
				']
			'[Revision COL 4 Approved
			Dim MyArrayList4 As New ArrayList
			MyArrayList4.Add("John")
			MyArrayList4.Add("Markinson")
			MyArrayList4.Add("Jeff")
			
				
			oArray4 = InputListBox("Select one:", MyArrayList4, "", "iLogic", "Approved By")
		
		If oArray4 = "" Then
			
		Else

			Dim oCell4 As RevisionTableCell = oRow.Item(4)
			oCell4.Text = oArray4
			
		End If
												
										']
			'[Revision COL 5 Zone	
			Dim MyArrayList5 As New ArrayList
			MyArrayList5.Add("-")
			MyArrayList5.Add("A1")
			MyArrayList5.Add("A2")
			MyArrayList5.Add("B1")
			

			oArray5 = InputListBox("Select one:", MyArrayList5, "", "iLogic", "Zone Changes ")
		
		If oArray5 = "" Then
			
		Else

			Dim oCell5 As RevisionTableCell = oRow.Item(5)
			oCell5.Text = oArray5
		End If
		
		End Sub
	']


	Private Sub	Positiontable( oTablePt As Point2d,oSheet As Sheet)

Dim oRevTableItem As RevisionTable
oRevTableItem = oSheet.RevisionTables.Item(1) 

Dim oWidthRevTable As Double
oWidthRevTable = oRevTableItem.RangeBox.MaxPoint.X - oRevTableItem.RangeBox.MinPoint.X

Dim oHeightRevTable As Double
oHeightRevTable = oRevTableItem.RangeBox.MaxPoint.Y - oRevTableItem.RangeBox.MinPoint.Y

oTablePt = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Border.RangeBox.MaxPoint.X - oWidthRevTable, oSheet.TitleBlock.RangeBox.MaxPoint.Y + oHeightRevTable)

oRevTableItem.Position = oTablePt
End Sub

 

 

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

rfgeefshuysen
Contributor
Contributor

Hi guys, i've implemented this rev table rule too! added a couple of columns and changed it here and there so it fits our purposes. it works amazingly. just one question left: we work with alphabetical revisions. how can i change that, since we have numerical revisions with this code.

 

also can i apply this to different rev table styles? 

one rev table has 1 draftsman and 3 checkers (for developed in house components). the other rev table has 1 draftsman and 2 checkers( for external projects).  so im actually looking for another pop up right at the start that asks for: "project" or "component". depending on that i have to fill in 2 or 3 checkers/approvers. 

0 Likes
Message 6 of 11

rfgeefshuysen
Contributor
Contributor

1

0 Likes
Message 7 of 11

A.Acheson
Mentor
Mentor

If your search through and look for alpha index boolean in the notes 📝 and in the code below you can see what needs to change. Change false to true and choose what letter you want to start at. 

'add a new revision table instructions
		'RevisionTables.Add2( PlacementPoint As Point2d, [IsSheetScope] As Boolean, 
		'[AutoIndex] As Boolean, [AlphaIndex] As Boolean, [StartValue] As String, 
		'[RevisionTableStyle] As Variant, [Layer] As Variant ) As RevisionTable 
		
		Dim oRTB As RevisionTable 
		oRTB = oRTBs.Add2(oTablePt,False, True, False, "0" )'oLocation

For the style this is where the style is selected. You can use a case/if statement to select the style and then duplicate the rest of the code per if statement and change as required. 

oRevStyle = oDrawDoc.StylesManager.RevisionTableStyles.Item("Revision Table (ISO)")'Revision Table (ISO)'You can enter in a revision style by name sample "Rev Table 1"

 

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

rfgeefshuysen
Contributor
Contributor

Awesome the alphabetical revision works fine now! 

 

for the revision styles.. I'm obviously not that experienced in coding.  

if I understood correctly, edit the style like the following

oRevStyle = oDrawDoc.StylesManager.RevisionTableStyles.Item("Revision Table (ISO)")'Revision Table (ISO)'You can enter in a revision style by name sample "Rev Table 1"

 and change the revision table RevisionTableStyles.Item("Revision Table (ISO)") to, in our case,  "PROJECTS"

 

then add in some code "case/if" ? and then add in this rule again?

...RevisionTableStyles.Item("Revision Table (ISO)") to, in our case,  "COMPONENTS" (see picture for styles)

 

then i have to copy the whole code underneath and past it somewhere haha. see.. I'm lost haha

 

last things.. 

determining the position of the rev table. how can i influence that?

see picture, it's placed at the drawing border instead of above the stamp.

and use the current date or select a revision date? is that also possible?

 

Again, I'm very thankful for your help, this coding is a whole new side of inventor that I really like

0 Likes
Message 9 of 11

A.Acheson
Mentor
Mentor
  1. Up near the top you can place a boolean message box and set the style object. See below if statement.
  2. You will need to create a new subroutine for the extra revision table modification denoted by RevisionTableContents(oRow) call the new one RevisionTableContents2(oRow). Which is just a copy of the original and change around the cell referencing as you need. Just do one step at a time and test to ensure it still functions.
  3. Next use a similar if statement as the style to switch the sub routines for modifying the table. This should minimize the extra code and allow the changes you need. 
If TemplateName="PROJECTS" Then
	oRevStyle = oDrawDoc.StylesManager.RevisionTableStyles.Item("Rev1")
ElseIf TemplateName="COMPONENTS" Then
oRevStyle = oDrawDoc.StylesManager.RevisionTableStyles.Item("Rev2")
End If

  I looked at the move and if you run the rule in sequence it should move the revision block correctly as it is simply measuring the length of the revision block and adjusting it in from the border and up from the titleblock. 

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

rfgeefshuysen
Contributor
Contributor

hi Alan, 

 

Many thanks for the help, your solution was way above my knowledge of coding, I have tried and cursed and tried again haha. Can you maybe provide the entire code? At the moment I can run through the program and change the format style manually after the rule is closed in the Format ribbon now. Of course things would be extremely fancy if you already have the option to choose between revision table format styles at the beginning. Another thing is that the date now is automatically placed at "today" whilst in engineering the date is sometimes set at a deliverable date in the future. Is it also possible to code a  "pick a date" or choose "todays date"?

 

kind regards, 

René

 

0 Likes
Message 11 of 11

A.Acheson
Mentor
Mentor

Hi @rfgeefshuysen could you provide your attempt so we can then see what tweeks are needed. If you follow the instructions you should be able to put that together. Take small steps to avoid making too many untraceable errors and undo will be your friend. The date in the future is probably easiest handle with an input box where the user types the date in.

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