ilogic - adding macro buttons to a custom ribbon tab

ilogic - adding macro buttons to a custom ribbon tab

Curtis_Waguespack
Consultant Consultant
2,615 Views
18 Replies
Message 1 of 19

ilogic - adding macro buttons to a custom ribbon tab

Curtis_Waguespack
Consultant
Consultant

 

I have a question for anyone who might have a minute to look at this issue.  I can't tell if there is a bug here or I'm just doing something wrong.

 

I have this simple test rule that either adds built in command buttons to a custom ribbon tab, or it adds macro buttons to this same tab, but it has a problem when adding the macro buttons.

 

this rule looks at the active document type to get the ribbon for the document type, then it deletes an existing tab if present, then it (re)creates that tab, creates a panel on that tap, and then creates buttons on that panel based on a predefined list.

eee.PNG

These are the built in commands that it add to the new ribbon tab 

ccc.PNG

 

The problem is that for macro buttons it only adds the last button in the list to the panel, whereas for the built in commands it adds them all/both

 

bbb.PNG

 

 

 

To test this using the code below you can:

 

  1. create a VBA module called "Test" as shown:

 

aaa.png

 

 

 

   2. Then paste in this code to the new module:

 

Sub Test_01()
    MsgBox ("Test 01")
End Sub

Sub Test_02()
    MsgBox ("Test 02")
End Sub

Sub Test_03()
    MsgBox ("Test 03")
End Sub

Sub Test_04()
    MsgBox ("Test 04")
End Sub

Sub Test_05()
    MsgBox ("Test 05")
End Sub

Sub Test_06()
    MsgBox ("Test 06")
End Sub

 

 

   3. Then create an external ilogic rule and paste this in:

oCommandType = InputRadioBox("Select One", _
"Built in commands", "Macro commands", False, "ilogic")

' Get the ribbon associated with the document
Dim oRibbon As Inventor.Ribbon

Dim oDoc As Document
oDoc = ThisApplication.ActiveEditDocument
If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
    oRibbon = ThisApplication.UserInterfaceManager.Ribbons.Item("Assembly")
    oType = "Assembly"
ElseIf oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
    oRibbon = ThisApplication.UserInterfaceManager.Ribbons.Item("Part")
    oType = "Part"
ElseIf oDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then
    oRibbon = ThisApplication.UserInterfaceManager.Ribbons.Item("Drawing")
    oType = "Drawing"
Else
    oType = "Unknown"
	Exit Sub
End If

oName = "TEST_"

'delete existing tab, in case it exist from previous test
Try
oRibbon.RibbonTabs.Item(oName & oType).Delete
Catch
End Try

Dim oTab As Inventor.RibbonTab
oTab = oRibbon.RibbonTabs.Add(oName & oType, oName & oType, "ClientId123")
oTab.Active = True

Dim oPanel As RibbonPanel
sPanelName = oName & " Tools"

oPanel = oTab.RibbonPanels.Add(sPanelName, sPanelName & "_" & oType, sPanelName & "_" & oType)

Dim oControlDefs As ControlDefinitions
oControlDefs = ThisApplication.CommandManager.ControlDefinitions

Dim oButtonsList As New ArrayList
If oCommandType = False
	
	If oType = "Drawing" Then	
		oButtonsList.Add("Test.Test_01")
		oButtonsList.Add("Test.Test_02")		
	Else If oType = "Assembly" Then
		oButtonsList.Add("Test.Test_03")
		oButtonsList.Add("Test.Test_04")	
	Else If oType = "Part" Then
		oButtonsList.Add("Test.Test_05")
		oButtonsList.Add("Test.Test_06")
	End If
	
	Dim oMacroDef As MacroControlDefinition 
	For Each oItem In oButtonsList
	oMacroDef = oControlDefs.AddMacroControlDefinition(oItem)	
		oPanel.CommandControls.AddMacro(oMacroDef, False)	
	Next

Else
	
	If oType = "Drawing" Then	
		oButtonsList.Add("DrawingBalloonCmd")
		oButtonsList.Add("DrawingBalloonAllCmd")		
	Else If oType = "Assembly" Then
		oButtonsList.Add("AppZoomSelectCmd")
		oButtonsList.Add("AppZoomAllCmd")		
	Else If oType = "Part" Then
		oButtonsList.Add("PartExtrudeCmd")	
		oButtonsList.Add("PartRevolveCmd")		
	End If

	Dim oButtonDef As ButtonDefinition
	For Each oItem In oButtonsList
		oButtonDef = oControlDefs.Item(oItem)		
		oPanel.CommandControls.AddButton(oButtonDef, False)	
	Next

End If

 

4. then open a part file and run this rule to create macro buttons

5. then do the same for an assembly

6. then do the same for a drawing

7. note that the issue seems to occur, on the third document type this is used in, and then persists for any and all documents after that

EESignature

