POST
|
Hi, I am also trying to customize my legend. Your solution is to use destinationTextSymbol in controlling the text properties in the legend. Can you please elaborate a bit on this solution? The following is my code for creating a legend. But after that, I am confused on HOW and WHERE to insert CIMTextSymbol reference such as your destinationTextSymbol. Can you please help me with that? Thanks. Coordinate2D llLegend = new Coordinate2D(10, 10);
Coordinate2D urLegend = new Coordinate2D(100, 50);
Envelope leg_env = EnvelopeBuilder.CreateEnvelope(llLegend, urLegend);
LayoutElementFactory.Instance.CreateLegend(layout, leg_env, mfElm);
... View more
02-26-2021
09:16 AM
|
0
|
1
|
754
|
POST
|
The solution you provided creates a rectangle, which is good. So, the only way I can achieve my result is to create another polyTxtElm and overlay on top of that rectangle you provided. THIS IS NOT THE BEST SOLUTION, but does the job. // Create Rectangle using polygon //
CIMPolygonSymbol polySym = SymbolFactory.Instance
.ConstructPolygonSymbol(ColorFactory.Instance.WhiteRGB,
SimpleFillStyle.Solid);
GraphicElement polyTxtElm = LayoutElementFactory.Instance
.CreatePolygonGraphicElement(layout, poly);
var g = new CIMPolygonGraphic
{
Polygon = poly,
Symbol = polySym.MakeSymbolReference()
};
polyTxtElm.SetGraphic(g);
// Overlay Text over SAME polygon //
CIMStroke outline = SymbolFactory.Instance
.ConstructStroke(ColorFactory.Instance.BlackRGB, 0.5,
SimpleLineStyle.Solid);
polySym = SymbolFactory.Instance
.ConstructPolygonSymbol(ColorFactory.Instance.WhiteRGB,
SimpleFillStyle.Solid, outline);
CIMTextSymbol sym = SymbolFactory.Instance
.ConstructTextSymbol(polySym, 10, "Tahoma", "Bold");
sym.HorizontalAlignment = HorizontalAlignment.Center;
polyTxtElm = LayoutElementFactory.Instance
.CreatePolygonParagraphGraphicElement(layout,
poly, title, sym);
... View more
02-26-2021
08:55 AM
|
0
|
1
|
978
|
POST
|
1. I am trying to change the background of the rectangular area containing a text in ArcGIS Pro Layout. I am trying to figure out WHERE to insert WHAT in the following code to make that work. 2. The following code was my attempt to change the color of the envelope containing the text, but it actually changed the color of the text instead. var theLayout = await QueuedTask.Run<Layout>(() =>
{
//Set up a page
CIMPage newPage = new CIMPage
{
Width = 420,
Height = 297,
Units = LinearUnit.Millimeters
};
Layout layout = LayoutFactory.Instance.CreateLayout(newPage);
#region Table
// Caption
title = "CAPTION";
plyCoords = new List<Coordinate2D>();
plyCoords.Add(new Coordinate2D(286, 271));
plyCoords.Add(new Coordinate2D(286, 277));
plyCoords.Add(new Coordinate2D(400, 277));
plyCoords.Add(new Coordinate2D(400, 271));
poly = PolygonBuilder.CreatePolygon(plyCoords);
CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 0.5, SimpleLineStyle.Solid);
polySym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.WhiteRGB, SimpleFillStyle.Solid, outline);
sym = SymbolFactory.Instance.ConstructTextSymbol(polySym, 10, "Tahoma", "Bold");
sym.HorizontalAlignment = HorizontalAlignment.Center;
polyTxtElm = LayoutElementFactory.Instance.CreatePolygonParagraphGraphicElement(layout, poly, title, sym);
return layout;
});
... View more
02-25-2021
09:38 AM
|
0
|
3
|
1133
|
POST
|
Thanks for the suggestion. I shall look into the OnHidden() method as well. The problem was currently solved by overriding the OnShow() method. I think I will try out the OnHidden() method as well.
... View more
02-23-2021
07:48 AM
|
0
|
1
|
2019
|
POST
|
1. By "Dockpane closing", I meant to close the Dockpane of the Add-In. 2. Overriding the OnShow() method, as you have shown, solved the problem.
... View more
02-23-2021
07:47 AM
|
0
|
0
|
2019
|
POST
|
I am trying to figure out: a. How to reset the properties in the dockpane when it closes [edited: or close an Add-In]. The following code below with "SaveDirectory" is initialized when I open the dockpane for the first time, then even after closing it and opening several different projects, the value of "SaveDirectory" does not change. How do I do that? b. I thought of resetting the value inside "UninitializeAsync()" method, but I guess "UninitializeAsync()" method is not used for that. Thanks. Kenny namespace Test
{
internal class TestDockPaneViewModel : DockPane
{
private string _saveDirectory;
/// <summary>
/// Default Directory to save all user input data.
/// </summary>
public string SaveDirectory
{
get { return _saveDirectory; }
set { _saveDirectory = value; NotifyPropertyChanged(() => SaveDirectory); }
}
/// <summary>
/// Constructor
/// </summary>
protected TestDockPaneViewModel()
{
SaveDirectory = System.IO.Directory.GetCurrentDirectory();
}
/// <summary>
/// Called when the pane is uninitialized.
/// </summary>
protected async override Task UninitializeAsync()
{
// Reset Default Save Directory when dockpane closes //
SaveDirectory = null;
await base.UninitializeAsync();
}
}
... View more
02-23-2021
06:11 AM
|
0
|
9
|
2068
|
BLOG
|
Hi Rich, Once again, thank you for you kind reply. Ah, I see. Joins are read-only. That makes sense. Coming from python to C#, I use alot of these processing tools. Now, I think it is a bad habit (because it is slow most of the time). Thank you for sharing an alternative (and better way) to perform this task. I shall definitely explore the low-level geodatabase routine and make it a habit to find similar alternatives for other routine geoprocessing tasks. Once again, many many thanks again. Kenny
... View more
04-07-2020
04:49 PM
|
0
|
0
|
1795
|
BLOG
|
Joining a table is easy. In ArcGIS Pro, you simply right-click a table, goto "Join and Relate" and then select "Add Join". This takes you to a Geoprocessing tool where you select the input join field and output join field and voila, your table is joined ! 1. But, when it comes to using the "management.AddJoin" with ExecuteToolAsync(), you actually end up with a new table with the two tables joined together: var argsAddJoin = gp.MakeValueArray("C:\\Project\\Sample_database.gdb\\Input_Table", "INPUT_ID", "Table_to_Join", "OUTPUT_ID", "KEEP_ALL"); var resultAddJoin = await gp.ExecuteToolAsync("management.AddJoin", argsAddJoin); string resultingJoinedTable= resultAddJoin.ReturnValue; 2. Then, if you want to recalculate a field in the input table, you would have used the following python code: // Calculate Field // arcpy.management.CalculateField("Resulting_Joined_Table", "Resulting_Joined_Table.FIELDNAME", "!Table_to_Join.FIELDNAME!", "PYTHON3", '', "TEXT") and expect to use the following code in C#: var argsCalculateField = gp.MakeValueArray("Resulting_Joined_Table", "Resulting_Joined_Table.FIELDNAME", "!Table_to_Join.FIELDNAME!", "PYTHON3", "", "TEXT"); var resultCalculateField = await gp.ExecuteToolAsync("management.CalculateField", argsCalculateField); But, this won't work. You actually have to reference the original input table that you had "wished to join" in as the input table's name: var argsCalculateField = gp.MakeValueArray("Resulting_Joined_Table", "Input_Table.FIELDNAME", "!Table_to_Join.FIELDNAME!", "PYTHON3", "", "TEXT"); await gp.ExecuteToolAsync("management.CalculateField", argsCalculateField);
... View more
04-07-2020
04:15 PM
|
1
|
4
|
2525
|
POST
|
Hi Rich, Thank you very much for your kind and prompt reply. It is very nice to know that such a feature will be available in the next release. Awesome ! Thank you for your script. I saw the snippet for opening a shapefile using "FileSystemDatastore" in the snippet section. But I could not find a way to use it to check for a shapefile. Thank you for sharing a simpler solution. This is really awesome! Many many thanks again ! Kenny
... View more
04-07-2020
09:08 AM
|
1
|
1
|
828
|
POST
|
I am trying find the best way to find the full path of a shapefile, which is open in the active map. Or in other words, I want to find a way to know if the feature layer in the active map is a shapefile or not. I "think" I saw it somewhere in the SDK snippets github pages, but I cannot track it now. Anyway, here is what I did: string SelectedShapefileLayer = "Some_feature_in_map"; string fcLocation = ""; // Location of feature layer: either a FGDB or a folder // string fcName = ""; // ACTUAL name of feature layer // await QueuedTask.Run(() => { var fcLyr = (FeatureLayer)MapView.Active.Map.FindLayers(SelectedFeatureLayer).First(); Uri fcURI = fcLyr.GetTable().GetDatastore().GetPath(); fcLocation = fcURI.LocalPath; fcName = fcLyr.GetTable().GetDefinition().GetName(); // Displayed name may not be ACTUAL name // }); string fcPath = ""; // Full path of feature layer // if (Path.GetExtension(fcLocation) == "") { // If feature layer is a shapefile // fcPath = Path.Combine(fcLocation, fcName + ".shp"); } else { // if feature layer is a FGDB feature class // fcPath = Path.Combine(fcLocation, fcName); } I would be grateful if anyone could help me find a better way to do this. Surely, there must be a better way. In the above code, I have assigned all feature layer WITHOUT an extension as a FGDB feature class, and others as a shapefile. I think that could run into trouble as well. Many thanks in advance. Kenny
... View more
04-07-2020
07:37 AM
|
0
|
3
|
908
|
POST
|
Hi Rich, Thank you very much for your kind and prompt reply. I will try to use the Subfields property and optimize my code. I shall post it as soon as I get time to code it. - Kenny
... View more
02-06-2020
08:01 AM
|
0
|
0
|
521
|
POST
|
Hi everyone, I want to extract all the rows of a specific field in a given table. This is how I am doing it. List<UInt32> outputList= new List<UInt32>(); // Query table await QueuedTask.Run(() => { using (Geodatabase curGDB = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(selectedGDB)))) using (Table table = curGDB.OpenDataset<Table>(selectedTable)) { QueryFilter qF = new QueryFilter { WhereClause = "OBJECTID > 0" }; using (RowCursor rc = table.Search(qF, false)) { while (rc.MoveNext()) { using (Row row = rc.Current) { outputList.Add(Convert.ToUInt32(row[selectedField])); } } } } }); My questions is: Is this a good way? Do I have to use "QueryFilter" and move through each row? Is there a better/optimum way? Many thanks in advance.
... View more
02-05-2020
12:33 PM
|
0
|
2
|
573
|
POST
|
Awesome ! Thanks ! Thank you for your detailed answer. That clears a lot of stuff for me. I had been reading all about these stuff, but I was not able to grasp the whole picture clearly. Your answer has probably taught me to be more careful while coding and has shown me how to improve them. Thanks to you, I know much more about why we should async and await. Thanks a lot !!
... View more
01-03-2020
03:53 PM
|
0
|
0
|
600
|
POST
|
I have removed the async and await functionalities from following code (copied from GeoprocessingExecuteAsync example) and it still works fine. My question is are they both correct (because i am not seeing any difference in the response of the system, i.e. with QueuedTask implementation, ArcGISPro is responsive in both cases? Many thanks in advance. The original code: protected override async Task<bool> OnSketchCompleteAsync(Geometry geometry) { var valueArray = await QueuedTask.Run(() => { var g = new List<object>() { geometry, }; // Creates a 8000-meter buffer around the geometry object // null indicates a default output name is used return Geoprocessing.MakeValueArray(g, null, @"8000 Meters"); }); await Geoprocessing.ExecuteToolAsync("analysis.Buffer", valueArray); return true; } and the modified code (async and await removed): protected override Task<bool> OnSketchCompleteAsync(Geometry geometry) { var something = QueuedTask.Run(() => { var g = new List<object>() { geometry, }; // Creates a 8000-meter buffer around the geometry object // null indicates a default output name is used var valueArray = Geoprocessing.MakeValueArray(g, null, @"8000 Meters"); Geoprocessing.ExecuteToolAsync("analysis.Buffer", valueArray); return true; }); return something; }
... View more
01-03-2020
12:24 PM
|
0
|
2
|
712
|
POST
|
Hi there, I have a question about ArcGIS Pipeline Referencing. Do we need to buy the SERVER version ArcGIS Pro or ArcGIS to use APR and its EVENT EDITOR? This will really help us in before deciding to buy ArcGIS Pro Desktop or Server. Thanks Kenny
... View more
01-25-2019
02:08 PM
|
0
|
1
|
306
|
Title | Kudos | Posted |
---|---|---|
1 | 04-07-2020 04:15 PM | |
1 | 04-07-2020 09:08 AM |
Online Status |
Offline
|
Date Last Visited |
04-06-2021
12:08 PM
|