POST
|
Hi Dan, In ArcGIS 9, you can put your vba code and button in the Normal template, which makes it global. But that is no longer supported starting at ArcGIS 10. So if you're using 10, you need to create an Add-In. You indicate you're using the Express edition of Visual Studio, so you will have to use VS 2008, since that's what the SDK installer supports. You should be able to simply reinstall the SDK to get the ArcGIS templates into VS.
... View more
04-10-2012
01:30 PM
|
0
|
0
|
295
|
POST
|
Hello Robert, The easist option, imo, is VBA to Add-In. You can code the Add-In in VB.NET, C#, or JAVA. A year ago I put together a tutorial on converting a simple VBA 9.3 ArcMap utility that included a button that launches a form and performs a simple move features operation. It converts the VBA to a C# Add-In, but the process for VB.NET is very similar and with less changes needed to go from VBA to VB.NET. VBA to Add-In Conversion Tutorial
... View more
01-19-2012
03:22 PM
|
0
|
0
|
205
|
POST
|
Hi Charles, Your line of code: element.Geometry = balloonParms.AnchorPoint; sets the position of the balloon text (lower-left corner). To set the leader line, you need to create another Point for the anchor of the leader line (offset from the text element of course) and assign it to IBalloonCallout.AnchorPoint. If you are already setting that in your GetTextBalloon() method, then you just need to use a point offset from it for IElement.Geometry. IOW, the leader won't show unless there is an offset between the two.
... View more
01-03-2012
11:31 AM
|
0
|
0
|
140
|
POST
|
I see the same behavior in the generated code and the subsequent error. However, try editing the line in the Config.Designer.cs file from: internal static string TestNamespace.cmdTest { to: internal static string TestNamespaceCmdTest { (just remove the dot, or change the name to something else appropriate) Then do a rebuild and it should work. Note: in the sample Addin that I tested this with, upon the first rebuild after I edited the static property name, the name was reset to the one with dots and the build failed again. After editing it again it seemed to stick for subsequent builds.
... View more
12-21-2011
07:49 AM
|
0
|
0
|
217
|
POST
|
Thanks, Neil! That makes it work. And thanks for the explanation. Here is the corrected line that will fix the prior code: ICommandBar contextMenu = cmdBars.Find(contextMenuUID, false, false) as ICommandBar;
... View more
12-16-2011
09:02 AM
|
0
|
0
|
543
|
POST
|
I threw something together, but it isn't working. Here is some C# test code for an Add-In extenstion attempting to add an item to the Feature Layer Context Menu:
protected override void OnStartup()
{
WireEvents();
}
private void WireEvents()
{
ArcMap.Events.OpenDocument +=
new ESRI.ArcGIS.ArcMapUI.IDocumentEvents_OpenDocumentEventHandler(Events_OpenDocument);
ArcMap.Events.NewDocument +=
new ESRI.ArcGIS.ArcMapUI.IDocumentEvents_NewDocumentEventHandler(Events_NewDocument);
}
void Events_OpenDocument()
{
System.Diagnostics.Debug.WriteLine("**** Events_OpenDocument ****");
LoadContextMenu();
}
void Events_NewDocument()
{
System.Diagnostics.Debug.WriteLine("**** Events_NewDocument ****");
LoadContextMenu();
}
private void LoadContextMenu()
{
ICommandBars cmdBars = ArcMap.Application.Document.CommandBars;
UID contextMenuUID = new UIDClass();
contextMenuUID.Value = "{BF643199-9062-11D2-AE71-080009EC732A}"; //esriArcMapUI.FeatureLayerContextMenu
ICommandBar contextMenu = cmdBars.Find(contextMenuUID, false, true) as ICommandBar;
if (contextMenu != null)
{
// Get the command item you want to add
UID commandUID = new UIDClass();
commandUID.Value = "Test_TestParaTextButton"; // Add-in button ID
//Check if it is already present on the context menu.
ICommandItem myCmdItem = contextMenu.Find(commandUID, false);
if (myCmdItem == null)
{
Object pos = contextMenu.Count - 1;
myCmdItem = contextMenu.Add(commandUID, ref pos);
//myCmdItem.Group = true;
myCmdItem.Refresh();
}
}
else
{
System.Diagnostics.Debug.WriteLine("**** contextMenu is null ****");
}
}
The contextMenu object is null on both calls to the method, so I suspect the GUID is either wrong or no longer supported.
... View more
12-16-2011
08:10 AM
|
0
|
0
|
542
|
POST
|
I was also thinking, "The only trick is finding the guid of the context menu." I found the following: {BF643199-9062-11D2-AE71-080009EC732A} esriArcMapUI.FeatureLayerContextMenu in the 9.0 documentation for Names and IDs. I couldn't find it in the similar 10.0 documentation. Maybe I'm looking in the wrong place?
... View more
12-15-2011
03:11 PM
|
0
|
0
|
542
|
POST
|
I haven't implemented that before, but I suspect you will need to use ICommandBar, since its documentation mentions context menus. I also think you're on the right track using an extension. You might want to have a look at this thread where we did something similar to add a menu to ArcMap's main menu bar: Modify-(add)-to-MAIN-Toolbar-with-Addinx-files Be sure to post back if you get anywhere -- or not.
... View more
12-15-2011
12:56 PM
|
0
|
0
|
542
|
POST
|
According to another thread, the caption property bug will be fixed in 10.0 SP4 and 10.1: Change Caption of Base Command
... View more
11-22-2011
09:10 AM
|
0
|
0
|
371
|
POST
|
I suspect it is because you are using the IFeatureDataConverter2. I just did a quick test with IExportOperation instead, in an Add-In, and it does export joined fields. Here's some quick and dirty code that I tested it with:
public void PerformTest5()
{
// Get the selection in TOC.
object item = ArcMap.Document.SelectedItem;
// Make sure it is a feature layer
if (item is IFeatureLayer)
{
IFeatureLayer featureLayer = item as IFeatureLayer;
IDisplayTable displayTable = featureLayer as IDisplayTable;
ISelectionSet selectionSet = displayTable.DisplaySelectionSet;
IDataset dataset = displayTable.DisplayTable as IDataset;
IDatasetName datasetName = dataset.FullName as IDatasetName;
IWorkspaceFactory outShapeWSF = new ShapefileWorkspaceFactoryClass();
IDataset outShapeWS = outShapeWSF.OpenFromFile("C:\\GIS", 0) as IDataset;
IWorkspaceName outShapeWSName = outShapeWS.FullName as IWorkspaceName;
IDatasetName outShapeName = new FeatureClassNameClass();
outShapeName.Name = "Export_test1";
outShapeName.WorkspaceName = outShapeWSName;
IExportOperation exportOperation = new ExportOperationClass();
exportOperation.ExportFeatureClass(datasetName, null, selectionSet, null,
outShapeName as IFeatureClassName, 0);
}
else
{
MessageBox.Show("Please select a feature layer.");
}
}
... View more
11-18-2011
01:22 PM
|
1
|
1
|
722
|
POST
|
Now, the only issue i'm running into is that I have a table joined to the map layer and those joined fields are not being "exported"! So far no luck on this particular issue. If anyone has any info on how I can include my joined table's fields in the "Export"... please help! Derek Take a look at using IDisplayTable for your source.
... View more
11-17-2011
02:23 PM
|
0
|
0
|
722
|
POST
|
Why should there be a difference between System.Drawing.Color.ToArgb() and the preceding code? The byte-ordering of the 32-bit ARGB value produced by System.Drawing.Color.ToArgb() is AARRGGBB. The order for IColor.RGB is 00BBGGRR. The 00 byte is not used. So not only is the order reversed, but there is no Alpha (transparency) in the ESRI integer color. So you will get very different colors assigning one to the other.
... View more
11-16-2011
02:29 PM
|
0
|
0
|
436
|
POST
|
Charles, If you provide some information regarding the values you are passing to your method, I will try to reproduce the issue. Either attach a zipped shapefile of the layer, or a description of it from which to create a dummy. Is this used in an Add-In?
... View more
11-16-2011
12:02 PM
|
0
|
0
|
436
|
POST
|
I don't have time right now to test this, but try the following: Replace the line: ITextSymbol textSymbol = new TextSymbol(); with: ISimpleTextSymbol textSymbol = new TextSymbolClass(); and replace: IColor color = textSymbol.Color; with: IRgbColor color = new RgbColorClass();
... View more
11-16-2011
08:16 AM
|
0
|
0
|
436
|
POST
|
There seems to be a disconnect between the UI button caption and the ICommandItem.Caption property. I tried some similar code in C#:
private void ChangeButtonCaption()
{
// Get the collection of toolbars
ICommandBars cmdBars = ArcMap.Application.Document.CommandBars;
// Get the button
UID uid = new UIDClass();
uid.Value = ThisAddIn.IDs.TestButton;
ICommandItem cmdItem = cmdBars.Find(uid, false, false);
// skip out if no button
if (cmdItem == null)
return;
// report the current caption
System.Diagnostics.Debug.WriteLine("cmdItem.Caption: " + cmdItem.Caption);
// change the caption
cmdItem.Caption = "Test Button (clicked)";
cmdItem.Refresh();
// report the changed caption
System.Diagnostics.Debug.WriteLine("cmdItem.Caption: " + cmdItem.Caption);
// Cannot set Tooltip: get error "This method cannot be called on built in commands"
// This is mentioned in documentation for this property.
//cmdItem.Tooltip = "Test tooltip. (clicked)";
}
As the original poster reported, the UI caption never changes even though the caption property persists. Further, after using ArcMap to change the UI caption (by opening the Customize dialog, then right-clicking on the button and editing the Name value), the new caption is reflected in the underlying ICommandItem.Caption property, but the UI caption still does not change when editing the property. [added] You can change the icon for the button. Inserting a line of code above with cmdItem.FaceID = 1 works. See the ICommandItem.FaceId documentation for more info.
... View more
11-15-2011
10:35 AM
|
0
|
0
|
371
|
Title | Kudos | Posted |
---|---|---|
1 | 11-03-2010 01:41 PM | |
1 | 10-04-2011 01:44 PM | |
1 | 11-18-2011 01:22 PM | |
1 | 03-09-2011 07:59 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|