0 Likes
2,616 Views
18 Replies
Replies (18)
Message 2 of 19

Curtis_Waguespack
Consultant
Consultant

Quick update to this, if I close Inventor and then open a part file, and run this to set the macro buttons, it works as expected.... if I think open an assembly file and run this... again it works as expected.... but then if I open a drawing and run this then the problem with it only creating the last button in the list occurs, and then the problems persists with all documents and document types...

 

From my tests it seems that the same will occur if I open a drawing, assembly, and then part... so it seems like the third document type can be any of the three, but the issue only occurs after running this on more than two document types... ?

EESignature

0 Likes
Message 3 of 19

tobias.orlow
Alumni
Alumni

Hi,

 

After a quick test with your provided sample code, I can't seem to reproduce the issue on my end (un-)fortunately. It works as expected no matter which and how many documents I try it in.

Can you let me know the exact version you're on please? Just to rule out it is related to that.

 

Thanks in advance!

Tobi

Tobias Orlow
Designated Support Specialist
Customer Success Organization
Linkedin: www.linkedin.com/in/tobiasorlow/
Message 4 of 19

Curtis_Waguespack
Consultant
Consultant

@tobias.orlow 


Thanks for looking at this! ... oh good point on the version ... I was testing this with Inventor 2020

EESignature

0 Likes
Message 5 of 19

tobias.orlow
Alumni
Alumni

Ah perfect, in 2020 I experience the same behavior! Up to 2019 it seemed to work.

I'll look into it now in detail, what has changed since then and will come back to you with my findings.

 

Thanks!

Tobi

Tobias Orlow
Designated Support Specialist
Customer Success Organization
Linkedin: www.linkedin.com/in/tobiasorlow/
Message 6 of 19

tobias.orlow
Alumni
Alumni

I noticed that it only didn't work properly in the session I set up the rule etc.

After a restart, I can't reproduce it anymore in 2020.1.1

 

However, there is definitely something strange going on while updating the UI internally (e.g. the 'smallIcons' are missing as well). The 'ButtonList' did contain both Subs in every case, even when only one showed in the Panel. They are also defined as controls when checking in the active document within the VBA Editor.

 

I might have to ask someone from development to look into this, can you in the meantime see if it persists when fully updating to 2020.1.1? For completion, please also use Public Subs in the macros as described here: http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-B769BA2B-85D0-4026-A677-FDC660306389

This shouldn't cause the behaviour though.

 

Thank you,

Tobi

Tobias Orlow
Designated Support Specialist
Customer Success Organization
Linkedin: www.linkedin.com/in/tobiasorlow/
Message 7 of 19

Curtis_Waguespack
Consultant
Consultant

Hi @tobias.orlow ,

 

Thanks again for taking the time to look at this. Indeed I did not have the updates installed on this machine, so I've done that and I've made the change to Public Sub as suggested.

 

aaa.png

bbb.PNG

 

With all of that in mind, I can see that it works after I run the rule in each document type, and then restart Inventor, and run it all again.

 

However, this only worked with this simple test set, when I try this with my actual files which has a dozen or so macros, etc... I  get the same thing as before, where it will only load the last one in the list as a button. 

 

I didn't have a lot of time to look too much further, but I'll try to investigate a bit more tomorrow.

 

Thanks again!

EESignature

0 Likes
Message 8 of 19

Curtis_Waguespack
Consultant
Consultant

... and after another restart, it seems the test set is now back to only adding one button again 🙄

EESignature

0 Likes
Message 9 of 19

Curtis_Waguespack
Consultant
Consultant

 @chandra.shekar.g , could you take a look at this and tell us if there is a way to get this to work predictably?  Thank you.

EESignature

Message 10 of 19

Curtis_Waguespack
Consultant
Consultant

@BrianEkins @johnsonshiue 

 

Would either of you be able to have a look at this issue and provide some insight into the issue and how to resolve it?

 

Thank you, Curtis

EESignature

0 Likes
Message 11 of 19

tobias.orlow
Alumni
Alumni

Hi @Curtis_Waguespack ,

Just letting you know that I logged it with Engineering (ref: 33892), I'll give you an update as soon as I know more.

In the meantime I'll continue to test if there might be a workaround for now.

 

Please let me know if you have any new findings as well.

 

Thank you!

Tobias

Tobias Orlow
Designated Support Specialist
Customer Success Organization
Linkedin: www.linkedin.com/in/tobiasorlow/
Message 12 of 19

chandra.shekar.g
Autodesk Support
Autodesk Support

@Curtis_Waguespack,

 

Unfortunately, unable to reproduce the behavior. What kind of error are you getting it. Steps that I followed is recorded in below screencast link. Please mention the steps if I missed any thing.

 

https://autode.sk/2ARPyDJ

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 13 of 19

tobias.orlow
Alumni
Alumni

Hi @chandra.shekar.g ,

