07-20-2015 04:05 AM
Hello,
Is it possible to add a custom panel item to the existing items (NAVIGATOR, VIEW, ANALYSIS, REPORT, DAC, VISUAL, SCRIPT)?
I now how to add buttons in the panel items and how to add menu items, but I couldn't find if it is possible to extend the DIAdem panel.
With kind regards,
Stijn
07-31-2015 11:16 AM
Hi Stijn,
You can add new large panel icons to the panel icon bar on the left of DIAdem. What you can't do is create a new workspace in the middle of DIAdem. So even if a user clicks on your new custom panel icon, they will still always ne in the workspace of one of the normal DIAdem panels.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
08-02-2015 04:33 PM
08-03-2015 11:13 AM
Hi Stijn,
Here's a good start for you.
Call AddPanelIcon(IconFileName, ScriptFilePath) Sub AddPanelIcon(IconFileName, ScriptFilePath) Dim ButtonIDs, ButtonNames, ButtonIcons, ButtonScripts ButtonIDs = Array("Separator", "GrabFlukeWaveform") ButtonNames = Array("", "Grab Fluke Waveform") ButtonIcons = Array("", IconFileName) ButtonScripts = Array("", ScriptFilePath) Call AddActionObjects(ButtonIDs, ButtonNames, ButtonIcons, ButtonScripts) Call AddButtons(BarManager.Bars("DIAPanels"), ButtonIDs, Array(1, 1)) End Sub ' AddPanelIcon() Function AddActionObjects(ButtonIDs, ButtonNames, ButtonIcons, ButtonScripts) Dim j, iMax, jMax, ActionObjects, ActionObj ActionObjects = Array("") IF IsArray(ButtonIDs) THEN jMax = UBound(ButtonIDs) ReDim ActionObjects(jMax) ReDim Preserve ButtonNames(jMax) ReDim Preserve ButtonIcons(jMax) ReDim Preserve ButtonScripts(jMax) FOR j = 1 TO jMax IF ButtonIDs(j) <> "" THEN IF BarManager.ActionObjs.Exists(ButtonIDs(j)) THEN Set ActionObj = BarManager.ActionObjs(ButtonIDs(j)) Call BarManager.ActionObjs.Remove(ButtonIDs(j)) END IF Set ActionObjects(j) = BarManager.ActionObjs.Add(ButtonIDs(j), "CustomButton") ActionObjects(j).ToolTip = ButtonNames(j) IF Left(ButtonScripts(j), 11) = "BarManager." THEN ActionObjects(j).OnClickCode.Code = ButtonScripts(j) ELSE ActionObjects(j).OnClickCode.Code = "Call ScriptStart(""" & ButtonScripts(j) & """)" END IF ActionObjects(j).Picture = ButtonIcons(j) END IF ' ButtonIDs(j) <> "" NEXT ' j END IF ' IsArray(ButtonIDs) AddActionObjects = ActionObjects End Function ' AddActionObjects() Function AddButtons(Bar, ButtonIDs, ButtonFlags) Dim j, iMax, jMax, Buttons Buttons = Array("") IF IsArray(ButtonIDs) THEN jMax = UBound(ButtonIDs) ReDim Buttons(jMax) ReDim Preserve ButtonFlags(jMax) FOR j = jMax TO 1 Step -1 IF Bar.UsedActionObjs.Exists(ButtonIDs(j)) THEN Call Bar.UsedActionObjs.Remove(ButtonIDs(j)) END IF NEXT ' j iMax = Bar.UsedActionObjs.Count IF NOT Bar.UsedActionObjs(iMax).ID = "Separator" AND ButtonIDs(0) = "Separator" THEN Call Bar.UsedActionObjs.Add("Separator") END IF FOR j = 1 TO jMax IF (ButtonFlags(j)) THEN Call Bar.UsedActionObjs.Add(ButtonIDs(j)) NEXT ' j END IF ' IsArray(ButtonIDs) AddButtons = Buttons End Function ' AddButtons()
Brad Turpin
DIAdem Product Support Engineer
National Instruments
08-13-2015 09:54 AM
Hello Brad,
Thanks for the script! I used parts from your example and I managed it to add an own button in the Panel bar.
I also added buttons behind this panel bar button, but I want to have a Group bar in between. How can I add a group bar? And how do I know/set the name of the new panel bar (Bar ID).
With kind regards,
Stijn
08-17-2015 01:44 PM
HI Stijn,
The important thing to remember when creating a "new" panel in DIAdem is that you really haven't. You've created a new big panel icon, yes, but when the user clicks on it, he/she is still in one of the normal panels, where by default there already is a group icon bar. You can customize that group bar, but the user is probably going to expect you to customize it back to the normal state when they "leave" your custom panel.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
12-13-2017 07:48 AM
Hi, I found this topic very interesting and I got the code to work except for the icon itself, iI get a question mark icon with the error "the file is not available"...what am I doing wrong ?
12-14-2017 03:26 PM
Hi DescInno,
The custom icon you want to display has to exist in a known DIAdem folder to show up correctly. The easiest way to do this is to add your custom icon file to the following DIAdem folder that contains the shipping icon files:
"C:\Program Files (x86)\National Instruments\DIAdem 2017\Resource\BarSource\"
Brad