luni, 13 octombrie 2014

VENTDUCT





about-2

Introduction

I’m back with a new article related to the new .NET framework. Today’s article is more of a tutorial explaining how to install and then configure a PDMS 12 addin made in .NET.
We’ll need an addin to use as example. I made a very simple addin for this purpose. This addin can be used to model trasitions from rectangular sections to circular ones for equipments. We’ll install this addin in PDMS and then configure it to expose its interface to the end user. This will be done with a menu and a commandbar.
To download the addin just scroll to the end of this page, it’s totally free.
about-2

Making the addin visible to PDMS

Each PDMS module is an application by itself, in other words Lexicon is an application, Paragon is another, Design is a third one and so on. When a module is loading, PDMS will load some standard addins from Aveva. The definition of which addin will be loaded is done through some .xml files located inside the PDMS executable folder.
These files are named according the module associated with them, e.g. the file that defines which addins are loaded in Paragon is called ParagonAddins.xml, the one for Draft is called DraftAddins.xml and so on.
Figura 1 - Conteúdo do arquivo DesignAddins.xml
Picture 1 – Contents of DesignAddins.xml file
The file we are looking for is DesignAddins.xml, since the addin I made is supposed to be used with Design. This file has a very simple structure, as can be seen at Picture 1. For our addin to be loaded what we need is only add a new entry with the name of our addin’s .dll file. That done the only thing we shall do would be to put a copy of the .dll (DrawTransition.dll) inside this folder.
However we’ll do the things a little bit different here. I’d say that edit the original PDMS files is not a good practice because you would have to replicate these changes to every PC with PDMS installed and you would have to redo the same changes after each PDMS reinstall or even update.
Because of this we’ll make some changes to allow all addin setup or modification accessible to every user over the network. This can be done creating some environment variables that will point to other folders.
about-2

Modifying the setup to run over the network

First we need to create the folder structure to store the addins and the interface customization files. Create the structure shown on Picture 2 somewhere on the network.
Figura 2 - Pastas para organizar os addins
Picture 2 – Folders to store and configure addins
Here I created the folders on the drive D:, so don’t forget to change it to your directory when needed.
There are many ways of setting up these environment variables. For this tutorial we’ll put them in the PDMS .bat file. Right click on the shortcut you use to open PDMS e choose Edit. Windows will find the right file and open to you.
In the beginning of the file insert these two lines:
The CAF_ADDINS_PATH variable informs PDMS where it should search for the addin to load.
The CAF_UIC_PATH variable informs PDMS where it should search for saved interface customization files.
Now we’re going to copy each module’s addin and interface configuration files. Unfortunately these environment variables aren’t like PMLLIB, where it’s possible to put only the modified files on the new folder and PDMS will search for the others on the installation folder. So we have to copy ALL files called <module’s name>Addins.xml (DesignAddins.xml, ParagonAddins.xml, SchematicsAddins.xml, etc) to the …\pml.net\addins\config folder and ALL files called <module’s name>Customization.xml (DesignCustomization.xml, ParagonCustomization.xml, DraftCustomization.xml, etc) to the …\pml.net\interface\config folder.
Copy the DrawTransition_v????.dll file to the …\pml.net\addins\dll folder.
Open the DesignAddins.xml on the Notepad and add one more line, like shown on the Picture 3, pointing the folder where you put the DrawTransition_v????.dllfile. Note that you have to type exactly the same name as the dll you’re using (there’s one dll for each PDMS version), and do not type the file extension.
Figura 3 - Arquivo DesignAddins.xml editado
Picture 3 – Edited DesignAddins.xml file
Now let’s create a new .uic file to save our menus, buttons and commandbars. Open Notepad and type the following:
Save the file as 3dMacro.uic on the …\pml.net\interface\uic folder.
Se preferir pode baixar o arquivo diretamente clicando aqui.
Watch out if your Windows is set up to hide file extensions. If yes it will add a .txt extension on your file’s name. It won’t appear to you but the .uic file won’t work.
Now we only have to inform PDMS about this new .uic file. Open the …\pml.net\interface\config\DesignCustomization.xml file on the Notepad and change it as show on Picture 4.
Figura 4 - Arquivo DesignCustomization.xml alterado
Figura 4 – Edited DesignCustomization.xml file
Now the addin is installed and will be loaded in Design. Open PDMS and watch the console window for any errors (the DOS window that starts with PDMS). If you see any error or PDMS does not load, redo the previous steps to see if you haven’t missed anything.
What we have to do now is expose the addin interface to the user. In PDMS 12 is possible to create menus and commandbars through the interface. We’ll create a menu and a commandbar that will allow the user to open the addin window.
about-2