you were actually able to reproduce. In each environment there should be two MacroButtons added to the newly created panel. The ButtonList does always contain both items and also when checking in the UI via VBA Editor after running the rule, both MacroButtons are there. I guess it's an issue with updating UI..

 

Please note the ticket I mentioned above which I logged already.

 

Thank you!

Tobi

Tobias Orlow
Designated Support Specialist
Customer Success Organization
Linkedin: www.linkedin.com/in/tobiasorlow/
Message 14 of 19

Curtis_Waguespack
Consultant
Consultant

@tobias.orlow & @chandra.shekar.g 

 

Thank you both for the replies.  We are looking to deploy inventor 2020 in the next couple of weeks and so I was hoping to find a solution to this. Any insight or work around would be a big help, thanks again.

EESignature

Message 15 of 19

tobias.orlow
Alumni
Alumni

Hi @Curtis_Waguespack ,

I figured, resetting the UI and building it new after adding the buttons seems to do the trick.

Only question would be if in your situation it's alright to reset it (is it before users may have made modifications to their panels or after).

Try adding the following at the end of your external rule and let me know if everything shows up properly please.

 

Dim uim As UserInterfaceManager = ThisApplication.UserInterfaceManager
uim.ResetRibbonInterface()

Thanks in advance,

Tobias

Tobias Orlow
Designated Support Specialist
Customer Success Organization
Linkedin: www.linkedin.com/in/tobiasorlow/
0 Likes
Message 16 of 19

Curtis_Waguespack
Consultant
Consultant

@tobias.orlow wrote:

Hi @Curtis_Waguespack ,

I figured, resetting the UI and building it new after adding the buttons seems to do the trick.

Only question would be if in your situation it's alright to reset it (is it before users may have made modifications to their panels or after).

Try adding the following at the end of your external rule and let me know if everything shows up properly please.

 

Dim uim As UserInterfaceManager = ThisApplication.UserInterfaceManager
uim.ResetRibbonInterface()

Thanks in advance,

Tobias


 

Thanks @tobias.orlow .... unfortunately I see the same result even when adding this line to the end of the code, meaning that it still does not add all the buttons

EESignature

0 Likes
Message 17 of 19

chandra.shekar.g
Autodesk Support
Autodesk Support

@Curtis_Waguespack,

 

To prioritize the change request (INVGEN-33982), please provide information for below points where possible.

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact on Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed use cases for the workflows that this change would address.

 

Thanks and regards,

 


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 18 of 19

Curtis_Waguespack
Consultant
Consultant

 

Hi @chandra.shekar.g 

 

Please find the requested information below. Thanks!

 

 

  • Impact on your application and/or your development.
  • Prevents our ability to deploy Inventor 2020 with an Enterprise tab that contains our internally developed tools in a single ribbon per environment. Additionally this seems to be preventing the ability to deploy macro buttons to custom panels on standard tabs, which leaves our ability to deploy these tools to our team "dead in the water"

 

  • The number of users affected.
  • 50+/-

 

  • The potential revenue impact to you.
  • It's not simple to draw that number out since the custom ribbon is an internally used tool set. The impact is on our ROI of development time, since we must justify our time spent in the terms of "development overhead must be greater or equal to the time saved by the Engineering team who uses the tools", so the impact is this has set the development of this into negative   .... but additionally this impacts our engineering project time, training time, etc... therefore it impacts (increases) the amount overhead invested in Engineering project and design work.

 

  • Realistic timescale over which a fix would help you
  • This was intended to be rolled out with the deployment of Inventor 2020,  but we will not be able to do that now. But we would implement it as soon as a fix is available 

 

  • In the case of a request for a new feature or a feature enhancement, please also provide detailed use cases for the workflows that this change would address.
  • I think in this case we are not requesting new features or enchantment, just asking for something to be fixed. But Our ultimate goal is to have a way to create an "Enterprise" tab in the ribbon to organize our internal automation tools as we do in AutoCAD. The current method of adding macros to a custom tab seems to simply have become "broken" in Inventor 2020. 
  • However, in terms of a new feature, It would be ideal to have a built in solution to get iLogic tools to a custom tab as well, currently the workaround is to do create VBA macros to call iLogic rules. I think a great number of companies/Inventor users would benefit from a built in solution to getting their iLogic buttons onto a custom ribbon tab without jumping through the VBA editor hoops
  • Our current set of tools (see image below) has outgrown the iLogic Panel (which has a lot of limitations concerning making good use of space) ....so in order to display it comfortably the actual model/drawing space is sacrificed severely. Therefor the ability to house macros and ilogic tools on one or more custom Ribbon tabs works much better, but again as an enhancement Inventor users would love to see the ability to do this in a much more straight forward manner

 

aaa.png

EESignature

Message 19 of 19

chandra.shekar.g
Autodesk Support
Autodesk Support

@Curtis_Waguespack,

 

Thanks for providing business case,

 

Change request (INVGEN - 33892) is updated with business cases.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network