Ilogic help with drawing rules

Ilogic help with drawing rules

Anonymous
Not applicable
809 Views
5 Replies
Message 1 of 6

Ilogic help with drawing rules

Anonymous
Not applicable

Hi There!


I am very new to ilogic and need some help with some stuff that can be considered basic...

 

13275351_0-1628458810969.png

I wanted to code something so that everytime I ran the code, the column that says Rev would increase by 1 on the next row. If it was a dash (-), the next one would be a 0 and so on. I am a bit clueless how to code exactly to the revision table to tell it to manipulate it to +1 every time the scrip is "save and run". Also the date next to the rev number would take todays computer date and record it next to the rev number allocated.


Right now my code features this which I have found through browsing the forums and a bit of coding.. Currently it just adds a blank row below every time it is run.

 

13275351_1-1628458969766.png

any help would be appreciated... Thanks heaps

 

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

A.Acheson
Mentor
Mentor
Accepted solution

Welcome to the forum, A tip you can copy the rule directly from the ilogic editor and paste in the post text area, it will then turn up as text that is easy to read and other user can help out  without rewriting the rule. An image can be hard to read  as well

 

There is samples and other information other than the forum located beside your user name in the ribbon beside the ? symbol and under help and Programming API help under search "revision row" Then "RevisionTable Object" Then scroll To the bottom And click "Query revision table"

 

For the indexing do you want to use -,0,1,2,3,4.?

This would go against the normal indexing which would start at 0 and 1 and user would not be able to replicate this manually. As it will jump from - to 1 as 0 is not the start point. In the rule below the the built in indexing  is used for the revision number so it will go from 0,1,2,3,4. If you need a custom rev number you will need to build all this in as value for cell1.

 

The below rule might be more than you need here as it has additional functionality. So modify as necessary.

Functions are:

  1. Adds a table if there is none on the drawing and adds it to a given style change called "TEST" as needed. 
  2. To modify the existing rev row with option to add row with options for contents. 
  3. Move revision table to above the title block and moves it each time you add a row.
  4. Date has special format as our computer system is American date system (month day year) and we are using  day month year in our revision box. Change as needed see windows VB.net help
'Change Revision Table Style
'https://forums.autodesk.com/t5/inventor-customization/ilogic-rule-to-switch-revision-table-sizes-defined-in-styles/td-p/3209372
'https://forums.autodesk.com/t5/inventor-customization/creating-sheet-scope-revision-table-using-ilogic/td-p/6282070
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("TEST")'You can enter in a revision style by name sample "Rev Table 1"

	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
			
	ElseIf 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("AAA")
			MyArrayList4.Add("BBB")
			MyArrayList4.Add("CCC")
			MyArrayList4.Add("DDD")
				
			oArray4 = InputListBox("Select one:", MyArrayList4, "", "iLogic", "Drawn 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("ZONE1")
			MyArrayList5.Add("ZONE2")
			MyArrayList5.Add("ZONE3")
			MyArrayList5.Add("ZONE4")
					

			oArray5 = InputListBox("Select one:", MyArrayList5, "", "iLogic", "Checked By ")
		
		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 3 of 6

Anonymous
Not applicable

Thank you so much for your help Acheson!

 

This is what I needed and now I know.. When I try running this code in my editor it comes up with this message!

 

13275351_0-1628485027172.png

13275351_1-1628485041050.png

 

Any clues on how to fix?

 

0 Likes
Message 4 of 6

A.Acheson
Mentor
Mentor

The only item that should be dependent on a customized input is this line

oRevStyle = oDrawDoc.StylesManager.RevisionTableStyles.Item("TEST")

You will need to change the style of the revision table from “TEST” to your current style you are using. In the drawing click annotation tab then click on the revision table, then in the drop down for the style and check the active name. Type that in place of “TEST”.

 

Alternatively go into the styles and click copy/rename and extract your default name from there. 

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 6

Anonymous
Not applicable

Thanks so much for your help Adam, I have run the code and it works perfectly!.. Just a quick one.. we have a couple drawings we have to fix. Right now with that code if the revision says 1 does it go to 2 when the code is run, also what happens if the revision column is blank.

0 Likes
Message 6 of 6

A.Acheson
Mentor
Mentor

When you run the code it will change the style to the one you specify. If this is not correct I would do it manually. You don't want to delete or have in the wrong columns the information. 

 

If the style is correct and there is a revision table there the rule counts the last revision and adds a new one if you select that option. This is assuming the numeric indexing was all ready set up when the revision table was added manually. 

 

I suggest test on a sample first but the worst it should do is leave out the revision number as the indexing may not be set. 

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