Creating the command button

Right click any menu or commandbar and pick Customize.
The window shown in Picture 5 will appear.
Figura 5 - Janela para customização de menus e barras de ferramenta
Picture 5 – Window used to customize menus and commandbars
Let’s make a little break to explain this window.
A) This list allows you to choose which customization file will be edited.
B) In this area we can find the user defined menus and commandbars. By default these items are divided in three categories:
  • per user
  • per project
  • per module
C) This area stores the user defined commands which can be inserted in the commandbars and menus.
D) The selected item’s properties will be shown here. Some may be read only and cannot be edited by the user.
First we’ll create a command which will give the user a direct access to the addin interface.
For this tutorial we’ll save these changes to the .uic file that we just created. If you followed all steps correctly, at the Active Customization File there will be the option3D Macro Tools.
Right click on the middle portion of the window and pick New Button. The new button will the shown on this middle area and its properties on the right panel. Change the Name property to .DrawTransition, the Caption property to Draw Transition v1.0 and the tooltip to Create rectangular to circular transitions. Click on the Command property and three dots will be visible (Picture 6).
Figura 6 - Criando o novo botão
Picture 6 – Creating the new button
Click on the dot button and choose Core on the next window. If the addin was correctly set up, a 3D Macro item will be available. Click on the little plus sign, choose the 3dMacro.Free.DrawTransition.Show option and click OK (Picture 7).
Figura 7 - Selecionando o comando do botão
Picture 7 – Picking the button’s command
To the Icon property select the picture which will show in the button and in the menu.
Now that the button is created, we need to create the menu and the command bar to use it.
about-2

Creating the menu and the command bar

Right click the Menubar item and pick New Menu. A new menu called Menu1 is created right below this item. Click it to show its properties on the right side. Change the Name to 3dMacroMainMenu and the Caption to 3D Macro.
Right click the Command Bars item and pic New CommandBar. A new bar is created right below this item. Click it to show its properties on the right side. Change the Name to 3dMacroMainToolbar and the Caption to 3D Macro Tools.
Now we’ll link the button to the menu and to the command bar. Drag the.DrawTransition button to the 3dMacroMainMenu. Repeat this operation but now drag it to th 3dMacroMainToolbar.
Figura 8 - Associando o botão de comando ao menu e à barra de ferramentas
Picture 8 – Linking the button to the menu and to the command bar
Click OK to go back to PDMS.
If you followed all steps above, it will be possible to see a new command bar and the new 3D Macro menu. The bar will appear anywhere around your already existing bars, so you’ll have to look for it.
Figura 9 - Novo menu e barra de ferramentas
Picture 9 – New menu and command bar
Observe that we created only on button and it was used to the bar as well to the menu. In other words, it’s not necessary to create multiple buttons if they do the same thing.
Now you can access the addin either through the menu or through the command bar.
If you need help to use this new tool, click on Help… inside the addin window.
about-2

Conclusion

In this article we could see the new system to addin access and user interface customization. The creation of new menus is not tied to the use of new addins. You can also run your old PML macros, because as you can see on the window from Picture 7 there’s a Macro option where you can call the macro you want to execute for the new item.
Up to today there was always the need to know PML 1 or 2 to create new menus. On this new version Aveva made this process a lot more user friendly and open to nearly all users, not only administrators. And the best part: can be done in a user basis, without change the company’s customizations.
And don’t forget: you can use the set up made here to install any addin from now on. You only have to copy the .dll addin file into the …\pml.net\addins\dll and change the .xml file of the module you want the addin to be used from.

Downloads

0 comentarii:

Trimiteți un comentariu

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More