[BUG] Revision Table Active Row

[BUG] Revision Table Active Row

MechMachineMan
Advisor Advisor
1,877 Views
10 Replies
Message 1 of 11

[BUG] Revision Table Active Row

MechMachineMan
Advisor
Advisor

There is some issue with the functionality of the active row and the only workaround I am aware of isn't ideal.

 

In a revision table, if you use "insert row", it does not make it the active row. The only current way I am aware of to change the active row is to use the "add row" feature, copy the data into that row, and the old row.

 

In order to prevent this workaround of copy/pasting I tried writing a simple iLogic rule to allow the user to switch it via API.

 

Although the API says ".IsActiveRow" is a read-write property, the below code errors out when I try to set it. Thinking it may be because it cannot have 2 active rows, I tried disabling it first, but even that did not work.

 

 

Sub Main()

    'kDrawingRevisionTableFilter    16904    Drawing revision table filter.
    oRevTable = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingRevisionTableFilter, "Select Rev Table")
    
    Dim oRow As RevisionTableRow
    
    For Each oRow In oRevTable.RevisionTableRows
        If oRow.IsActiveRow = True Then
            oActiveRow = oRow(1).Text
        End If
    Next
    
    Dim oNewActiveRow As String
    oNewActiveRow = InputBox("Select New Active Row", "MacroMagic", oActiveRow)
    
    For Each oRow In oRevTable.RevisionTableRows
        If oRow(1).Text = oActiveRow Then
            oRow.IsActiveRow = False
        End If
    Next    
    
    MsgBox("Active row removed!")
    
    For Each oRow In oRevTable.RevisionTableRows
        MsgBox(oRow(1).Text & vbLf & oNewActiveRow)
        If oRow(1).Text = oNewActiveRow Then
            oRow.IsActiveRow = True  
        End If
    Next

MsgBox("Active row set!" & vblf & vblf & "Please open rev table dialog and double check")
End Sub  

 


--------------------------------------
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
Accepted solutions (2)
1,878 Views
10 Replies
Replies (10)
Message 2 of 11

Ruffy85
Collaborator
Collaborator

@MechMachineMan

 

i tried to reproduce trough the normal way, manually in the drawing. i noticed that there is a Button with insertrow and Insertrevisionrow.

 

If you use insertrow, i can follow you, but with insertrevisionrow. the new row is the active one and the revision bumped up.

 

Maybe this helps?

If my reply was helpful, please give a "Kudo" or click the "Accept as Solution" button below (or both).
Message 3 of 11

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @MechMachineMan,

 

iLogic code works fine with little changes. This code is tested for following revision table.

 

RevsionTable.JPG

 

Sub Main()

    'kDrawingRevisionTableFilter    16904    Drawing revision table filter.
    oRevTable = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingRevisionTableFilter, "Select Rev Table")
    
    Dim oRow As RevisionTableRow
    
    For Each oRow In oRevTable.RevisionTableRows
        If oRow.IsActiveRow = True Then
            oActiveRow = oRow(2).Text
        End If
    Next
    
    Dim oNewActiveRow As String
    oNewActiveRow = InputBox("Select New Active Row", "MacroMagic", oActiveRow)
   

    For Each oRow In oRevTable.RevisionTableRows
        If oRow(1).Text = oActiveRow Then
            oRow.IsActiveRow = False
        End If
    Next    
    
    MsgBox("Active row removed!")
    
    For Each oRow In oRevTable.RevisionTableRows
        MsgBox(oRow(1).Text & vbLf & oNewActiveRow)
        If oRow(1).Text = oNewActiveRow Then
            oRow.IsActiveRow = True  
        End If
    Next

    MsgBox("Active row set!" & vbLf & vbLf & "Please open rev table dialog and double check")    

End Sub

Can you please sample revision table to test iLogic code?

 

Thanks and regards,

 


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 4 of 11

MechMachineMan
Advisor
Advisor

Hmm. Interesting.

 

I have it consistently working for the default revision block now.

 

Whenever I set oRevNumberColumn to 2 ( for my table) and try running it on my custom style table, it fails.

 

Sub Main()
	
	Dim oRevNumberColumn As Integer
	oRevNumberColumn = 2

	Dim oRevTable As RevisionTable
        oRevTable = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingRevisionTableFilter, "Select Rev Table")
	
	Dim oRow As RevisionTableRow
	Dim oActiveRow As String
	
	For Each oRow In oRevTable.RevisionTableRows
		If oRow.IsActiveRow = True Then
			oActiveRow = oRow(oRevNumberColumn).Text
		End If
	Next
	
	Dim oNewActiveRow As String
	oNewActiveRow = InputBox("Select New Active Row", "MacroMagic", oActiveRow)
	If oNewActiveRow = "" Then: Exit Sub: End If

	For Each oRow In oRevTable.RevisionTableRows
		If oRow(oRevNumberColumn).Text = oNewActiveRow Then
			oRow.IsActiveRow = True
		End If
	Next

