Revision Table iLogic

Revision Table iLogic

Eddimeister
Enthusiast Enthusiast
2,483 Views
3 Replies
Message 1 of 4

Revision Table iLogic

Eddimeister
Enthusiast
Enthusiast

Hey Guys...

 

I recently came across a laborious task at work the other day... Our project was behind but was ask to quickly Up Rev all Dwgs for Construction... After 143 Add Revsions and enering data... I was, as you could imagine, "Over it.!" There must be an easier way...

VBA and iLogic have been of interest to me for a while... However I've only just started out and need some guidance...

 

Our Revisions are catergorized as three Revision Classes

P = Preliminary - Primarily For Internal Review

A = Client Approval - After Design stage completed Dwg's are sumitted to Client for Approval after the witness the deisgn...

C = Construction - Once the client has signed off on the Design we update to a Construction Level for Manufacture and Installations

 

Each class has its own internal numeric revision number as the design progresses...

 

P1 = 1st Dwg of Preliminary Level Design Intent

P2 = 2nd Dwg of Preliminary Level Design Intent  - And so on P3, P4... etc

 

When instructed by the Senior Engineers our Dwgs

A1 = 1st Dwg of Preliminary Level Design Intent

A2 = 2nd Dwg of Preliminary Level Design Intent  - And so on A3, A4... etc

 

Client Sign off and Up Rev the Dwgs for Construction Purposes - At times there is the need to revise the Design due to Manufacture Limitations

C1 = 1st Dwg of Preliminary Level Design Intent

C2 = 2nd Dwg of Preliminary Level Design Intent  - And so on A3, A4... etc

 

I'd like to generate some iLogic code to reduce the overhead on this task if possible... Something like this...

 

Run Rule -

 

Msgbox appears - Asks for a Revision Class

Another Msgbox appears - Asks for Additional Revion Notes pertaining to the changes

If then Statement dependant on either P, A or C is enter...

Code Cycles through current Rev Table and extrpolates the Current Revision of the Sheet

Depending on the input given by the user initially  - P, A or C it adds a New Row and either

a. increases the numeric Value or

b. Restarts at 1 again if A or C is inputted for a new Class

Adds a New Row to the Rev Table and Populates the Cells accordingly including any Additional Revion Notes entered

 

File Save

File output to PDF with Input for Directory location

 

Im still learning and kinda guessing my way through this... Any help would be great..!

 

Eddy

 

 

0 Likes
2,484 Views
3 Replies
Replies (3)
Message 2 of 4

MechMachineMan
Advisor
Advisor

Notes:

1. Use VBA/VB.net if possible; avoid iLogic at all costs. - It becomes "unstable/unpredictable" if you try using it in external rules with triggers.

       -External rules, macros (for buttons) or an external application are the best way to accomplish this.

2. Search up the programming help that came installed with your inventor and use google, with tags "msdn + vb.net +".

         "C:\Program Files\Autodesk\Inventor 2016\Local Help\admapi_20_0.chm"

3. Here is a sample to update/add a revision row for all sheets in a document.

4. Add the Line Msgbox("Here!") to your code to manually debug while you learn. Can help you find where error originates. Also, the error stacks that appear ARE in plain english, contrary to what many seem to believe; just read from the bottom up and it will narrow down the scope of the error. Again, google and forums are your friend.

 

'Revision Row Adder
'JRK Fall 2015

'Prompts for revision and applies that description to all sheets with Current user and current date
Sub Main()

If ThisApplication.ActiveDocumentType <> kDrawingDocumentObject
	MsgBox("For use in .idw only")
	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
Dim oInput As String

'oDoc.PropertySets.Item("Inventor Summary Information").Item("Author").Value ="ELC"

oInput = UCase(InputBox("What did you change?", "REV", "ISSUED FOR CONSTRUCTION"))
If oInput = ""
	Exit Sub
End If

For Each oSheet In oDoc.Sheets
	oSheet.Activate

	If oDoc.ActiveSheet.RevisionTables.Count = 0
		Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
		Dim pt As Point2d = oTG.CreatePoint2d(40.8322300046828, 2.14949322301587)
		oSheet.RevisionTables.Add2(pt,False, True, False, "0",,)
	Else
		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 equal to the user name on the open application 
			If oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count - 1).Item(1).Text = "A"
				oCell1.Text = "0"
			Else
				Try
					oCell1.Text = oRevTable.RevisionTableRows.Item(oRevTable.RevisionTableRows.Count - 1).Item(1).Text + 1
				Catch
				End Try
			End If
	
			Dim oCell2 As RevisionTableCell = oRow.Item(2)
	'                    'Set it equal to the user name on the open application        
				oCell2.Text=oUser
			
			Dim oCell3 As RevisionTableCell = oRow.Item(3)
				'Set it equal to the the current date        
				oCell3.Text= DateTime.Now.ToString("d")
				
			Dim oCell4 As RevisionTableCell = oRow.Item(4)
				'Set it equal to the the current date        
				'oCell4.Text= "UPDATED TO BOLTER LIB DWG"
		oCell4.Text= oInput
		End If
	End If 'Rev table count = 0
'End If 'Sheet Name is PO
Next

End Sub

 

 Bonus code: Used for making a macro to run external rules, so that you can make buttons for external rules; is just a work-around.

 

Public Sub iLogicCollapseBrowser()

  RunExternaliLogicRule "CollapseBrowser" 'Replace this name with name of external rule

End Sub

Sub RunExternaliLogicRule(ByVal ruleName As String)

Dim iLogicAuto As Object
Set iLogicAuto = GetiLogicAddin(ThisApplication)
If (iLogicAuto Is Nothing) Then Exit Sub

Dim doc As Document
Set doc = ThisApplication.ActiveDocument

Dim i As Integer
i = iLogicAuto.RunExternalRule(doc, ruleName)

End Sub

Function GetiLogicAddin(oApplication As Inventor.Application) As Object
Set addIns = oApplication.ApplicationAddIns

Dim addIn As ApplicationAddIn
On Error GoTo NotFound
Set addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")

If (addIn Is Nothing) Then Exit Function

addIn.Activate
Set GetiLogicAddin = addIn.Automation
Exit Function
NotFound:
End Function

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 4

Eddimeister
Enthusiast
Enthusiast

Hey Justin...

 

Thanks for the huge leg up on this one...

Quick question in this tho... The code doesnt give an option to choose a Revision Level ie P, A, or C...

Esentially it adds a row and then populates the cells the Description, Drawn By and Date Cells correctly but doesnt seem to give an option to changing the Issue or Counter for the Issue column...

 

I might give it a go playing around with it and see where it leads tho... But again thanks for your input end efforts..!

 

Eddy

0 Likes
Message 4 of 4

MechMachineMan
Advisor
Advisor
Yes, that is where you need to get the information or use logic.

ie; Use an inputbox/listbox/radio buttons.

OR

Create logic to select revision based upon previous.

Also, to change the revision, you simply need to change the corresponding cell in the revision table. (ie; the first cell in the row)

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes