Hi,
I want to change file name and path programatically while exporting layout. Is there any way to capture export layout button event and change properties before starting process? or access export layout pane and modify values ?
Any help would be appreciated,
Prashant
Solved! Go to Solution.
You have to change the name of the Layout. I used this snippet below in a button to change the Layout name, which in turn is then used as the default file name. Just make sure that you don't use invalid file name characters (like ':').
protected override async void OnClick()
{
Map map = null;
await QueuedTask.Run(() =>
{
var layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(i => i.Name.Equals ("layout", StringComparison.OrdinalIgnoreCase));
if (layoutItem != null)
{
var layout = layoutItem.GetLayout();
var defLayout = layout.GetDefinition();
var now = DateTime.Now.TimeOfDay;
defLayout.Name = $@"msecs - {now.TotalMilliseconds}";
layout.SetDefinition(defLayout);
}
});
}
Hi @PrashantKirpan ,
Quick question...how good is your Python?
The best way to tackle this would be to write your own tool/script.
https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/layout-class.htm
That way you can set it to pull the name from, say the name of the current map and use it as the name of the output file.
Hope this helps,
Thanks,
Michael
Hi MichaelBoyce,
I'm good in python but I was trying to avoid rebuilding same export layout UI for just file name.
If there is no way to access export panel or event then I'll create own tool.
Thanks for the reply.
Prashant
You have to change the name of the Layout. I used this snippet below in a button to change the Layout name, which in turn is then used as the default file name. Just make sure that you don't use invalid file name characters (like ':').
protected override async void OnClick()
{
Map map = null;
await QueuedTask.Run(() =>
{
var layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(i => i.Name.Equals ("layout", StringComparison.OrdinalIgnoreCase));
if (layoutItem != null)
{
var layout = layoutItem.GetLayout();
var defLayout = layout.GetDefinition();
var now = DateTime.Now.TimeOfDay;
defLayout.Name = $@"msecs - {now.TotalMilliseconds}";
layout.SetDefinition(defLayout);
}
});
}