|
POST
|
When you Inherit Addins.Button. MY namespace can be used. My.ArcMap.Application
... View more
09-29-2011
07:17 AM
|
0
|
0
|
640
|
|
POST
|
Hello, I'm looking for a way to programmatically add an Add-In folder to the list in the Add-In Manager of ArcMap. I have tried simply adding the folder path to the AddInFoldersList.xml file in my AppData\Local\ESRI\Desktop10.0 folder but that doesn't work because when ArcMap closes it overwrites that file and removes my changes. Any help would be appreciated. Thanks! Chris I have no problem doing it this way. Arc does write to the XML during close, but if you have added the folder path and the esriaddinx files are there, nothing will change. Unless... perhaps the folder path you are inserting no longer exists when arc is closing. I had written an exe which, pending windows version (xp, win 7) will enable OFFLINE MODE which prevents the loss of the link as well. (IF the folder is on a server) the second you unplug connection, lets say for a laptop, all the tools are removed during next ARC initialize. I would confirm in Addin Manager >> options that the folder path does indeed exist before closing. Perhaps a mistake was made in the xml file. Recap: 1. verify xml is correct (verifying under options that the folder path and SHARED addins exist before closing Arc) - its possible IF the path (desired folder) contains NO addins, would be removed as well, but I dont know on that) 2. verify folder connection is not lost.
... View more
09-29-2011
07:10 AM
|
0
|
0
|
1691
|
|
POST
|
Ann, Jeff, please could put code in Visual Basic Net, it happens that I can not do the equivalent = (.. I'm still very puppy programming on these issues. Greetings! You have to, of course, declair ArcMap. Public Sub PerformTest()
Const myParaTextID As String = "MyDisclaimerTextID"
Dim paraText As String = "Sample disclaimer paragraph text"
Dim graphicsContainer As ESRI.ArcGIS.Carto.IGraphicsContainer = TryCast(ArcMap.Document.PageLayout, ESRI.ArcGIS.Carto.IGraphicsContainer)
Dim element As ESRI.ArcGIS.Carto.IElement
Dim elementProperties As ESRI.ArcGIS.Carto.IElementProperties
' Check if the disclaimer text element already exists in layout
graphicsContainer.Reset()
element = graphicsContainer.Next()
While element IsNot Nothing
If TypeOf element Is ESRI.ArcGIS.Carto.IParagraphTextElement Then
elementProperties = TryCast(element, ESRI.ArcGIS.Carto.IElementProperties)
If elementProperties.Name = myParaTextID Then
MessageBox.Show("The Disclaimer Text, which autoupdates " & "the time and date, is already placed in the map.")
Return
End If
End If
element = graphicsContainer.Next()
End While
' No disclaimer found, so make one
Dim paraTextElement As ESRI.ArcGIS.Carto.IParagraphTextElement = New ESRI.ArcGIS.Carto.ParagraphTextElementClass()
Dim textElement As ESRI.ArcGIS.Carto.ITextElement = TryCast(paraTextElement, ESRI.ArcGIS.Carto.ITextElement)
elementProperties = TryCast(paraTextElement, ESRI.ArcGIS.Carto.IElementProperties)
element = TryCast(paraTextElement, ESRI.ArcGIS.Carto.IElement)
' Set this so it can be found if this method called again
elementProperties.Name = myParaTextID
' Set the actual text to display
textElement.Text = paraText
' Set the size and location of the text box
Dim envelope As ESRI.ArcGIS.Geometry.IEnvelope = New esri.ArcGIS.Geometry.EnvelopeClass()
envelope.PutCoords(0, 0, 3, 1)
element.Geometry = envelope
' Add the text box to the layout
graphicsContainer.AddElement(element, 0)
ArcMap.Document.ActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGraphics, Nothing, Nothing)
End Sub
... View more
09-01-2011
12:47 PM
|
0
|
0
|
521
|
|
POST
|
The correct way: Using an extension: Here is the Class.vb called in the esriaddinx: [HTML] Imports System.Windows.Forms Imports ESRI.ArcGIS.esriSystem Imports ESRI.ArcGIS.Framework Public Class YOUREXTENSIONClassName Inherits ESRI.ArcGIS.Desktop.AddIns.Extension 'Not needed for this example ' 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 SetAsIconAndText(Your UID OR ClassID value, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleTextOnly ) Catch ex As Exception MessageBox.Show(ex.Message & vbNewLine & "Details: " & ex.StackTrace, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk) End Try End Sub Private Sub ArcMapOpenDocument() Try SetAsIconAndText(Your UID OR ClassID value, ESRI.ArcGIS.SystemUI.esriCommandStyles.esriCommandStyleTextOnly ) Catch ex As Exception MessageBox.Show(ex.Message & vbNewLine & "Details: " & ex.StackTrace, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk) End Try End Sub Public Sub SetAsIconAndText(ByVal UIDValue As String, ByVal CommandStyle As ESRI.ArcGIS.SystemUI.esriCommandStyles) 'control text or Text and icon or icon only Dim pUID As New UID pUID.Value = UIDValue 'YOUR COMMAND BUTTON UID VALUE OR ButtonID name in esriaddinx file of that Addin. Dim pCommandItem As ESRI.ArcGIS.Framework.ICommandItem pCommandItem = My.ArcMap.Application.Document.CommandBars.Find(pUID, True, False) pCommandItem.Style = CommandStyle End Sub End Class [/HTML]
... View more
08-03-2011
11:47 AM
|
0
|
0
|
942
|
|
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
|
942
|
|
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
|
4042
|
|
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
|
4042
|
|
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
|
4042
|
|
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
|
1871
|
|
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
|
1871
|
|
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
|
1871
|
|
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
|
2108
|
|
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
|
1065
|
|
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
|
2911
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 09-27-2024 09:04 AM | |
| 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 |
| Online Status |
Offline
|
| Date Last Visited |
4 weeks ago
|