Resize behavior of Scalebar

317
2
Jump to solution
06-25-2020 01:43 AM
Sai_PhaneendraPoludasu2
New Contributor III

How to set Resize Behavior of a scale bar through SDK. I can see this property can be set from UI and not sure how to do that through code. 

I have set the Division property and tried, if setting this value would set the resize behavior to "adjust width" by default. It doesn't. How to set Resize behavior ?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
UmaHarano
Esri Regular Contributor

Hi 

You can set the Resize behavior using the CIM Definition of the scale bar. In my example, I used a simple "Scale Line" type of scale bar. The CIM Definition you retrieve needs to be cast to the type of scale bar you are using.

QueuedTask.Run( () => {
        var lyt = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault().GetLayout();
        Element scaleBar = lyt.FindElement("Scale Bar") as Element;
        var scaleBarDefn = scaleBar.GetDefinition() as CIMScaleLine;
        //Enums        
        scaleBarDefn.FittingStrategy = ScaleBarFittingStrategy.AdjustDivisionAndDivisions; 
        scaleBar.SetDefinition(scaleBarDefn);
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Thanks!

Uma

View solution in original post

0 Kudos
2 Replies
UmaHarano
Esri Regular Contributor

Hi 

You can set the Resize behavior using the CIM Definition of the scale bar. In my example, I used a simple "Scale Line" type of scale bar. The CIM Definition you retrieve needs to be cast to the type of scale bar you are using.

QueuedTask.Run( () => {
        var lyt = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault().GetLayout();
        Element scaleBar = lyt.FindElement("Scale Bar") as Element;
        var scaleBarDefn = scaleBar.GetDefinition() as CIMScaleLine;
        //Enums        
        scaleBarDefn.FittingStrategy = ScaleBarFittingStrategy.AdjustDivisionAndDivisions; 
        scaleBar.SetDefinition(scaleBarDefn);
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Thanks!

Uma

0 Kudos
Sai_PhaneendraPoludasu2
New Contributor III

Thanks Uma Harano‌. I am using a Double Fill Scale bar, only change I made is that and it worked.

0 Kudos