|
POST
|
That does work in setting the tool to the Line, but I need to do this in my code and get the result. Like I did in ArcObjects. Immediatly after my Feature was created, I wanted a line that represents the Row direction of this polygon (Agriculture field). I basically prompted the user from code to draw a line direction. IGeometry lineGeom = new PolylineClass();
IRubberBand rubberBand = new RubberLineClass();
if (rubberBand.TrackExisting(screenDisplay, null, lineGeom))
{
lineGeom = rubberBand.TrackNew(screenDisplay, null) as IPolyline;
}
screenDisplay.FinishDrawing();
... View more
04-20-2018
11:58 AM
|
0
|
2
|
1149
|
|
POST
|
I am trying to trigger a MapTool from my code now. This will allow me to draw a line that is my direction line that I need. But I can't seem to get it to work. I don't know what i am missing. I keep getting the exception "Cannot set sketch from inactive tool". 1st I am making a MapTool class internal class AddRowDirectionTool : MapTool
{
private IDisposable _graphic = null;
private CIMLineSymbol _lineSymbol = null;
public AddRowDirectionTool()
{
IsSketchTool = true;
SketchType = SketchGeometryType.Line;
SketchOutputMode = SketchOutputMode.Map;
Module.GfxAddRowDirectionTool = this;
}
public async Task startSketch(Geometry inGeometry)
{
await StartSketchAsync();
await SetCurrentSketchAsync(inGeometry);
}
} 2nd I make the reference in the module to the class private AddRowDirectionTool m_gfxAddRowDirectionTool;
public static AddRowDirectionTool GfxAddRowDirectionTool
{
get
{
return Current?.m_gfxAddRowDirectionTool;
}
set
{
if (Current != null)
Current.m_gfxAddRowDirectionTool = value;
}
} 3rd I make the DAML entry for this class <tool id="GFXModule_PairTool" caption="Add Row Direction" className="xxxxyyyzzz.Attributes.Model.AddRowDirectionTool" keytip="AddRow" loadOnClick="true" smallImage="Images\Rings32.png" largeImage="Images\Rings32.png" condition="esri_mapping_mapPane">
<tooltip heading="Add Row Direction">
Add Row Direction<disabledText />
</tooltip>
</tool> 4th In my code where i want to use the tool I do this and get the error "Cannot set sketch from inactive tool" //Here is where I load an instance and call it
AddRowDirectionTool adt = new AddRowDirectionTool();
//I call my function Start Sketch
await adt.startSketch(RowLine);
//It gives me the error when I try and set the geometry in the start sketch function
await SetCurrentSketchAsync(inGeometry);
//But even If i skip over that line and just do this
await StartSketchAsync();
//It doesn't wait for my sketch to be created I know I am missing something simple. Please Advise
... View more
04-20-2018
06:55 AM
|
0
|
4
|
1149
|
|
POST
|
After drawing a polygon on my map. i am required to get a direction Polyline from the user. In ArcObjects, I was able to accomplish this like the following. This would give me a line that a user drew that represented a "direction" IActiveView activeView = pDocument.ActiveView;
IScreenDisplay screenDisplay = activeView.ScreenDisplay;
string cursorLocation = ProMapSettings.AssemblyDirectory + @ProMapSettings.CursorFileLocation + "RowDirection.cur";
bool cursorLocationExists = File.Exists(cursorLocation);
if (cursorLocationExists)
{
System.Windows.Forms.Cursor newCursor = new System.Windows.Forms.Cursor(cursorLocation);
System.Windows.Forms.Cursor.Current = newCursor;
}
screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)esriScreenCache.esriNoScreenCache);
IGeometry lineGeom = new PolylineClass();
IRubberBand rubberBand = new RubberLineClass();
if (rubberBand.TrackExisting(screenDisplay, null, lineGeom))
{
lineGeom = rubberBand.TrackNew(screenDisplay, null) as IPolyline;
}
screenDisplay.FinishDrawing();
polyline = (IPolyline)lineGeom; In ArcGIS Pro, i understand how to create overlays and use map tools to create features, but can't quite figure out how to get a drawing from a user from within the code. If there was a way I could trigger a MapTool that would be great too, but can't quite figure out how to get that to work and wait for it in code. I want something like this. //I need something like this to work, and then get result back to use the geometry
AddOverlayTool adt = new AddOverlayTool(RowLine);
Polyline mPolyline = await adt.startSketch();
//Then I use that line to get the angle and do more work
if (!mPolyline.IsNullOrEmpty())
... View more
04-19-2018
02:28 PM
|
0
|
5
|
1269
|
|
POST
|
That worked great. Here is my updated code. I do this as I fear someone will be working in test and mistakenly load a map that points to production. This will ensure that the Test URL gets loaded instead of the production URL. I know our environment on the ActiveMapViewChanged event and make sure the loaded layers have the correct url based on the environment we are in. FeatureLayer LoadLayer = GetBasicFeaturLayer(entry.Key) as FeatureLayer;
if (LoadLayer == null) //Not already on the Map, load it
{
Uri uri = new Uri(NEWurl + entry.Value);
LoadLayer = LayerFactory.Instance.CreateFeatureLayer(uri, MapView.Active.Map, position);
}
else //We need to check the datasource of the loaded map and make sure it is updated to correct path based on environment
{
CIMStandardDataConnection dataConnection = LoadLayer.GetDataConnection() as CIMStandardDataConnection;
string urlMatch = "URL=" + NEWurl;
if (!dataConnection.WorkspaceConnectionString.Contains(urlMatch))
{
dataConnection.WorkspaceConnectionString = urlMatch;
LoadLayer.SetDataConnection(dataConnection);
}
}
... View more
04-16-2018
12:11 PM
|
0
|
0
|
1556
|
|
POST
|
I have about 14 feature layers, and i want to be able to switch our the Data Source URL from my code if it does not match the environment I am in. i would even settle for being able to just drop and re-add the layer if it has a different datasource then the one I want to load. Unfortunately, I cant seem to find how to Get/Set this value for a layer? I attached a screen shot of what I want to get/set FeatureLayer LoadLayer = GetBasicFeaturLayer(entry.Key) as FeatureLayer;
if (LoadLayer == null) //Not already on the Map, load it
{
Uri uri = new Uri(NEWurl + entry.Value);
LoadLayer = LayerFactory.Instance.CreateFeatureLayer(uri, MapView.Active.Map, position);
}
else
{
//HERE
//HERE
//I need to check if the layer that already exists on the map has a different datasource
//IF CURRENT URL != NEWurl
//If Not equal, then remove existing layer or some how redo the data source
//Here is the remove logic, but I would rather rename, but I first need to find out if datasouce is different
RemoveBasicFeaturLayer(entry.Key);
Uri uri = new Uri(NEWurl + entry.Value);
LoadLayer = LayerFactory.Instance.CreateFeatureLayer(uri, MapView.Active.Map, position);
}
... View more
04-13-2018
01:41 PM
|
0
|
2
|
2293
|
|
POST
|
When i create a new feature in arcmap, the CreatedBy, CreatedDateUTC, UpdatedBy, and UpdatedDateUTC all say null in the attribute editor. I am using a feature service. This was not the case in 2.1.0. Refreshing the map (Blue Circle) is the only way to pull this information in. I am using onRowCreate and onRowChange events in the Module, but the value doesn't seem to be on the initial argument like it was for 2.1.0. It happens out of the box as well as in my code here below. protected static async void onRowCreateEvent(RowChangedEventArgs args)
{
long _updateOID = args.Row.GetObjectID();
//Get the layer of the selected item
FeatureClass newFC = (FeatureClass)args.Row.GetTable();
string updateItemName = newFC.GetDefinition().GetAliasName();
FeatureLayer firstFeatureLayer = FeatureServiceManagement.GetFeatureLayer(updateItemName);
//Load the inspector
await inspr.LoadAsync(firstFeatureLayer, _updateOID);
//These are all now NULL
string CreatedDateUTC = inspr["CreatedDateUTC"];
string CreatedBy = inspr["CreatedBy"];
string UpdatedDateUTC = inspr["UpdatedDateUTC "];
string UpdatedBy = inspr["UpdatedBy"];
}
... View more
04-11-2018
07:15 AM
|
0
|
0
|
469
|
|
POST
|
I feel this is a bug. I am still on 2.1.1, but I need a way for these values to be populated as they were in 2.1.0
... View more
04-11-2018
06:58 AM
|
0
|
0
|
504
|
|
POST
|
So, then I just need to know if a shape is a circle. If what you say is correct, that densify just adds more vertices, then is there some method to determine if the shape is a representation of a circle?
... View more
04-03-2018
06:06 AM
|
0
|
2
|
920
|
|
POST
|
I create circles in my project using the out of the box circle tool, but then I densify those circles immediately after they are created. But know I need to know if that densified shape that i created is a circle? Is there a way to get all the points of that densified polygon and see if they are all equidistant apart. This would tell me that the polygon is a densified circle.
... View more
04-02-2018
02:29 PM
|
0
|
4
|
1013
|
|
POST
|
So for a Configuration I had to do a work around to replace and add an item to the esri_mapping_selection2DContextMenu selection menu. I did this in the OnUpdateDatabase Override function of my ConfigurationManager.cs file. The RefID to my attribute editor, MyAttributeEditor, is set up in the config.daml controls section. But I had to add it here. The following worked for me to remove and add, but I would like to know how to use the OnCreateDaml override if possible. protected override void OnUpdateDatabase(XDocument database)
{
// select all elements that are tabs
var nasp = database.Root.Name.Namespace;
var menuElements = from seg in database.Root.Descendants(nasp + "menu") select seg;
foreach (var menuElement in menuElements)
{
var id = menuElement.Attribute("id");
if (id != null && id.Value.StartsWith("esri_mapping_selection2DContextMenu"))
{
//Remove the OOB Attribute Editor Item
var buttonElements = from seg in menuElement.Descendants(nasp + "button") select seg;
foreach (var butElement in buttonElements)
{
var refID = butElement.Attribute("refID");
if (refID != null && refID.Value.StartsWith("esri_editing_ShowAttributes"))
{
butElement.Remove();
break;
}
}
//Add My Attribute Editor
XElement xe = new XElement("button");
XAttribute attRefID = new XAttribute("refID", "MyAttributeEditor");
XAttribute attSeparator = new XAttribute("separator", "true");
XAttribute attInsert = new XAttribute("insert", "after");
xe.Add(attRefID);
xe.Add(attSeparator);
xe.Add(attInsert);
menuElement.Add(xe);
}
}
}
... View more
03-27-2018
12:09 PM
|
0
|
1
|
4350
|
|
POST
|
So how is that accomplished. Do I have to Navigate the database elements and add the element to the esri_mapping_selection2DContextMenu somehow? Or can i reload the .daml here somehow?
... View more
03-27-2018
11:35 AM
|
0
|
0
|
4350
|
|
POST
|
I am actually using a configuration not an addin. So maybe that has something to do with it? Do I need to make sure something loads that is not. Right now my configuration only loads a small subset of all of the Pro Tools.
... View more
03-27-2018
06:03 AM
|
0
|
2
|
4350
|
|
POST
|
I must be missing something. I can't even add an ESRI reference to the Context menu, let alone my own button. This should put the save button in the context menu for the Selection <updateModule refID="esri_mapping"> <menus> <updateMenu refID="esri_mapping_selection2DContextMenu"> <insertButton refID="esri_core_saveProjectButton" placeWith="esri_mapping_locateReverseGeocode" /> </updateMenu> </menus> </updateModule>
... View more
03-26-2018
02:10 PM
|
0
|
4
|
4350
|
|
POST
|
I have a button I created in my tool bar that opens a custom attribute form that I created. I would like to add this button to the right click menu of the selected feature context menu. So when one or more features is selected, and I right click, my Open Attribute Menu item will be on the list. In ArcObjects I was able to do this by adding it to the Command Bar for the Edit Tool menu. I was hoping that it would be this simple in ArcGIS Pro, or if I was able to do this in the DAML somehow. My initial efforts or simply adding a menu in the DAML and setting ContextMenu="True" and adding my button reference did not work. But i feel like I am missing something that might make this process quite easy as I do see contextMenu in the xsd for ArcGIS.Desktop.Framework.
... View more
03-26-2018
07:09 AM
|
0
|
10
|
6099
|
|
POST
|
Here is what i do in my code. I am sure there is a better way to get the path to your app.config, but here is what i do. i create a settings class that is used to retrieve all the values from the App.Config. I set it up once and I am able to call it from everywhere. In the below example I initialize the appconfig Configuration mConfig and create public procedures to retrieve the values using it and the App.Config. You can change the AppConfigpath below to match where the relative location in the output directory. Hope this helps. //APP.CONFIG
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<appSettings>
<!--Set the Environment-->
<add key="Environment" value="TR"/>
</appSettings>
</configuration>
//Settings Class used to retrieve values from App.Config
public static class Settings
{
private static Configuration mConfig;
static Settings()
{
initializeAppConfig();
MessageBox.Show(CurrentApplicationEnvironment);
}
//CurrentApplicationEnvironment
private static string _CurrentApplicationEnvironment;
public static string CurrentApplicationEnvironment
{
get
{
if (string.IsNullOrEmpty(_CurrentApplicationEnvironment))
{
_CurrentApplicationEnvironment = mConfig.AppSettings.Settings["Environment"].Value;
}
return _CurrentApplicationEnvironment;
}
}
const string appConfigPath = "App.Config";
private static void initializeAppConfig()
{
try
{
string executingAssemblyFqPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
executingAssemblyFqPath = (System.IO.Path.Combine(executingAssemblyFqPath, appConfigPath));
if (System.IO.File.Exists(executingAssemblyFqPath))
{
ExeConfigurationFileMap map = new ExeConfigurationFileMap();
map.ExeConfigFilename = executingAssemblyFqPath;
mConfig = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
}
}
catch (Exception e)
{
}
}
}
... View more
03-20-2018
07:54 AM
|
2
|
4
|
6316
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-23-2018 06:49 AM | |
| 1 | 08-02-2023 08:28 AM | |
| 1 | 01-03-2020 10:54 AM | |
| 1 | 11-30-2017 06:41 AM | |
| 1 | 08-20-2018 01:10 PM |
| Online Status |
Offline
|
| Date Last Visited |
10-22-2025
04:33 AM
|