What's new

Adventures in V24 Add-on Development

bolsover

Senior Member
@DavidJ
Many thanks for the feedback and the stack trace - great help when it comes to debugging.
The references to D:\ all come from the debugging code and help me to track down the exact file and line number where the problem occurs.

I was not able to reproduce your exact issue with 'Unknown or unsupported file format' but I suspect it happens when there is an attempt to open a corrupt file or one with an invalid extension.
I tried renaming perfectly good .pdf with the extension .AD_PRT and got a similar problem when I pointed the Data Browser at the directory containing this file (see image below).

I have now changed the code in an effort to mitigate the problem and warn the user if an invalid file is encountered.

I'm still working on an update to the utilities to include generation of internal gears. So this will be updated at the same time - soon I hope.

David
Screenshot 2022-10-28 162704.png
 

DavidJ

Administrator
Staff member
OK Thanks - the identification of a 'rogue' file could be helpful - presumably there's something in my folder that it doesn't like.
 

DavidJ

Administrator
Staff member
David,

version 1.3.0.0 seems to have fixed the issue I was having opening my folder containing mainly Alibre file. Thanks.

Minor issue with text alignment on left hand side of Gear Generator Dialogue. Right hand side look fine, so I doubt this is a Windows scaling issue ?

GearGenAlignment.jpg
 
Last edited:

bolsover

Senior Member
David
Thanks for the feedback. You'll probably guess my motivation for the data browser was simply to have a utility that could view and optionally edit the Alibre design properties, particularly the Part No.
Not sure why but for some reason, the Version Comment property is not exposed by the Alibre API - would be nice to have access to that also.
David
 

tachera

New Member
David, thanks for all the great work. I have used your example Utiities solution to start building out a Global Params utility. Question if I may. Looks like Addons do not work for drawings. Is this correct or maybe I am missing something. :) Many thanks for any feedback
 

NateLiqGrav

Alibre Super User
David, thanks for all the great work. I have used your example Utiities solution to start building out a Global Params utility. Question if I may. Looks like Addons do not work for drawings. Is this correct or maybe I am missing something. :) Many thanks for any feedback
Go here and click on "Quickstart Download". In that file you will find a description of what to change in the ADC file for your add-on including:
<Workspace>
Type of the workspace for the Add-On. The available choices are:
“Part”, “Drawing”, “SheetMetal”, “Repository”, “Always” (for any workspace).
However there is not a lot you can do with the current API in the drawing environment.
 

bolsover

Senior Member
David, thanks for all the great work. I have used your example Utiities solution to start building out a Global Params utility. Question if I may. Looks like Addons do not work for drawings. Is this correct or maybe I am missing something. :) Many thanks for any feedback

I'm pleased you found it useful. As @NateLiqGrav suggests, there is limited support for Drawings in the current API and TBH, I've not made any effort to find out what can be done with drawings.
If you are planning to write your own add-on, it is possible to enable/disable individual menu items in your code rather than in the .adc. I use the code option because it gives more control than the .adc

The following is code from my UtilitiesForAlibre.cs file:


C#:
       /// <summary>
        /// Returns property bits providing information about the state of a menu item
        /// ADDON_MENU_ENABLED = 1,
        /// ADDON_MENU_GRAYED = 2,
        /// ADDON_MENU_CHECKED = 3,
        /// ADDON_MENU_UNCHECKED = 4,
        /// </summary>
        /// <param name="menuID"></param>
        /// <param name="sessionIdentifier"></param>
        /// <returns></returns>
        public ADDONMenuStates MenuItemState(int menuID, string sessionIdentifier)
        {
            var session = alibreRoot.Sessions.Item(sessionIdentifier);

            switch (session)
            {
                case IADDrawingSession:
                    switch (menuID)
                    {
                        case MENU_ID_ROOT: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case MENU_ID_FILE: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case MENU_ID_UTILS: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_DATA_BROWSER: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_FILE_OPEN: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_FILE_CLOSE: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_FILE_EXIT: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_UTILS_CYCLOIDAL_GEAR: return ADDONMenuStates.ADDON_MENU_GRAYED;
                        case SUBMENU_ID_UTILS_GEARS: return ADDONMenuStates.ADDON_MENU_GRAYED;
                        case SUBMENU_ID_UTILS_PLANE_FINDER: return ADDONMenuStates.ADDON_MENU_GRAYED;
                        case SUBMENU_ID_UTILS_DATA_VIEWER: return ADDONMenuStates.ADDON_MENU_GRAYED;
                        case SUBMENU_ID_UTILS_3DLINE: return ADDONMenuStates.ADDON_MENU_GRAYED;
                        case SUBMENU_ID_UTILS_SAMPLE: return ADDONMenuStates.ADDON_MENU_GRAYED;
                        case SUBMENU_ID_HELP_ABOUT: return ADDONMenuStates.ADDON_MENU_GRAYED;
                    }

                    break;

                case IADAssemblySession:
                    switch (menuID)
                    {
                        case MENU_ID_ROOT: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case MENU_ID_FILE: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case MENU_ID_UTILS: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_DATA_BROWSER: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_FILE_OPEN: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_FILE_CLOSE: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_FILE_EXIT: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_UTILS_CYCLOIDAL_GEAR: return ADDONMenuStates.ADDON_MENU_GRAYED;
                        case SUBMENU_ID_UTILS_PLANE_FINDER: return ADDONMenuStates.ADDON_MENU_GRAYED;
                        case SUBMENU_ID_UTILS_GEARS: return ADDONMenuStates.ADDON_MENU_GRAYED;
                        case SUBMENU_ID_UTILS_DATA_VIEWER: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_UTILS_3DLINE: return ADDONMenuStates.ADDON_MENU_GRAYED;
                        case SUBMENU_ID_UTILS_SAMPLE: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_HELP_ABOUT: return ADDONMenuStates.ADDON_MENU_ENABLED;
                    }

                    break;
                case IADPartSession:
                    switch (menuID)
                    {
                        case MENU_ID_ROOT: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case MENU_ID_FILE: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case MENU_ID_UTILS: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_DATA_BROWSER: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_FILE_OPEN: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_FILE_CLOSE: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_FILE_EXIT: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_UTILS_CYCLOIDAL_GEAR: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_UTILS_GEARS: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_UTILS_PLANE_FINDER: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_UTILS_DATA_VIEWER: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_UTILS_3DLINE: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_UTILS_SAMPLE: return ADDONMenuStates.ADDON_MENU_ENABLED;
                        case SUBMENU_ID_HELP_ABOUT: return ADDONMenuStates.ADDON_MENU_ENABLED;
                    }

                    break;
            }

            return ADDONMenuStates.ADDON_MENU_ENABLED;
        }
 
Top