POST
|
Hi, Thanks for the code and the error string. I don't see any problems with your feature class creation code nor the way you are constructing the renderer for the layer. But I do have concerns about the CreateCurrentImageryFootprintLayerDefinition method and how / where you are using the return CIMFeatureLayer value. - if at all. Just to confirm that you are creating the layer using the LayerFactory CreateLayer method (https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic76685.html) Here's an example of adding a feature class to a map // get the fc
var fc = geodatabase.OpenDataset<FeatureClass>(name);
CIMRGBColor fillColor = new() { R = 0, G = 0, B = 255, Alpha = 0 };
CIMRGBColor outlineColor = new() { R = 0, G = 0, B = 255 };
CIMSolidStroke solidStroke = new() { Color = outlineColor, Width = 1.5 };
var polySymbol = ArcGIS.Desktop.Mapping.SymbolFactory.Instance.ConstructPolygonSymbol(fillColor, SimpleFillStyle.Null, solidStroke);
var rd = new ArcGIS.Desktop.Mapping.SimpleRendererDefinition()
{
Label ="Imagery footprints",
SymbolTemplate = polySymbol.MakeSymbolReference()
};
var fLayerParams = new ArcGIS.Desktop.Mapping.FeatureLayerCreationParams(fc)
{
Name = "Current Imagery Footprints",
RendererDefinition = rd,
};
var fLayer = ArcGIS.Desktop.Mapping.LayerFactory.Instance.CreateLayer<ArcGIS.Desktop.Mapping.FeatureLayer>(fLayerParams, ArcGIS.Desktop.Mapping.MapView.Active.Map); We don't have every property available to set on the FeatureLayerCreationParams so if you need to update additional properties after the layer has been added then add the following // update the rest of the layer properties as necessary
var fLayerDef = fLayer.GetDefinition() as CIMFeatureLayer;
// fLayerDef.ShowLegends = false; // this causes the warning
fLayerDef.Selectable = false;
fLayerDef.Description = "Current Custom Imagery Footprints";
fLayerDef.CustomProperties = new CIMStringMap[] { new() { Key = "IsCustomLayer", Value = "True" } };
fLayer.SetDefinition(fLayerDef); In your particular case it appears that the ShowLegends is the property that is causing the Symbology Pane to display the warning. I believe that this should be true. If you wish to hide the symbol in the TOC then the best way to do that is to use the layer SetExpanded method (https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic11772.html) Let me know if you have any additional questions. Narelle
... View more
a week ago
|
0
|
1
|
59
|
POST
|
Hi, Are you able to post the error that displays at the top of the Symbology pane. Also any code with your symbology generation and the way the feature class is generated in the memory geodatabase. Thanks Narelle
... View more
a week ago
|
0
|
3
|
85
|
POST
|
Hi Mody, Use the Inspector from the Template object to provide temporary override values for field values prior to calling the EditOperation.Create method. Here is an example // perform the creation
var op = new EditOperation();
op.Name = "Create feature";
// use template default field values
op.Create(template, geometry);
// to modify default template properties
var insp = template.Inspector;
insp["City"] = "Perth";
// create with the modified fields and a different geometry
op.Create(template, geometry2);
// reset the template fields back to original defaults
insp.Cancel();
// execute the operation
bool result = op.Execute();
... View more
01-12-2025
03:31 PM
|
0
|
0
|
157
|
POST
|
Hi Barbara, Unfortunately as you mention, we currently do not have those methods in the SDK for the ImageServiceLayer object. I will add an issue to include it for the 3.5 release. Thanks for bringing this gap to our attention. Narelle
... View more
01-09-2025
05:28 PM
|
0
|
0
|
85
|
POST
|
Hi,
So I've dug a bit deeper over the last day and know a bit more about what is going on. And why the EditOperation.Create is not working correctly for dimension features. As the documentation states, a dimension feature consists of 4 points (the begin, end points, the dimension line point and the text point). These points are stored as x,y fields in the feature class. The polygon shape of the dimension is the bounding rectangle of these points and it should be calculated when the feature is created or modified. In the case of the creation; we supply the points as a mutlipoint geometry, however the calculation to generate the bounding polygon from this point information and the other attributes is not being performed and the shape value of the created feature is null (which is why it is not displayed). As you've seen if you make any modifications to the point coordinate attributes or other attributes, the dimension becomes visible - because it's polygon shape has been generated.
So basically we need to look into a way to force this shape generation to occur on a creation as the software is not working as it should.
Having said all of that, lets deal with the original question you had first - how to move a dimension feature.
Assuming we're dealing with a well-defined dimension feature (ie one that is displaying correctly); you should be able to use EditOperation.Move function. For example
// assuming on the MCT
// get a dim layer
DimensionLayer dimLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<DimensionLayer>().FirstOrDefault();
var selection = dimLayer.GetSelection();
var oids = selection.GetObjectIDs();
var oid = oids.FirstOrDefault();
var op = new EditOperation();
op.Name = "Move dimension";
op.Move(dimLayer, oid, 10, 0); // move it in the x direction only
var success = op.Execute();
Alternatively you can modify the BeginX, BeginY, EndX, EndY, DimX, DimY and TextX and TextY fields individually if you'd rather using the EditOperation.Modify method and an Inspector class. Here's an example snippet of this
// assuming on the MCT
// get a dim layer
DimensionLayer dimLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<DimensionLayer>().FirstOrDefault();
var selection = dimLayer.GetSelection();
var oids = selection.GetObjectIDs();
var oid = oids.FirstOrDefault();
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
insp.Load(dimLayer, oid);
// get all the coordinates
Double.TryParse(insp["BeginX"].ToString(), out double BeginX);
Double.TryParse(insp["BeginY"].ToString(), out double BeginY);
Double.TryParse(insp["EndX"].ToString(), out double EndX);
Double.TryParse(insp["EndY"].ToString(), out double EndY);
Double.TryParse(insp["DimX"].ToString(), out double DimX);
Double.TryParse(insp["DimY"].ToString(), out double DimY);
Double.TryParse(insp["TextX"].ToString(), out double TextX);
Double.TryParse(insp["TextY"].ToString(), out double TextY);
// modify the x positions
BeginX += 10;
EndX += 10;
DimX += 10;
// assign the new values to the fields
insp["BeginX"] = BeginX;
insp["EndX"] = EndX;
insp["DimX"] = DimX;
// do the edit
var op = new EditOperation();
op.Name = "Modify dimension";
op.Modify(insp);
var success = op.Execute();
You can use any of the other EditOperation.Modify overloads as appropriate. The key is that you need to modify the x,y fields of the points and not the shape field itself. Despite supplying a mtulipoint to the EditOperation.Create to generate a dimension feature we cannot use a multipoint within an EditOperation.Modify to modify the geometry.
I've verified that both of these scenarios work correctly at 3.4. Can you try and see if they work for you at 2.9.
As for the creation, you were on the correct path with regards to the DimensionFeature. and the SetDimensionShape method. This is the call we have to make to force the shape generation to occur as the workaround for this bug. The way to use this method within an EditOperaiton is to hook into the RowCreated event. Here's a button that is based on your code snippet with the row event and the SetDimensionShape method.
protected override void OnClick()
{
var CurrentMap = MapView.Active.Map;
DimensionLayer dimLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<DimensionLayer>().FirstOrDefault();
QueuedTask.Run(() =>
{
var sr = dimLayer.GetSpatialReference();
// use layer selection to get an oid
var selection = dimLayer.GetSelection();
var oids = selection.GetObjectIDs();
var oid = oids.FirstOrDefault();
// load inspector with the feature
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
insp.Load(dimLayer, oid);
// get the x,y coords of the the dimension points
Double.TryParse(insp["BeginX"].ToString(), out double BeginX);
Double.TryParse(insp["BeginY"].ToString(), out double BeginY);
Double.TryParse(insp["EndX"].ToString(), out double EndX);
Double.TryParse(insp["EndY"].ToString(), out double EndY);
Double.TryParse(insp["DimX"].ToString(), out double DimX);
Double.TryParse(insp["DimY"].ToString(), out double DimY);
Double.TryParse(insp["TextX"].ToString(), out double TextX);
Double.TryParse(insp["TextY"].ToString(), out double TextY);
// create a new multipoint for updated dimension points
var DimPoints = new List<MapPoint>()
{ MapPointBuilderEx.CreateMapPoint(BeginX + 10, BeginY, 0, sr),
MapPointBuilderEx.CreateMapPoint(EndX + 10, EndY, 0, sr),
MapPointBuilderEx.CreateMapPoint(DimX + 10, DimY, 0, sr) };
var UpdatedGeom = MultipointBuilderEx.CreateMultipoint(DimPoints, AttributeFlags.AllAttributes);
// attributes
var Attributes = new Dictionary<string, object>() { { "StyleID", 0 },
{ "DimType", 0 },
{ "BeginX", DimPoints[0].X }, { "BeginY", DimPoints[0].Y },
{ "EndX", DimPoints[1].X }, { "EndY", DimPoints[1].Y },
{ "DimX", DimPoints[2].X }, { "DimY", DimPoints[2].Y } };
// subscribe to the RowCreatedEvent
// do this as close as possible to the EditOperation to
// minimize the time that we are monitoring the creates
var table = dimLayer.GetTable();
SubscriptionToken token = ArcGIS.Desktop.Editing.Events.RowCreatedEvent.Subscribe(OnRowCreated, table);
// wrap in a try/catch/finally to ensure that we can unsubscribe
// if there is a failure
bool success = false;
var Op = new EditOperation(); Op.Name = "Test";
try
{
Op.Create(dimLayer, UpdatedGeom, Attributes);
success = Op.Execute();
}
catch (Exception ex)
{
}
finally
{
// unsubscribe
if (token != null)
ArcGIS.Desktop.Editing.Events.RowCreatedEvent.Unsubscribe(token);
}
if (!success)
{
throw new Exception(Op.ErrorMessage);
}
});
}
private void OnRowCreated(ArcGIS.Desktop.Editing.Events.RowChangedEventArgs args)
{
var row = args.Row;
if (row is ArcGIS.Core.Data.Mapping.DimensionFeature df)
{
try
{
// force the dimension polygon shape generation
// a simple get and then set will accomplish this
var shape = df.GetDimensionShape();
df.SetDimensionShape(shape);
}
catch (Exception ex)
{
}
}
}
Again, this works on 3.4; can you verify that it will work for you on 2.9.
I've entered an issue into our backlog to fix the dimension creation. In the meantime, I'll get this workaround documented on the Editing Dimensions concept page. Thanks for drawing our attention to this; unfortunately we don't have too many dimension feature SDK users.
Let me know if you have any additional questions or run into any problems with the snippets I've posted.
Narelle
... View more
11-13-2024
07:12 PM
|
0
|
0
|
375
|
POST
|
Hi Billy,
I am looking at this right now and can confirm that custom dimension construction tools aren't working in the current release. I am trying to find you a work around. In the mean time can you tell me what version of the software you are using.
But from your first sentence it seems like you are also interested in how to move an existing dimension feature. Are you using the EditOperation.Modify operation and modifing the individual x,y coordinates of the BeginX, BeginY, EndX, EndY, DimX, DimY and TextX and TextY fields.?
Thanks
Narelle
... View more
11-12-2024
04:59 PM
|
0
|
2
|
396
|
POST
|
Kerry,
Sorry for the confusion. I would have to qualify my above statement with regards to determining when a button / command has finished executing; is that it depends on the command.
In the example in the documentation, the command "esri_mapping_createBookmark" displays a modal dialog and performs some action on the ok button.
The command in your example "esri_editing_DivideCommand" activates the divide tool and displays a UI in a dockpane. This is not a modal dialog as tools very often require some interaction with the map. The divide command at this point has finished executing. It is the divide tool and the dockpane UI that actually controls the divide operation. The only way to know when the user has finished interacting with the UI and executed the divide edit is to use the edit events. .
Hope this helps clarify things a bit.
Narelle
... View more
11-12-2024
04:34 PM
|
0
|
1
|
301
|
POST
|
Hello,
There is no way to determine when a button has finished executing like you're attempting to do. However when it comes to edit operations, you can determine when an edit has occurred by using the edit events. See this documentation. https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-Editing#edit-events
In your case you would need to subscribe to the row Events to determine when the Divide operation has completed and add your custom attribute updates within that event.
Narelle
... View more
11-10-2024
05:59 PM
|
0
|
3
|
322
|
POST
|
Hello,
Here is a sample of the expression that can be used to map field values between two features or rows with the EditOperation.TransferAttributes function.
return { "ADDRESS" : $sourceFeature['ADDRESS'], "IMAGE" : $sourceFeature['IMAGE'], "PRECINCT" : $sourceFeature['PRECINCT'], "WEBSITE" : $sourceFeature['WEBSITE'], "ZIP" : $sourceFeature['ZIP'] }
Here's an example of a simple button that will transfer attributes from a source feature (oid 1) in the Police Stations layer to a destination feature (oid 2) in the same layer
protected override void OnClick()
{
var layer = MapView.Active.Map.GetLayersAsFlattenedList().FirstOrDefault(l => l.Name == "Police Stations");
if (layer == null)
return;
string expression = "return {\r\n " +
"\"ADDRESS\" : $sourceFeature['ADDRESS'],\r\n " +
"\"IMAGE\" : $sourceFeature['IMAGE'],\r\n + " +
"\"PRECINCT\" : $sourceFeature['PRECINCT'],\r\n " +
"\"WEBSITE\" : $sourceFeature['WEBSITE'],\r\n " +
"\"ZIP\" : $sourceFeature['ZIP']\r\n " +
"}";
QueuedTask.Run(() =>
{
var op = new EditOperation();
op.Name = "Transfer atts";
op.TransferAttributes(layer, 1, layer, 2, expression);
var success = op.Execute();
});
}
I'll make sure the documentation for the function is updated. Let me know if you have any additional questions.
Narelle
... View more
11-10-2024
05:51 PM
|
0
|
0
|
147
|
POST
|
Hi Joe,
I think the property you're looking for is part of the CIM definition of the template object. Each EditingTemplate / EditingRowTemplate has a definition which is a CIMRowTemplate. CIMRowTemplate inherits from CIMBasicRowTemplate. There is a RequiredFields property on the CIMBasicRowTemplate object (https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic74601.html). This is different from the property used for setting default values (which is CIMBasicRowTemplate.DefaultValues).
Narelle
... View more
10-16-2024
09:05 PM
|
0
|
1
|
254
|
POST
|
Hi Dominic,
Unfortunately we do not have the Smooth function available in the Geometry or Editing APIs as you've pointed out. I've added an issue to have it added to the Geometry API on the GeometryEngine object for the next release. This will be the 3.5 release as we are in the final stages of 3.4 right now which is due to be released shortly.
Narelle
... View more
09-29-2024
06:22 PM
|
0
|
1
|
488
|
POST
|
Hello, An issue has been created and assigned to the development team. It s currently in the near-term queue, but I do not have any other timeline information on this.
... View more
08-27-2024
04:04 PM
|
0
|
0
|
265
|
POST
|
Hello, Thank you for reporting this. Internally we also recently identified this same issue with the RowHandle object and how it is used within the EditOperation object. The Create and Delete operations with regards to relationships is one of these scenarios where some gaps in functionality exist. As you mention if the RowHandle is defined using a MapMember and objectID pair then the EditOperation Delete relationship method will work correctly. Unfortunately it will not work if the rowHandle is defined using a Row (or with a Table/FeatureClass and objectID pair). These bugs have been fixed and will be available in the 3.4 release of the software. Sorry for any inconvenience. Narelle
... View more
08-08-2024
09:44 PM
|
1
|
0
|
226
|
POST
|
Hello, Thanks for bring this bug to our attention. This will be fixed for the Pro 3.4 release.
... View more
07-18-2024
04:46 PM
|
1
|
0
|
277
|
POST
|
Hi Grzegorz, This bug was found and logged too late to be resolved in the 3.3 release. It is currently targeted to be fixed for ArcGIS Pro 3.4. Narelle
... View more
07-02-2024
10:24 PM
|
0
|
0
|
440
|
Title | Kudos | Posted |
---|---|---|
1 | 08-08-2024 09:44 PM | |
1 | 07-18-2024 04:46 PM | |
1 | 06-04-2024 07:18 PM | |
4 | 05-27-2024 09:22 PM | |
1 | 02-12-2019 08:59 AM |
Online Status |
Online
|
Date Last Visited |
7 hours ago
|