|
POST
|
In an addin i'm creating there's a button that will add a raster layer to my map based on a selected value in a listbox. The code is simple and works fine: the new layer appears in the TOC and the image appears on the map, but curiously all visibility checkboxes on layers in the TOC become greyed out for a while. After a minute or so, they become enabled again. I'm guessing something is going on in a background thread that is setting the visibility checkboxes to disabled while it is doing whatever it is doing. The question is what is it doing? The images are around 10mb each and georeferenced. private async void cmd_ButtonAdd_Click(Object sender)
{
Layer pImgLay;
string url = selectedObliqueVal;
url = m_imgPath + m_Isle + m_imgFolder + "A" + url.Substring(1, 1) + @"\" + url + ".jpg";
if (!System.IO.File.Exists(url))
{
MessageBox.Show("File does not exist:\r\n" + url);
return;
}
pImgLay = await QueuedTask.Run(() => { return LayerFactory.Instance.CreateLayer(new Uri(url), MapView.Active.Map); });
_addedImages.Add(url);
//MessageBox.Show("Add");
}
... View more
05-19-2022
01:54 PM
|
0
|
0
|
487
|
|
POST
|
Yes, you are right! But that error should still restrict the file types to just .xls. After correcting that error, the tool still allows any type of file.
... View more
02-24-2022
11:16 AM
|
0
|
0
|
806
|
|
POST
|
I created some ArcObjects code that creates a geoprocessing tool that creates a featureclass from some input files. The code creates a GP tool that works as it should, except for one problem: the GP parameter for the input files accepts all files when it is supposed to only accept files with the extension .jxl or .xls. There is no documentation on how to do this, but below is the code snippet of what I wrote to create the input file parameter. I've also converted the tool to a Python tool (which has much better documentation) and it does filter input files to just the allowed ones. I assume the underlying objects are the same for the .Net SDK as for ArcPy, so there should be a way to get the .net authored tool to work as well. I also looked for clues in the Pro SDK, but came up with nothing since Pro doesn't even support creating GP tools with .net. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
parameter = New GPParameterClass()
Dim inputType As IGPDataType = New DEFileTypeClass()
Dim pGXFileFilter As IGxFileFilter = New GxFileFilterClass
pGXFileFilter.AddFileType("jxl", "Trimble JXL Files", "")
pGXFileFilter = New GxFileFilterClass
pGXFileFilter.AddFileType("xls", "Excel Files", "")
Dim pGXFilterInfo As IGxFilterInfo
pGXFilterInfo = CType(inputType, IGxFilterInfo)
pGXFilterInfo.OpenGxObjectFilters.Add(pGXFileFilter)
pGXFilterInfo.SaveGxObjectFilters.Add(pGXFileFilter)
Dim mvType As IGPMultiValueType = New GPMultiValueTypeClass()
mvType.MemberDataType = inputType
Dim mvValue As IGPMultiValue = New GPMultiValueClass()
mvValue.MemberDataType = inputType
parameter.Name = "input_files"
parameter.DisplayName = "Input Files"
parameter.ParameterType = esriGPParameterType.esriGPParameterTypeRequired
parameter.Direction = esriGPParameterDirection.esriGPParameterDirectionInput
parameter.DataType = CType(mvType, IGPDataType)
parameter.Value = CType(mvValue, IGPValue)
pParameters.Add(parameter)
' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
... View more
02-17-2022
03:40 PM
|
0
|
2
|
849
|
|
POST
|
If you need to do something before the tool is used, then use ActiveToolChangedEvent mentioned, but if what you are doing occurs when the tool actually does something, then just get the active tool - there's only one. Tool currentTool = FrameworkApplication.ActiveTool;
MessageBox.Show(currentTool.Caption);
... View more
02-17-2022
01:20 PM
|
0
|
0
|
759
|
|
POST
|
Whole new world - maybe. More like a different planet. The "help" is unfortunately rather fragmented: Reference The reference for all the Pro objects. For the most part auto-generated and doesn't give you much more than what intellisense does. Snippets Bits of code to do various things. Very good, but requires a lot of searching through the various categories if you didn't create the SDK and thus don't know what's in all the various SDK assemblies. Samples Lots of very good samples. Requires some editing in wordpad of the .csproj files if you did not install ArcGIS in the default location. The one you want to look at is under "Framework" called DockpaneSimple. It has a couple of listboxes. Pay attention to the Bindings in BookmarkDockpane.XAML for the listboxes, and the corresponding properties in BookmarkDockpaneViewModel.cs That app makes a list of Bookmark names, but can just as easily be some text items you get from your WebResponse. DockPanels don't go away once they are created, so if you want your app to work like a geoprocessing tool and go away once it's done doing it's work, you'll need to add this at the end: DockPane dockPane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
if (dockPane != null) { dockPane.IsVisible = false; } You can find what _docPaneID for your app is supposed to be in the Config.DAML for your addin.
... View more
02-07-2022
02:07 PM
|
0
|
0
|
1807
|
|
POST
|
I want to put some custom maptools into a dockpanel addin. I have found how to do this and run it from an RelayCommand and it works using the little bit of code below, but I was wondering about the parameter that you can pass to the tool. Can this be anything? If so, how do I get at it from within my maptool? IPlugInWrapper pWrapper = FrameworkApplication.GetPlugInWrapper("PukaWai_GetFeatTool");
if (pWrapper is ICommand toolCmd)
{
// toolCmd.Execute(null);
toolCmd.Execute("parameter");
}
... View more
02-05-2022
08:34 PM
|
0
|
0
|
494
|
|
POST
|
I have been able to do all the topology stuff in a Pro addin that I was able to do in an ArcMap addin, but that didn't include creating topologies. The Pro SDK doesn't let you create database things, you are expected to use Geoprocessing tools for all that. There are tools for Creating Topology, Adding Rules, Adding Featureclasses. There's also a snippet for running a geoprocessing tool from .net. Not sure about adding them to a map, but I was able to find a topology layer in my map so there must be a way to create the topologylayer in the SDK as well.
... View more
02-05-2022
08:16 PM
|
1
|
0
|
2040
|
|
POST
|
Try t await QueuedTask.Run(() =>
{
ReadOnlyObservableCollection<Layer> lstLays;
lstLays = MapView.Active.Map.Layers;
foreach (Layer lay in lstLays)
{
if (lay is GroupLayer)
{
GroupLayer pGrpLay = (GroupLayer)lay;
ReadOnlyObservableCollection<Layer> featureLayers = pGrpLay.Layers;
foreach (FeatureLayer fLay in featureLayers)
{
CIMBaseLayer fLayDef = fLay.GetDefinition();
string pLayName = fLayDef.Name;
MessageBox.Show(pLayName);
}
}
}
}); his:
... View more
02-05-2022
08:00 PM
|
0
|
1
|
1281
|
|
POST
|
Not sure why its hanging, could be something with doing UI stuff in a queuedTask. The bigger issue is that it looks like your combo box is a Windows.Forms.ComboBox and while it supposedly possible to use that, Pro AddIn development is supposed to use WPF. Take a look at this video: https://www.youtube.com/watch?v=ItzVMZZDRGc . It does a good job of explaining how to set up the combo box and get it to automatically update when adding stuff. It's worth it to watch the whole thing, but the relevant part to populating combo boxes starts around 22:00. Pro AddIns, especially with some sort of UI using WPF and MVVM are a sizeable learning curve jump from ArcMap AddIns and will take a while to get used to, but not too bad after that. Just have to get used to writing considerably more code to do the same thing. From another newbie.
... View more
02-05-2022
07:02 PM
|
0
|
2
|
1829
|
|
POST
|
I wrote a bit of code to show me the extent (footprint) of a raster with a Polyline. It should be fairly simple by getting the map coordinates of four corner pixels of the raster. Yes, I'm aware that those should give me the coordinates of the center of those pixels, but that's fine. The code works fine for Rasters with orthogonal georeferencing, but has problems if the georeferencing rotates and stretches the image. See screenshot below for the results I'm getting await QueuedTask.Run(() =>
{
pOutLay = (FeatureLayer)LayerFactory.Instance.CreateLayer(new Uri(url), MapView.Active.Map);
pSpatRef = SpatialReferenceBuilder.CreateSpatialReference(32655); //UTM55N
EditOperation createFeatEditOp = new EditOperation();
createFeatEditOp.Name = "CreateImageEdges";
createFeatEditOp.SelectModifiedFeatures = false;
createFeatEditOp.SelectNewFeatures = false;
foreach (Item itm in items)
{
lstPnt = new List<MapPoint>();
string path = itm.Path.Substring(0, itm.Path.LastIndexOf(@"\"));
string strFile = itm.Path.Substring(itm.Path.LastIndexOf(@"\") + 1);
FileSystemConnectionPath connectionPath = new FileSystemConnectionPath(new System.Uri(path), FileSystemDatastoreType.Raster);
FileSystemDatastore dataStore = new FileSystemDatastore(connectionPath);
RasterDataset fileRasterDataset = dataStore.OpenDataset<RasterDataset>(strFile);
Raster pRas = fileRasterDataset.CreateDefaultRaster();
pTup = pRas.PixelToMap(0, 0);
lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
pTup = pRas.PixelToMap(0, pRas.GetWidth());
lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
pTup = pRas.PixelToMap(pRas.GetHeight(), pRas.GetWidth());
lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
pTup = pRas.PixelToMap(pRas.GetHeight(), 0);
lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
pTup = pRas.PixelToMap(0, 0);
lstPnt.Add(MapPointBuilder.CreateMapPoint(pTup.Item1, pTup.Item2));
pPline = PolylineBuilder.CreatePolyline(lstPnt, pSpatRef);
dctAtts = new Dictionary<string, object>();
dctAtts.Add("SHAPE", pPline);
dctAtts.Add("Image", strFile);
dctAtts.Add("Width", pRas.GetWidth());
dctAtts.Add("Height", pRas.GetHeight());
createFeatEditOp.Create(pOutLay, dctAtts);
}
createFeatEditOp.Execute();
});
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} The size of this image is 8272x6200 and you can see in the table that I'm not getting the correct height from the Raster object either. Any idea what's going on here?
... View more
12-31-2021
05:05 PM
|
0
|
0
|
720
|
|
POST
|
Yes, that is what I was doing, but still molasses slow. But I stumbled upon a solution that works much better: cast your featurelayer to a BasicFeatureLayer which has a ShapeType property. This little snippet creates a list of selected layers that match a specified geometry type. Fore some reason GeoNet doesn't give me the option for inserting "code". dctLookup = new Dictionary<string, esriGeometryType>(); dctLookup.Add("POINT", esriGeometryType.esriGeometryPoint); dctLookup.Add("LINE", esriGeometryType.esriGeometryPolyline); dctLookup.Add("POLYGON", esriGeometryType.esriGeometryPolygon); selLays = MapView.Active.GetSelectedLayers(); foreach (Layer lay in selLays) if (lay.MapLayerType == MapLayerType.Operational) { pBFL = lay as BasicFeatureLayer; if (pBFL != null) { for (int i = 0; i < lstTypes.Count; i++) { if (pBFL.ShapeType == dctLookup[lstTypes[i]]) { lstLays[i] = lay; } } } } return lstLays;
... View more
12-21-2021
12:52 PM
|
1
|
0
|
5801
|
|
POST
|
Thanks for posting this solution, it was something I needed to do. Have you found any other methods for determining the geometry type of a feature layer? Your posted solution works, BUT it is excruciatingly sloooow - it took over 15 seconds to determine the geometry type for 2 layers...
... View more
11-26-2021
08:55 PM
|
0
|
2
|
5904
|
|
POST
|
Thanks to @Robert_LeClair for "Tagging" Melita, didn't know how to do that. I have spoken with Melita several times before concerning issues on another island in the vicinity! Melita, Yes, that is exactly what I am finding, and likewise I didn't want flip the transformation either. You can try it yourself: I'm attaching a zipfile containing 3 .gtf files and 3 more that are "flipped". Also in the zipfile is a little file geodatabase with point features of USGS benchmarks using the published coordinates on each of three islands (Saipan. Tinian, Rota) in both UTM as well as the local coordinate system so you can see the result of the transformation. Rota has a couple additional issues: I have been unable to find any information on the details of the spatial reference used there, nor have I encountered anybody out there that knows. I know it uses the same Geo Datum as the other islands and also the same projection but with different parameters. I stumbled across one single .prj file and used it to create a custom transformation which works well, but the Geographic offsets therein are so large that I don't think the .prj is right. These custom transformations were made to work together with the "Guam_1963_to_WGS84_Saipan" transformation which was fine in ArcMap, but Pro ignores it - I think because Rota is a little bit south of the bounds in the documentation for that transform.
... View more
10-14-2021
07:05 PM
|
1
|
1
|
1970
|
|
POST
|
I am trying to use some custom datum transformations in Pro. These were created to work in conjunction with a standard transformation as a composite transformation. I have noticed that the standard transformations are bi-directional, i.e. the same transformation is used no matter which is the "from" datum and which is the "to" datum. The custom transformations are also bi-directional, but they only show up for one direction in the transformations list box in Map properties. I've found some workarounds but neither is ideal: If my custom transformation doesn't show up, I can change my map spatial reference to be the same as the layer that needs the transformation, then select the transformation that uses the custom transformation, and then switch the map spatial reference back again. (The selected transformation remains and works as it should) The second workaround involved writing a .net AddIn to set the transformation which works great but is limited to the custom transformations it is written for. The third workaround is to develop a second set of custom transformations that work in the reverse direction. Is there some way to get Pro to consider custom transformations as bi-directional when it decides what transformations to show in the dropdown list?
... View more
10-13-2021
02:07 PM
|
0
|
4
|
2051
|
|
POST
|
Brilliant solution. Almost - but only works for ArcGIS Pro. ArcCatalog is ArcGIS 10.x and thus uses Python 2.7, where this doesn't work. Some digging came up with just reload(your-module) or there's another reload in module imp: import imp imp.reload(your-module) which works for python 2 and 3.2-3.3 although I don't think there's Pro version that uses any of these Python versions. Thanks for putting me on the right path!
... View more
09-13-2021
01:59 PM
|
0
|
0
|
3026
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-14-2021 07:05 PM | |
| 1 | 06-09-2020 12:58 PM | |
| 1 | 07-21-2022 05:46 PM | |
| 1 | 02-05-2022 08:16 PM | |
| 1 | 12-21-2021 12:52 PM |
| Online Status |
Offline
|
| Date Last Visited |
07-29-2025
11:30 AM
|