Hello List, Thanks to Ryan Dalton who provided code to create separator's in extensions. Works Perfect! ---------------------- Forwarded by Paul Bartschi/AKSO/AK/BLM/DOI on 11/08/2000 02:30 PM --------------------------- Ryan Dalton 11/07/2000 07:02 AM To: Paul_Bartschi@AK.BLM.GOV cc: Subject: Re: [ARCVIEW-L] How to create separators in AV extensions (Document link: Paul Bartschi (Archive)) Paul- The default ESRI extension making scripts do not contain code to include the menu spacers. Attached is the Make, Install, and Uninstall scripts that I have put together (based on other peoples posts, scripts, etc) to include just about everything, including...most importantly to you... menu spacers. Ryan 'Make Script for Extensions ' ScriptName: Extension Builder - Source Code ' ' Title ' ' Topics: ' ' Description: ' ' Requires: ' ' Self: ' ' Returns: '------------------------------------------------------ '------------------------------------------------------ '------------------------------ '------------------------------ '------------------------------ 'The latest update: theDate = Date.Now theDate.SetFormat("M/dd/yy") 'the Filename of the extension theExtensionPath = "$USEREXT/" '<---The slash must be left at the end theExtensionFileName = "sample.avx" theExtensionFile = theExtensionPath + theExtensionFileName '------------------------------ 'The version of the extension theVersion = 1.0 '------------------------------ 'The Name of the extension to be displayed in the extension dialog theExtensionName = "Sample Extension"++theVersion.asstring '------------------------------ 'The description of the extension to be displayed in the extension dialog theDescription = "This is a sample extension that will..."+nl+ "Last updated:"++theDate.asstring '================================================ ' Start Adding items to be included in extension '================================================ '------------------------------ 'Install Script ' The Script to use to install the extension 'NOTE: "My Extension Install" is a pre-perpared script for this InScriptName="Ext_Install" '------------------------------ 'Uninstall Script ' The Script to use to uninstall the extension 'NOTE: "My Extension Uninstall" is a pre-perpared script for this UnScriptName="Ext_Uninstall" '------------------------------ 'Any document Names to include ' This is a list of any documents to include ' e.g. theDocs={"View1","Layout1"} theDocs={} '------------------------------ 'Controls (Buttons and normal Tools) to include 'Controls {GUI name,ControlType,ScriptName} 'e.g. TheControlList={{"View","ButtonBar","View.ZoomIn"}, {"View","ToolBar","View.Identify"}} TheControllist={} '------------------------------ 'Tool menus to include ' This is a list of which tool menus to include. Tool menus are specified ' by giving a GUI name and a script name of one of the tools in the tool menu ' Using this to locate the tool menu ALL other tools inb that menu and ' their scripts will be extracted ' theToolMenu={{"View","View.PointTool"}} TheToolMenuList={} '------------------------------ 'The Menus to include (a list of menu items listing the doc, the top menu, and the script for the menu item) 'The MenuList {Doc name, Main Menu name , menu item Scriptname} ' e.g. The MenuList={{"View", "File", "View.Export"}} ' To add a seperator add this line: {"","","Space"}, TheMenuList={} '------------------------------ 'The scripts to include, not in controls or menus 'e.g. theScripts={"My.Script","View.export"} theScripts={} '------------------------------ 'The dialogs to include 'e.g. theDialogs={"Dialog Name"} theDialogs={} '------------------------------ 'The Dependencies 'This line will embed "hidden" dialogs into the extension if you need it 'theDependencies={"$AVBIN/avdlog.dll".asfilename} theDependencies={} '------------------------------ ' ATTENTION!!!!!!!!!!!!!!! ' Do NOT alter the script after these lines, the remainer of this script ' uses the lists you provided above to build the extension object. '_______________________________________________________________ '_______________________________________________________________ '_______________________________________________________________ '_______________________________________________________________ '_______________________________________________________________ '_______________________________________________________________ '_______________________________________________________________ '_______________________________________________________________ '_______________________________________________________________ 'Create a total list of the needed scripts TheNeeded={} for each ControlScript in thecontrolList TheNeeded.add(ConTrolScript.get(2)) end For each MenuScript in theMenuList theNeeded.add(MenuScript.get(2)) end totalscripts=thescripts.merge(theNeeded) TotalScripts.removeduplicates theInstall=av.GetProject.FindScript(InscriptName) if (theInstall=NIL) then Msgbox.Error("The install Script "+InScriptName+" was not found","Script not found") return(nil) end theUninstall=av.GetProject.FindScript(unscriptName) if (theUninstall=NIL) then Msgbox.Error("The install Script "+UnScriptName+" was not found","Script not found") return(nil) end 'Create the extension ' Extension.Make(ExtensionFile, theExtensionName, InstallScript, UninstallScript, Dependancies_ myExt = Extension.Make(theExtensionFile.asFilename, theExtensionName, theInstall, theUninstall, theDependencies) TheDocList={} TheDialogList={} TheTotalControls={} ThetotalMenus={} theTotalToolMenus={} ' Process the Document List '__________________________________________ for each aDoc in TheDocs if ((av.getproject.findDoc(aDoc)="Null").NOT) then TheDocList.Add(av.GetProject.FindDoc(aDoc)) else MsgBox.Warning("The Doc "+adoc.asstring+" cannot be found in the current project.","Script Error") return(nil) end end 'Add the List of Documents MyExt.add(TheDocList) ' Process the Dialog List '__________________________________________ for each aDialog in TheDialogs if ((av.getproject.findDialog(aDialog)="Null").NOT) then TheDialogList.Add(av.GetProject.FindDialog(aDialog)) else MsgBox.Warning("The Dialog "+aDialog.asstring+" cannot be found in the current project.","Script Error") return(nil) end end 'Add the List of Documents MyExt.add(TheDialogList) ' Process the control List '__________________________________________ 'Controls {GUI,ControlType,Scriptname} '__________________________________________ '__________________________________________ '__________________________________________ for each aControl in TheControlList theControlDoc=av.getproject.findGUI(aControl.get(0)) if (theControlDoc=NIL) then MsgBox.Warning("The GUI "+aControl.get(0)+" cannot be found in the current project.","Script Error") return(nil) end thecommand="av.getproject.findGUI("""+aControl.get(0)+""").Get" +acontrol.get(1) 'msgbox.info(thecommand,"") thescript1=Script.Make(thecommand) thecontrolset=thescript1.doit("") theFoundControl=TheControlSet.FindbyScript(aControl.get(2)) if (theFoundControl=NIL) then MsgBox.Warning("No Control found with the script "+aControl.get(2)+" in "+acontrol.get(1),"Warning") return(nil) end if (theFoundControl.is(ToolMenu)) then MsgBox.Warning("The script "+aControl.get(2)+" in "+acontrol.get(1)+" is for a tool menu.","Not Supported") return(nil) end TheTotalControls.Add ({aControl,thefoundControl,theControlSet.getcontrols.find(thefoundcontrol)}) end 'Add to Ext MyExt.add(TheTotalControls) '__________________________________________ 'The MenuList {Doc, Menu, MenuScript} '__________________________________________ '__________________________________________ '__________________________________________ themenuitemidx = 1 '*******Add this to allow for seperators - sets the menuitemidx For each aMenu in themenulist mDoc=aMenu.get(0) mMenu=aMenu.get(1) mScript=aMenu.get(2) themDoc=av.getproject.findGUI(mDoc) if (themDoc=NIL) then MsgBox.Warning("The GUI "+mDoc+" cannot be found in the current project.","Script Error") return(nil) end theMbar=av.getproject.findGUI(mDoc).GetMenuBar themenu=theMbar.findbylabel(mMenu) if (themenu=NiL) then MsgBox.Warning("The menu named "+mMenu+" is not here.","Script Error") return(nil) end themenucontrol=themenu.findbyScript(mScript) ' ***** To allow seperators in menus, the next 5 lines are replaced below ' if (themenucontrol=NiL) then ' MsgBox.Warning("The script "+mScript+" not found.","Warning") ' return(nil) ' end ' themenuitemidx=themenu.getcontrols.find(themenucontrol) ' ***** The following 11 lines (if..then statement) allow for seperators in the menu if (themenucontrol=Nil) then if(mScript.AsString = "Space") then '***Add this - checks the string entered in place of script themenucontrol = Space.Make '***Add this - makes the separator themenuitemidx = themenuitemidx + 1 '***Add this - increments else '***Add this MsgBox.Warning("The script "+mScript+" not found.","Warning") return(nil) end '*** Add this else themenuitemidx=themenu.getcontrols.find(themenucontrol) end '***** End of script addition to add seperators in the menu thetotalmenus.add({amenu,theMenuControl,theMenuItemIdx}) end myext.add(thetotalmenus) '__________________________________________ 'Process the Tool Menu List '__________________________________________ '__________________________________________ '__________________________________________ for each aControl in TheToolMenuList theControlDoc=av.getproject.findGUI(aControl.get(0)) if (theControlDoc=NIL) then MsgBox.Warning("The GUI "+aControl.get(0)+" cannot be found in the current project.","Script Error") return(nil) end thecontrolset=theControlDoc.getToolbar theFoundControl=TheControlSet.FindbyScript(aControl.get(1)) if (theFoundControl=NIL) then MsgBox.Warning("No Control found with the script "+aControl.get(1)+" in "+acontrol.get(1),"Warning") return(nil) end if (theFoundControl.is(ToolMenu).not) then MsgBox.Warning("The script "+aControl.get(1)+" is NOT for a tool menu.","User Error") return(nil) end TheTotalToolMenus.Add ({aControl,thefoundControl,theControlSet.getcontrols.find(thefoundcontrol)}) end myext.add(thetotalToolmenus) '__________________________________________ ' Process the Script list '__________________________________________ '__________________________________________ '__________________________________________ for each ascript in TotalScripts if ((av.getproject.findscript(ascript)="Null").NOT) then myExt.Add(av.GetProject.FindScript(ascript)) else MsgBox.Warning("The script "+ascript+" cannot be found in the current project.","Script Eror") return(nil) end end myExt.SetAbout(theDescription) myExt.SetExtVersion(theVersion) myExt.Commit msgbox.info("You extension was written to" ++theextensionfile.asstring,"Extension Builder Complete!") **************************************************************************************************************************************************************** Following is the install script: 'DO NOT EDIT!!! if (av.getproject=nil) then return(nil) end theDocs = SELF.get(0) theDialogs = SELF.get(1) theControlList = SELF.get(2) theMenuList = SELF.get(3) theToolMenuList=SELF.Get(4) theProject=Av.getproject 'Add the Docs ' for each adoc in theDocs theProject.addDoc(adoc) end 'Add the Dialogs ' for each adialog in theDialogs theProject.addDialog(adialog) end 'Add the Controls ' for each totalControl in theControlList 'The Control list acontrol=totalControl.get(0) 'The physical control theControl = totalControl.get(1) 'The control Index theCindex=totalControl.get(2) 'Find the DocGUI theControlDoc=av.getproject.findGUI(aControl.get(0)) if (theControlDoc=NIL) then MsgBox.Warning("The GUI "+aControl.get(0)+" cannot be found in the current project.","Script Eror") return(nil) end 'This finds the control set thecommand="av.getproject.findGUI("""+aControl.get(0)+""").Get" +acontrol.get(1) thescript1=Script.Make(thecommand) thecontrolset=thescript1.doit("") 'Add the control to the control set theControlSet.Add(theControl,theCindex) end 'Add the menus for each totalcontrol in theMenuList 'The Control list acontrol=totalControl.get(0) mDoc=acontrol.get(0) mMenu=acontrol.get(1) mMenuItem=acontrol.get(2) 'The physical control theControl = totalControl.get(1) 'The control Index theCindex=totalControl.get(2) 'Find the DocGUI theControlDoc=av.getproject.findGUI(aControl.get(0)) if (theControlDoc=NIL) then MsgBox.Warning("The GUI "+aControl.get(0)+" cannot be found in the current project.","Script Eror") return(nil) end theMbar=av.getproject.findGUI(mDoc).GetMenuBar themenu=theMbar.findbylabel(mMenu) if (themenu=NiL) then themenu=menu.make themenu.setlabel(mMenu) theMbar.add(themenu,999) end themenu.add(thecontrol, theCindex) end 'Add the Tool Menus for each totalControl in theToolMenuList 'The Control list acontrol=totalControl.get(0) 'The physical control theControl = totalControl.get(1) 'The control Index theCindex=totalControl.get(2) 'Find the DocGUI theControlDoc=av.getproject.findGUI(aControl.get(0)) if (theControlDoc=NIL) then MsgBox.Warning("The GUI "+aControl.get(0)+" cannot be found in the current project.","Script Eror") return(nil) end 'This finds the control set thecommand="av.getproject.findGUI("""+aControl.get(0)+""").Get" +acontrol.get(1) thescript1=Script.Make(thecommand) thecontrolset=av.getproject.findGUI(aControl.get(0)).GetToolBar 'Add the control to the control set theControlSet.Add(theControl,theCindex) end '***** Add any files, variables, etc that need to be loaded after this line av.getproject.setmodified(true) 'And the scripts add themselves ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Ryan Dalton rdalton@or.blm.gov Willamette/North Coast PIEC 1717 Fabry Rd SE Salem, OR 97306 phone: 503-375-5716 fax: 503-375-5622 Paul_Bartschi@AK.BLM.GOV@ESRI.COM> on 11/06/2000 05:26:59 PM Please respond to Paul_Bartschi@AK.BLM.GOV Sent by: ARCVIEW-L To: ARCVIEW-L@ESRI.COM cc: Subject: [ARCVIEW-L] How to create separators in AV extensions Hello list! I have a question regarding extensions. I have created an extension in arcview that has a menu named ARIMS, a popup named ARIMS, and buttons and tools pertaining to my project. Everything works great, except the menu on the Menu Bar. When the menu gets created, the separators are left out leaving me with one huge menu that is all clumped together. I have reviewed the on-line documentation, and understand that the Space.Make command is supposed allow for separators. My question is how do you insert the space to the menu, so that the separators appear in the spot where you want them? I'm assuming a For Each loop is appropriate here. Any help would be greatly appreciated! Thanks, Paul Bartschi BLM - AK State Office