End Sub

Error Trace:

 

System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
   at Inventor.RevisionTableRow.set_IsActiveRow(Boolean )
   at LmiRuleScript.Main()
   at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
   at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

--------------------------------------
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 5 of 11

dgreatice
Collaborator
Collaborator

Hi.

 

I think class "IsActiveRow" just for Revision Row. Not For Custom Row.

 

I check this with.

 

Sub Main()

Dim oRevNumberColumn As Integer
oRevNumberColumn = 2

Dim oRevTable As RevisionTable
        oRevTable = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingRevisionTableFilter, "Select Rev Table")

Dim oRow As RevisionTableRow
Dim oActiveRow As String

For Each oRow In oRevTable.RevisionTableRows
If oRow.IsActiveRow = True Then
oActiveRow = oRow(oRevNumberColumn).Text
End If
Next

Dim oNewActiveRow As String
oNewActiveRow = InputBox("Select New Active Row", "MacroMagic", oActiveRow)
If oNewActiveRow = "" Then: Exit Sub: End If

For Each oRow In oRevTable.RevisionTableRows
If oRow(oRevNumberColumn).Text = oNewActiveRow Then

If oRow.Custom = True then

oRow.IsActiveRow = True

else

msgbox "This Row are Custom Row"

end if
End If
Next

End Sub

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 6 of 11

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @MechMachineMan,

 

Can you please provide Revision table details?

 

Screenshot also fine.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 7 of 11

MechMachineMan
Advisor
Advisor

It's just a custom rev table style that is organized:

 

Rev     |        Date     |      By      |    Description

 

Thanks,


--------------------------------------
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 8 of 11

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @MechMachineMan,

 

You are right!!!

 

Unable to set the value for RevisionTableRow.IsActiveRow property. I am checking the same with Engineering team. After hearing from team, I will get back to you.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 9 of 11

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

Hi @MechMachineMan,

 

I heard back from Engineering team, Setting RevisionTableRow.IsActiveRow property from False to True is possible which makes Inactive to Active row. But, setting RevisionTableRow.IsActiveRow property from True to False will raise error. Because one of the row must be active.

 

So, the following iLogic code throws error message if that row is active.

 

For Each oRow In oRevTable.RevisionTableRows
        If oRow(1).Text = oActiveRow Then
            oRow.IsActiveRow = False
        End If
Next 

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 10 of 11

dgreatice
Collaborator
Collaborator
Accepted solution

Hi @chandra.shekar.g

 

I think you miss understood. @MechMachineMan want try to activated Custom Row (Create from Insert Row at Revision Table)

 

To Activate Revision Row (Created From "Add Revision Row") is no problem.

 

like I said "I think class "IsActiveRow" just for Revision Row. Not For Custom Row".

Why must use Custom Row that created with "Insert Row" at Revision Table?

For most people, they use "Add Revision Row" because automatically will update Revision Number at Properties.

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 11 of 11

MechMachineMan
Advisor
Advisor

Thanks @dgreatice & @chandra.shekar.g.

 

That makes sense about the custom row. I think it's what I was missing before as it would work in some cases, but not others. Seems interesting how it makes there is the custom row set up there that is so easily confused with the "Add Row" of the UI. It seems like most users would think 'What's the difference?' or click the first button they see.

 

Anyhow, the code below works for all intents and purposes, within this limitation.

 

Sub Main()
	
	Dim oRevNumberColumn As Integer
	oRevNumberColumn = 1

	Dim oRevTable As RevisionTable
        oRevTable = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingRevisionTableFilter, "Select Rev Table")
	
	Dim oRow As RevisionTableRow
	Dim oActiveRow As String

	'Custom Row Check
	For m = 1 To oRevTable.RevisionTableRows.Count
		If oRevTable.RevisionTableRows.Item(m).Custom = True Then
			oCustomString = oCustomString & vbLf & m
		End If
	Next
	
	If Not oCustomString Is Nothing
		MsgBox("Custom Rows (cannot be activated): " & vbLf & oCustomString)
		Exit Sub
	End If
	
	'Find Active Row
	For Each oRow In oRevTable.RevisionTableRows
		If oRow.IsActiveRow = True Then
			oActiveRow = oRow(oRevNumberColumn).Text
		End If
	Next
	
	'Set New ActiveRow
	Dim oNewActiveRow As String
	oNewActiveRow = InputBox("Select New Active Row", "MacroMagic", oActiveRow)
	If oNewActiveRow = "" Then: Exit Sub: End If

	For Each oRow In oRevTable.RevisionTableRows
		If oRow(oRevNumberColumn).Text = oNewActiveRow Then
			oRow.IsActiveRow = True
		End If
	Next

End Sub

--------------------------------------
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