POST
|
While searching for more answers I found this: https://community.esri.com/t5/arcgis-pro-questions/arcpy-mp-layerfile-layer-filename-hangs/td-p/1217980. This fits our situation exactly. The arcpy.env.workspace needs to be pointed to the correct .sde file. However, the instance in the connection properties of layers within the .lyr must match the instance found in the .sde file or the script will hang when trying to instantiate a LayerFile. This gets messy to say the least. I'll keep pecking away at it.
... View more
08-01-2023
01:17 PM
|
0
|
0
|
286
|
POST
|
I think that's a method on the LayerFile class. I can't get the instantiation of the class to happen so I can't get that far. I'm using the first code sample and it dies on the lyrFile = arcpy.mp.LayerFile() line. I've checked to see if the file in my example above is a valid layer file and it opens up in both ArcMap 10.6.1 and ArcGIS Pro. It's nothing terribly exciting - address points with an transparent symbol and labeling turned on.
... View more
08-01-2023
10:59 AM
|
0
|
0
|
291
|
POST
|
I am trying to write a script to convert .lyr files generated with ArcGIS 10.6.1 to ArcGIS Pro 3.0 .lyrx files in the Pro flavored version of ArcPy. In the documentation for the LayerFile class it says that it provides access to .lyr files. When I try this: lf = arcpy.mp.LayerFile(r'M:\Production\Layerfile\Address\House Numbers.lyr') It never returns and just hangs. Is the documentation out of date and you can no longer access .lyr files at 3.0? Is there a piece that I'm missing? Thanks, Scott
... View more
08-01-2023
06:54 AM
|
0
|
3
|
329
|
POST
|
I am building a comboBox in the ribbon that I would like to use to select a feature based on an attribute value. I have successfully queried the table that holds my attribute values and added them to the comboBox. There are approximately 17,000 unique values in this list. When trying to use the comboBox it is painfully slow. Is there something that I am missing or is there a maximum limit to the number of values this comboBox can effectively handle? Or, have I missed the boat completely and I'm trying to use the comboBox control in a way that it was not intended? <comboBox id="LOJICTools_ComboBoxFindStreet" isEditable="false" isTextSearchEnabled="true" rows="10" caption="Find Street:" className="ComboBoxFindStreet" itemWidth="140" extendedCaption="Extended Caption" isReadOnly="false" resizable="true">
<tooltip heading="LOJIC Tools Find Street">
Allows the user to zoom to any street in Jefferson County.<disabledText />
</tooltip>
</comboBox> I am using the following to populate the comboBox: await QueuedTask.Run(() =>
{
TableDefinition pTD = sifTable.GetDefinition();
Field stNameField = pTD.GetFields().First(x => x.Name.Equals("ROADNAME"));
StatisticsDescription pSD = new StatisticsDescription(stNameField, new List<StatisticsFunction> { StatisticsFunction.Count });
TableStatisticsDescription pTSD = new TableStatisticsDescription(new List<StatisticsDescription> { pSD });
pTSD.GroupBy = new List<Field>() { stNameField };
pTSD.OrderBy = new List<ArcGIS.Core.Data.SortDescription>() { new ArcGIS.Core.Data.SortDescription(stNameField) };
IReadOnlyList<TableStatisticsResult> statResults = sifTable.CalculateStatistics(pTSD);
foreach (TableStatisticsResult result in statResults)
{
if (!Regex.IsMatch(result.GroupBy[0].Value.ToString(), @"^[0-9]+$"))
Add(new ComboBoxItem(result.GroupBy[0].Value.ToString()));
}
_isInitialized = true;
}); Thanks!
... View more
03-28-2022
07:02 AM
|
0
|
1
|
266
|
POST
|
Was this ever resolved? If so, please share how that was accomplished.
... View more
09-09-2021
11:39 AM
|
0
|
0
|
94
|
POST
|
We have a named user that we intend to use as our user to authorize pro (and consequently Python 3) while running several dozen overnight scheduled tasks written using ArcPy. The scheduled tasks are being run by the Windows Scheduled Task app. We have a domain user set up to run the scheduled tasks for us. I logged in to the machine yesterday and then in to ArcGIS Pro. Using our named user I was able to set ArcGIS Pro running in offline mode and checked out a license. This morning I logged in with our domain user to check the tasks and I was unable to start ArcGIS Pro. The error I get is "The number of licenses assigned to users exceeds the number of licenses available in your organization." I checked with our organizations admin and he verified that we have licenses available. Currently I am unable to get past this error message to undo the off-line mode set up that we did yesterday and our scheduled tasks fail with a License Not Initialized error. Has anyone seen this before? Thanks!
... View more
06-25-2021
08:22 AM
|
0
|
1
|
526
|
POST
|
I now have it working. Thank you for pointing me in the right direction! I had tried using Marshal.ReleaseCOMObject to no avail before. The Stack Overflow post you referenced mentioned explicitly calling Garbage Collection and then waiting for it to complete. Specifically these two lines: GC.Collect();
GC.WaitForPendingFinalizers(); I placed those between the mapDocument.Close() and the mapDocument.Open() and it worked - at least in my test app. I'm gong to swtich back over to the project i"m working and and see if it works there. Thanks again!!
... View more
02-25-2021
06:53 AM
|
0
|
0
|
565
|
POST
|
Here is the scenario. I open an MXD using IMapDocument.Open. This MXD contains layers that read from our 10.2.1 Enterprise Geodatabase. I do some operation and then close the MapDocument using IMapDocument.Close(). I open another MXD that has layers from the same 10.2.1 Enterprise Geodatabase immediately thereafter and do a similar process. This time the process fails because it can't get the FeatureClass from the FeatureLayer. I have created a small console app to demonstrate the problem. I am currently using ArcObjects 10.6.1. If you put a breakpoint at the line mapDocument2.Close() and check the value of FeatureClass on FL2 it returns as null. What have I missed here? using ESRI.ArcGIS.esriSystem;
using System;
using ESRI.ArcGIS.Carto;
using System.Runtime.InteropServices;
namespace TestApp
{
class Program
{
private static LicenseInitializer m_AOLicenseInitializer = new TestApp.LicenseInitializer();
[System.Runtime.InteropServices.DllImport("user32")]
public static extern int GetDesktopWindow();
[STAThread()]
static void Main(string[] args)
{
//ESRI License Initializer generated code.
m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeAdvanced },
new esriLicenseExtensionCode[] { });
//ESRI License Initializer generated code.
//Do not make any call to ArcObjects after ShutDownApplication()
IMapDocument mapDocument = new MapDocumentClass();
mapDocument.Open(@"\\pc.lojic.local\files\ArcGIS\10.6.1\Desktop\Development\Msd\Atlases\templates\forcemaincover.mxd");
IActiveView pAV = (IActiveView)mapDocument.PageLayout;
pAV.Activate(GetDesktopWindow());
IFeatureLayer pFL = FindLayer(mapDocument.ActiveView.FocusMap, "ForceMains");
Console.WriteLine(pFL.Name);
pFL = null;
pAV.Deactivate();
pAV = null;
mapDocument.Close();
mapDocument = null;
IMapDocument mapDocument2 = new MapDocumentClass();
mapDocument2.Open(@"\\pc.lojic.local\files\ArcGIS\10.6.1\Desktop\Development\Msd\Atlases\templates\forcemains.mxd");
IActiveView pAV2 = (IActiveView)mapDocument2.PageLayout;
pAV2.Activate(GetDesktopWindow());
IFeatureLayer pFL2 = FindLayer(mapDocument2.ActiveView.FocusMap, "ForceMains");
mapDocument2.Close();
m_AOLicenseInitializer.ShutdownApplication();
}
public static IFeatureLayer FindLayer(IMap pmap, string aLayerName)
{
IEnumLayer pEnumLayer = pmap.Layers;
ILayer pLayer;
while ((pLayer = pEnumLayer.Next()) != null)
{
Console.WriteLine(pLayer.Name + " " + pLayer.Valid.ToString());
if (pLayer.Name == aLayerName)
return (IFeatureLayer)pLayer;
}
return null;
}
}
}
... View more
02-24-2021
03:47 PM
|
0
|
2
|
600
|
POST
|
Is there an event that can be subscribed to that will fire when a layout has been activated and drawing is complete? I'm trying to fire off a process that begins once the layout is available but it kicks off early and doesn't do anything. Thanks, Scott Dickison LOJIC
... View more
07-26-2018
12:55 PM
|
0
|
2
|
452
|
POST
|
Is there any way to execute the Print or Export buttons on the Sharing ribbon? I'm trying to write a simple tool that automates the creation of a layout and I'd like to be able to trigger the stock tools from a button on my dockpane. Thanks, Scott Dickison LOJIC
... View more
07-02-2018
06:55 AM
|
0
|
2
|
608
|
Online Status |
Offline
|
Date Last Visited |
01-25-2024
01:30 PM
|