top of page

Post#16 – Filing Your Plugins The Easy Way

Jul 27
3 min read

Arranging and renaming your ABAQUS plugins without editing the code.



Accessing your plugins collection is made easy using the plugins menu. When you have lots of plugins then it becomes a chore to arrange your menus to suit yourself so that they appear in a logical way that makes them easy to find, with a clear name indicating what they do and when to use them. I have found the following tips have made my user experience more efficient.




Limit Visibility


When you write your plugin choose which modules it can be used with, rather than the default and lazy ALL, see line 40 in Figure 1. Limiting a plugin to appear only when, say the user is working in the meshing module, keeps the plugin menu less cluttered since only the currently applicable scripts are available. To limit when your plugin appears change the argument of applicableModules, Figure 1, to a tuple of strings, selecting one or more from: Part, Property, Assembly, Step, Interaction, Load, Mesh, Job, Visualization, and Sketch, see Snippet 1:



Renaming & Reordering


What if you want to group your plugins, to suit you, your workflows, and how you think of them, rather than with the locations and names given to them by their authors? If you only have the compiled plugin you are out of luck, you are stuck with the location and name that the writer assigned to it. If you have the source code then you can change both the name and the location by editing the plugin registration code.


Grouping plugins in sub menus of related tasks makes them easier to find and use. What if you change your mind about groupings? What if my colleague has a different way of looking at their work flows? I might think calling my latest plugin GuysMarvellousPlugin and sticking it in a folder called ProductivityPlugins is a good idea. They might prefer something more informative like Meshing Plugins->DangerDeletesAllMesh. To each their own.


If they have the source code for the plugin then they can go in and rename and relocate the plugin in the menu by changing the lines shown here. However, this is tedious when several plugins are being reorganised, as each has to be renamed and allocated a location, by changing the buttonText argument of the plugin registration.


I find it easier to file my plugins in separate folders within my user space’s abaqus_plugins folder and give the folders the name and location as they will appear in my plugins menu. If I wish to change where and how they appear in the menu then moving, and possibly renaming, the folder is all I have to do, using Windows Explorer.


To achieve this, all my plugins have this very simple function added at the bottom, before the registration code in the xxx_plugin.py file as shown in Figure 1. The GetMenuEntry function names the plugin, as the user sees it in the menu, based on the name of the folder that contains the plugin and attaches it to a submenu named for the folder that holds that plugin’s folder, see Figure 2. Multiple layers of submenus can be used.


Note the highlighted sections. Yellow should contain the real name of your plugin’s form class, that is usually defined at the top of this same file and derived from AFXForm. Purple should contain the real name of any kernel modules that you are importing. In both cases the <> should not be present.


Note also that the sample code in Figure 1 is only a snippet containing the registration code for a plugin and my additions to it.


I hope that some of you find this helpful, until next time.



Figure 1 Bottom section of the xxx_plugin.py file where the plugin is registered with the ABAQUS messaging system.
Figure 1 Bottom section of the xxx_plugin.py file where the plugin is registered with the ABAQUS messaging system.

Figure 2 How the folder structure in your user space maps across to the plugins menu
Figure 2 How the folder structure in your user space maps across to the plugins menu

Comments


bottom of page