how to get the connected attribute rotation field of a layer in pro SDK

3142
3
Jump to solution
03-18-2016 10:30 AM
AlexanderGray
Occasional Contributor III

I am trying to make a custom point construction tool with a line geometry.  I want to take the angle of the line and pass it to the field for which the rotation is set, if rotation is set.

In pro interface,

I go to my point layer

I open the symbology tab (unique value renderer)

I go to review connected attributes

Rotation is set to a field

I a custom construction tool, from the currentTemplate property I can get the layer.  I have been navigating up and down the API reference but I haven't figured out how to get to the connected attribute for rotation.

Any hint would help

0 Kudos
1 Solution

Accepted Solutions
ThomasEmge
Esri Contributor

Alexander,

the information is stored as part of the renderer which is part of the layer. The way this information is stored is part of the CIM (cartographic information model).

Please take a look at this code snippet to retrieve the information:

var featureLayer = ActiveMapView.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
QueuedTask.Run(() =>
{
    var cimRenderer = featureLayer.GetRenderer() as CIMUniqueValueRenderer;
    var cimRotationVariable = cimRenderer.VisualVariables.OfType<CIMRotationVisualVariable>().FirstOrDefault();
    var rotationInfoZ = cimRotationVariable.VisualVariableInfoZ;
    var rotationExpression = rotationInfoZ.Expression; // this expression stores the field name
});

View solution in original post

0 Kudos
3 Replies
ThomasEmge
Esri Contributor

Alexander,

the information is stored as part of the renderer which is part of the layer. The way this information is stored is part of the CIM (cartographic information model).

Please take a look at this code snippet to retrieve the information:

var featureLayer = ActiveMapView.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault();
QueuedTask.Run(() =>
{
    var cimRenderer = featureLayer.GetRenderer() as CIMUniqueValueRenderer;
    var cimRotationVariable = cimRenderer.VisualVariables.OfType<CIMRotationVisualVariable>().FirstOrDefault();
    var rotationInfoZ = cimRotationVariable.VisualVariableInfoZ;
    var rotationExpression = rotationInfoZ.Expression; // this expression stores the field name
});
0 Kudos
AlexanderGray
Occasional Contributor III

Thanks Thomas that is great.  I am new to ArcGIS Pro so I am still getting my feet wet.

I am surprise it is the VisualVariableInfoZ since I am dealing with a 2D map...  I guess it is around the Z axis which protrudes from the map...

0 Kudos
ThomasEmge
Esri Contributor

Correct, the view understanding for Pro has been unified such that the code for 2D and 3D is essentially the same or very similar.

For more information please take a look at the concept documentation for map exploration ProConcepts Map Exploration · Esri/arcgis-pro-sdk Wiki · GitHub

0 Kudos