POST
|
I'm not sure if it's completely right, but I've used this code inside the OnUpdate method and it works for me, I've no need to change the style manually. Note that the OnUpdate method is called many times during the start up of ArcMap, but the first few . No, OnUpdate is Not called when a NEW arcmap session is opened. I tried several times with a fresh Addin, then debug or run arc, there was no OnUpdate trigger, therefore, no adjustment to the command style. OnUpdate was not triggered until you pressed the actual button, but a new Addin, toolbar shows up, and ONLY the icon shows up even with the code in Protected Overrides Sub OnUpdate(). OR if you were lucky to hit a framework OnUpdate run, used for example to check if an extension is enabled. In debugging, was not stopped (break point) either when a fresh arc was opened meaning OnUpdate was never called on New Document. There must be something you had done prior, or manually changed it at some point or just got lucky the framework called the OnUpdate. Change your code to be esriCommandStyleTextOnly and see if its ONLY text (and see if it changes), then change it to a different enum again and see if the change follows. No Overrides from a button perspective will work. OnUpdate is random and multiple times called by the framework... If it manages to update the button, you hit a 'right time' scenario, and you would be running the code over and over. When I set OnDemand = false in the esriaddinx, I cant even get Arc to load, it just crashes... i believe due to the command not initialized yet, and already trying to change the commands style. The only proper method is to add an extension and run on NEW and OPEN document events, to control the command style as stated prior. this ensures the commandstyle change WILL occur right at startup. ref: http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//001v000001qw000000
... View more
08-03-2011
11:14 AM
|
0
|
0
|
383
|
POST
|
Just to summarize... This does work, if a) you build a toolbar with commands (buttons) ... you must then build an EXTENSION to use the Events.NewDocument and Events.OpenDocument. Currently I do not know of a way of adjusting the Command style through the Toolbar/buttons added in a specific Addin file. - the ORIGINAL Question. then find the UID value for that specific command Item... like so... Public Sub SetAsIconAndText()
' Make sure button is showing Icon And Text
Dim pUID As New UID
pUID.Value = "{6298A204-AD3A-9573-D5E7-E8952250BA36}" ' Toolbar GUID"
Dim pCommandItem As ESRI.ArcGIS.Framework.ICommandItem
pCommandItem = My.ArcMap.Application.Document.CommandBars.Find(pUID, True, False)
pCommandItem.Style = ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleTextOnly
End Sub
... View more
08-02-2011
09:53 AM
|
0
|
0
|
1767
|
POST
|
This specifically was for a toolbar / buttons... so create an extention just to control the command styles? seems silly... let me see if that works... you cant access THISaddin and look for that button as its not contained in the Extension addin. its in a separate addin. How would one trigger on 'creation' when the Addin is added, its not possible is it? The code below works, but never found a way to have it work on loading the toolbar. OnClick - well, thats too late OnUpdate ? Sub Finalize? Public Sub SetAsIconAndText()
' Make sure button is showing Icon And Text
' Dim pUID As New UID 'not needed
' pUID.Value = My.ThisAddIn.AddInID ' ' Toolbar GUID ' not needed
Dim pCommandItem As ESRI.ArcGIS.Framework.ICommandItem
pCommandItem = My.ArcMap.Application.Document.CommandBars.Find(My.ThisAddIn.IDs.PrecisionXYButton, true, false)
pCommandItem.Style = ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleIconAndText
End Sub jeff... you were a ton help in getting me going with creating Root Menu drop down items and pointing to other buttons/commands btw...
... View more
08-02-2011
09:38 AM
|
0
|
0
|
1767
|
POST
|
I found this: http://gis.stackexchange.com/questions/1297/can-you-programmatically-change-the-button-image-for-a-esri-arcgis-desktop-addins and it works for me! 😄 perhaps I should have clarified... I am aware of Caption and all XML variables within the esriaddinx config file... Caption gives the text under the Customize Mode >Commands window, as it should. The question was... how does one, when creating a toolbar with buttons, have an IMAGE and TEXT (text for the image) appear on the toolbar ** using Addins? (Have no problems using dll old method with Command Style (I only found a way to use drop downs and have image AND text together, but not simply a button on a toolbar... Once the button is on the bar, the user then MUST go to Customize >> Customize mode and right click on the image and click from DEFAULT to 'Image and Text' to have the button and Text both visible. The question was, is there a way to have Button AND text show up on a toolbar as seen in the pic here, I have to manually change to have BOTH icon and text show on the toolbar as seen below for PrecisionXY example.
... View more
08-02-2011
08:45 AM
|
0
|
0
|
1767
|
POST
|
Wow! This works! Thanks a ton! Your example, and adjustments all make complete sense. Handy to have that Acme example as well... thanks for that pointer! Im no C# guy, so Ill post my vb.net version for anyone else to go over, including yourself In the config.esriaddinx as usual, create the menu, containing the items > button and Commands containing the button ID Autoload = true >> on the extension isRootMenu = true >> on the Menu And here is the vb.net version that works. * note I used IndexObject value of 1 to place right beside the FILE choice on the main bar. Imports System.Windows.Forms
Imports ESRI.ArcGIS.Framework
Imports ESRI.ArcGIS.esriSystem
Public Class Extension1
Inherits ESRI.ArcGIS.Desktop.AddIns.Extension
Private c_mainMenuID As String = "{1E739F59-E45F-11D1-9496-080009EEBECB}" ' Main menubar
Public Sub New()
End Sub
Protected Overrides Sub OnStartup()
WireDocumentEvents()
End Sub
Protected Overrides Sub OnShutdown()
End Sub
Private Sub WireDocumentEvents()
AddHandler My.ArcMap.Events.NewDocument, AddressOf ArcMapNewDocument
AddHandler My.ArcMap.Events.OpenDocument, AddressOf ArcMapOpenDocument
End Sub
Private Sub ArcMapNewDocument()
Try
LoadCustomMainMenu()
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine & "Details: " & ex.StackTrace, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
End Try
End Sub
Private Sub ArcMapOpenDocument()
Try
LoadCustomMainMenu()
Catch ex As Exception
MessageBox.Show(ex.Message & vbNewLine & "Details: " & ex.StackTrace, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
End Try
End Sub
Private Sub LoadCustomMainMenu()
Dim mainMenuBar As ESRI.ArcGIS.Framework.ICommandBar = GetMainMenuBar()
' make sure we got the main menu bar
If mainMenuBar Is Nothing Then
Return
End If
' check if our custom menu is already there
Dim menuID As String = "FocusToolsToolbar_Addin_v10_ERCBMenu"
' ID of Add-In Root Menu
Dim cmdItem As ESRI.ArcGIS.Framework.ICommandItem = mainMenuBar.Find(menuID, False)
' skip out if custom menu already there
If cmdItem IsNot Nothing Then
Return
End If
System.Diagnostics.Debug.WriteLine("**** MENU ADDED ****")
' Add Menu, if needed
Dim uid As ESRI.ArcGIS.esriSystem.UID = New ESRI.ArcGIS.esriSystem.UIDClass()
uid.Value = menuID
Dim indexObj As [Object] = 1 ' Right beside FILE
' adds menu one spot in
Dim myMenu As ICommandBar = TryCast(mainMenuBar.Add(uid, indexObj), ICommandBar)
DirectCast(mainMenuBar, ESRI.ArcGIS.Framework.ICommandItem).Refresh()
End Sub
Private Function GetMainMenuBar() As ICommandBar
Try
'Grab the root menu bar
Dim uid As ESRI.ArcGIS.esriSystem.UID = New ESRI.ArcGIS.esriSystem.UIDClass()
uid.Value = c_mainMenuID
Dim mx As ESRI.ArcGIS.ArcMapUI.MxDocument = DirectCast(My.ArcMap.Application.Document, ESRI.ArcGIS.ArcMapUI.MxDocument)
Dim cmdBars As ESRI.ArcGIS.Framework.ICommandBars = mx.CommandBars
Dim x As ESRI.ArcGIS.Framework.ICommandItem = cmdBars.Find(uid, False, False)
Return TryCast(cmdBars.Find(uid, False, False), ICommandBar)
Catch
Return Nothing
End Try
End Function
End Class
... View more
07-27-2011
08:22 AM
|
0
|
0
|
673
|
POST
|
Hi Jeff, It is interesting, possibly requiring a fix in newer releases or a WIP? Funny how writing 15,000 lines of code for some complex task is less frustrating than something you would think is so simple to accomplish, lol. Perhaps someone else will chime in soon, or you find something I overlooked... I really dont want to go back to registering dlls methods outside of addins just because of this. Thank you for your efforts with this!
... View more
07-25-2011
09:18 AM
|
0
|
0
|
673
|
POST
|
The whole issue with IMenuDef is the fact Im trying to do this through Addins as stated, which is not structured in that manner. (Am I missing something perhaps?) Back in the 'old' days... years of doing msi installer packages and registering a compiled dll, I used IMenuDef to alter any arcmap... The problem is we now have everyone on shared addins, rather than installing and registering dlls using, (esriregasm), as its a headache free updating setup (one update = everyone gets updated on next arcmap setup, via addins or addition of new tools, etc without any babysitting of everyones machines to ensure they uninstall/install etc. correctly. Then go through the entire process again for any found issues. Addins has streamlined the updating tremendously, using shared addins on a visible network drive/folder for all offices. The first post code works, it adds the menu, but thats where the road ends... unable to add any further Addin Tools. Ill look at it again, but I dont think modifying the Main menu bar is plausible at this time... I have the menu bar receiving the added item via an Addin Extension
... View more
07-25-2011
07:10 AM
|
0
|
0
|
673
|
POST
|
Hi there, I'm trying to learn how to use Visual Studio to create a button that loads a form. I'm using Visual Studio Express 2008 (VB.NET). I've followed, step by step, two tutorials: http://gis.qtools.com/blog/tutorials/vba-to-c-add-in/part-4-creating-new-add-in-project/ (up to Part 4 and using VB.NET) http://www.esri.com/news/arcuser/0311/recycling-vba.html In neither tutorial have I been able to get a form to load. In the case of the first tutorial, I can't even get a message box to display. It's pretty frustrating. So, I started from scratch in a new project (ArcMapAddIn1). It is a button (Button1) on a toolbar (My Toolbar). When the button is pressed a message box is supposed to pop up (this is under the OnClick event for Button1). Nothing happens when I press the button! It just goes grey. Any ideas about what I'm missing here? Cheers, Olwyn Button going grey is a sign that the dll is not unpacked from the Addin, missing the class. Check the Assembly Folder for the dll.. make sure your build action is AddinContent for the esriaddinx. Make sure the others are Compile and if you are moving files over to the Assembly Folder, use Embedded Resource. Just see what gets unpacked.. or check the ESRIAddin.exe itself by renaming it .zip and unzipping to see the contents. In this case above... there is: class="StaggerOffsetButton" Is this class in the Solution?
... View more
07-14-2011
01:45 PM
|
0
|
0
|
886
|
POST
|
Thanks guys. Although i havent been able to locate the AddinFoldersList.xml. I am using Windows XP. Any ideas where i can locate the file on XP. For windows XP the xml is located here: "C:\Documents and Settings\" & Environment.UserName & "\Local Settings\Application Data\ESRI\Desktop10.0\AddinFoldersList.xml"
... View more
07-13-2011
07:14 AM
|
0
|
0
|
462
|
POST
|
ArcMap wasn't designed to be automated and the whole process is flaky and, in my opinion, a lot more trouble than it's worth. After a few years of somewhat achieving full automation, which in some rare cases is really handy (such as I have automated where as a sent email from a client triggers eventual data xy created by info in the email, open arc, create features, attributes, place in cleint gdb, create a compiled layout and pdf back to the emailer and close - no one needs to be around, just the computer on) otherwise I completely agree with Neil...
... View more
07-13-2011
06:23 AM
|
0
|
0
|
1100
|
POST
|
Just give a spatial Reference Environment such as createprojectedCoordinateSystem Add point to a featurelayer Get the spatial reference of the featureclass... pPoint.PutCoords(x,y) >> values from the entered by the user then project to the featureclass pPoint.Project(pSpatialReference) You can then add attributes / fields to the featureclass... pFeature.Shape = pPoint pFeature.Store () I do this, but using Local Coordinates, sent to a web-service for conversion... etc.. but you will get the idea. 'get the spatial information from the shapefile and add the new point with attributes to the point file
'Need to look at what projection or lat/long of the shapefile where the point is being created.
Dim pSpatialReferenceWebServices As ESRI.ArcGIS.Geometry.ISpatialReference
Dim pSpatialReferenceEnvironment As New ESRI.ArcGIS.Geometry.SpatialReferenceEnvironment
Dim pGeodataset As ESRI.ArcGIS.Geodatabase.IGeoDataset
Dim pSpatialReference As ESRI.ArcGIS.Geometry.ISpatialReference
'Spatial Reference passed from Webservies
pSpatialReferenceWebServices = pSpatialReferenceEnvironment.CreateProjectedCoordinateSystem(pSpatialInt)
'Add point to selected layer feautre class
Dim pFeatureClass As ESRI.ArcGIS.Geodatabase.IFeatureClass
pFeatureClass = pPointLayer.FeatureClass ' runtime will not occur as its in the above if statement checking for selected feature
'get the projection of the featurelayer
pGeodataset = pFeatureClass
pSpatialReference = pGeodataset.SpatialReference
Dim pPoint As New ESRI.ArcGIS.Geometry.Point
'give the point the reference from the WkID given from the webservices
pPoint.SpatialReference = pSpatialReferenceWebServices
pPoint.PutCoords(pXCoord, pYCoord)
'now project to the featureclass spatial reference
pPoint.Project(pSpatialReference)
... View more
07-12-2011
01:52 PM
|
0
|
0
|
710
|
POST
|
Hi, I wanted to know if it was possible to programmatically add additional add-in folders (network path) in the Add-In Manager dialog box. Hence the end user doesn't need to do it. This should also enable the developer to provide later version of the add-in without need to re-send the new add-in file. Is this possible. Thanks Sure it possible.. How we run it all here. Went further and wrote an exe as an ADDIN installer... one click program modifying that xml for the user as well as enabling OFFLINE server folder path for caching, the user doesn't have to do a thing. Remember, using a network path, the second the network is unavailable.. alll the tools are deleted from the users machine... and is NOT restored either!.. as the network path in the xml or seen by the user under addins-manager (options) is automatically removed. So caching is a must... e.g. Offline for windows 7. its great though, everyone has the deployed addins, even our custom Patch and Service pack updater to keep everyone up to date automatically... any changes made, is made through the restricted write server folder... everyone gets the new update instantly. Pending on the OS being used... windows 7 has the AddinFoldersList.xml stored under USERS >> [USER] >> AppData >> Local >> ESRI >> Desktop10.0.. and all the assemblies from the addinx file land under the assembly directory (a protected operating system file) and then under their corresponding UID as their folder name. So to see this folder, you must UN-CHECK Hide Protected Operating System Files, Its not a 'Hidden Folder'. Then you see your UID folder.. e.g. \AssemblyCache\{ABCB2AE5-4AA6-67AE-052A-DC8126BAB0AA} And then its just your normal dll (toolset or extension etc..) with the corresponding files like the good old days of COM and packaging as an MSI. (but not registered in the Registry this way...) Pass and embed anything over to the local machine as well would end up in this folder, nice and convenient to access.
... View more
06-30-2011
12:14 PM
|
0
|
0
|
462
|
POST
|
Anyone ? No one attempted to modify the Main Bar? add a menu and add a button in the menu with addins?
... View more
06-30-2011
06:33 AM
|
0
|
0
|
673
|
POST
|
Many of our installers write values to the registry which are then read by our ArcGIS extensions. We've never had to change anything with the registry keys in order to make our applications install and run on both 32-bit and 64-bit machines. See this article on MSDN: http://msdn.microsoft.com/en-us/library/aa384232(v=vs.85).aspx Agreed. I only use this as I have made a Patch and Service pack automation program... separate issue from the OP and not related to the thread... Just thought I would post how to, but your link covers all the answers.
... View more
06-27-2011
11:19 AM
|
0
|
0
|
820
|
Title | Kudos | Posted |
---|---|---|
1 | 01-06-2016 11:32 AM | |
1 | 12-13-2021 10:03 PM | |
1 | 07-19-2017 07:31 AM | |
1 | 01-18-2016 07:23 AM | |
1 | 01-08-2016 02:43 PM |
Online Status |
Offline
|
Date Last Visited |
09-27-2024
05:55 PM
|