|
POST
|
Greetings. I am working on a project trying to get sequential Plan ID numbers for polygons produced in different year and different counties. I am using the field "County" to derive my County ID number (it is a string) and a "Year" field to derive my year value (alos a string. The format I am looking for is: 2012-401-1 2012-401-2 2012-401-3 2012-363-1 2012-363-2 2011-401-1 2011-401-2 Any help that y'all could provide would be greatly appreciated. Use the code and tool configuration shown in my post at position # 87 of this thread on auto-sequential numbers to fill in a long field with a sequential number that restarts with each new instance of a unique multi-field case value grouping. The code and tool design in that post allows you to subsort on fields that are not part of the multi-field case grouping, so you can ensure that the sequence is numbered according to the sort order of the actual dates of the plans, despite the fact that those actual dates do not contribute to the unique multi-field case groupings. While you are welcome to adapt the code from what I have posted to directly populate your text field, I suggest using the tool as it is written to first store the sequential group subnumbers in a Long field and then do a separate calculation to concatenate the three fields into your desired text field format. Numbers are always better than text for analysis and sorting of numeric values and I always try to have concatenated components in separate fields for manipulations I don't imagine I will need when I first create them. For the concatenation you will need to be sure to account for leading zero formatting if in any case there are more than 9 instances within a single year and county combination (it is bound to happen in at least one year, either in the past of in the future). I would always make allowance for at least 99 plans per year per County. Search on the Python format syntax for creating strings with standarized leading zero formatting.
... View more
08-28-2012
04:05 PM
|
0
|
0
|
980
|
|
POST
|
I have been searching the internet for ideas on how to restrict a VB.Net System.Windows.Forms.TextBox control to only accept positive Long or positive Double numeric values. I think I have come up with a good control set up, primarily based on this post on msdn. The code within the KeyPress and Leave events below is generic and can be pasted into any Textbox KeyPress and Leave events to produce the behaviors described below. I am posting this in case it helps others and also to see if anyone has a more elegant way of doing this. For this example, the behavior criteria of my Long Textbox are as follows: 1. When the user finishes editing in the Textbox the value of the Textbox must be a Long interger that is positive and greater than or equal to 1 (in this example the Textbox represents an annual average daily trip count which cannot be negative and which is used as a divisor in an equation, so at least 1 annual average daily trip must occur on the road for a valid analysis). 2. From the keyboard the user must only be able to type numbers. 3. The user may paste text into the Textbox. This introduces the possibility for insertion of negative numbers, floating values, and invalid entries which must be resolved in the following ways: a. If a negative number is pasted into the Textbox, it must be reset to its absolute value. b. If a floating number is pasted into the Textbox, it must be rounded to a whole interger. c. If the user pastes invalid text into the Textbox and does not correct an invalid entry prior to leaving the Textbox, the user will be permitted to exit the textbox, but the invalid value will be replaced by the minimum default value (in this case 1). 4. If a user attempts to leave the Textbox with a blank entry or an entry of 0, the user is permitted to leave but the textbox will be completed using the minimum default value (in this case 1). 5. Numbers must always be corrected to a conventional format when the user leaves the Textbox. In other words, a user may enter a value of 023 into the Textbox, but when he exits the Textbox it must appear as 23. Here is the code that implements this behavior. The Textbox in this specific example is named txtAADT; however, the code written within the KeyPress and Leave Subs is generic and can be pasted into these two events for any other Textbox to implement the same behavior. Imports System.Math
Private Sub txtAADT_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtAADT.KeyPress
# If the keystroke is not a numeric digit, the keystroke will be disregarded. Code works for any Textbox KeyPress event.
If Not (Char.IsDigit(e.KeyChar) Or Char.IsControl(e.KeyChar)) Then
e.Handled = True
End If
End Sub
Private Sub txtAADT_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtAADT.Leave
# User has completed their entry and is leaving the Textbox.
# Create a Textbox variable to make the code below generic so that it can be pasted into any Textbox Leave event
Dim tbx As System.Windows.Forms.TextBox = sender
Dim value As Double
If Not Double.TryParse(tbx.Text, value) Then
# The user did not correct an invalid entry so replace it with 1
tbx.Text = 1
ElseIf value < -1 Then
# The user pasted a negative value, so make sure it is rounded and take its absolute value
tbx.Text = Abs(CLng(value))
ElseIf value < 1 Then
# The user has entered 0 or pasted in a value between -1 and 1, so replace with minimum value of 1
tbx.Text = 1
ElseIf value = vbNull Then
# The user has blanked out the Textbox, so fill in the Textbox with the minimum value of 1
tbx.Text = 1
Else
# The user has entered a valid postive number, so make sure it is rounded and appears as a conventional number
tbx.Text = CLng(value)
End If
End Sub
The positive Double Textbox has similar requirements to the positive Long Textbox, but it allows an optional single decimal point to be inserted to create non-integer values. (The code is not designed at this time to respond to local Cultural settings for the decimal character, so that would be a nice enhancement if anyone cares to suggest the code required to do that.) The following additional or different behaviors are implement with the positive Double Textbox: 1. When the user finishes editing in the Textbox the value of the Textbox must be a Double value that is positive and greater than or equal to 0 (in this example the Textbox represents a Distance of offset from an intersection which cannot be negative, but which may be 0 where no offset is desired). 2. From the keyboard the user must only be able to type numbers and at most one decimal character. 3. The user may paste text into the Textbox. This introduces the possibility for insertion of negative numbers and invalid entries which must be resolved in the following ways: a. If a negative number is pasted into the Textbox, it must be reset to its absolute value. b. If the user pastes invalid text into the Textbox and does not correct an invalid entry prior to leaving the Textbox, the user will be permitted to exit the textbox, but the invalid value will be replaced by the minimum default value (in this case 0). 4. If a user attempts to leave the Textbox with a blank entry, the user is permitted to leave but the textbox will be completed using the minimum default value (in this case 0). 5 A maximum of 4 fractional digits are permitted. Any fractional digits beyond that must be rounded. (This is due to the maximum resolution of the data) 6. Numbers must always be corrected to a conventional format when the user leaves the Textbox. In other words, a user may enter a value of 023.123456 into the Textbox, but when he exits the Textbox it must appear as 23.1235. Here is the code for the positive Double Textbox. The Textbox in this specific example is named txtDistance1; however, the code written within the KeyPress and Leave Subs is generic and can be pasted into these two events for any other Textbox to implement the same behavior. Imports System.Math
Private Sub txtDistance1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtDistance1.KeyPress
# Create a Textbox variable so that the code within this KeyPress event is generic for all positive Double Textboxes.
Dim tbx As System.Windows.Forms.TextBox = sender
If Not (Char.IsDigit(e.KeyChar) Or Char.IsControl(e.KeyChar) Or (e.KeyChar = "." And tbx.Text.IndexOf(".") < 0) Or (e.KeyChar = "." And tbx.Text.IndexOf(".") >= 0 And tbx.SelectionLength > 0 And tbx.SelectionStart <= tbx.Text.IndexOf(".") And tbx.SelectionStart + tbx.SelectionLength > tbx.Text.IndexOf("."))) Then
# Explanation: Prevent the keystroke if it is not a numeric digit, a non-printable character such as a Backspace, or a decimal point where no decimal point exists in the Textbox or where the existing decimal point is contained in a text selection that will be overwritten by the new decimal point.
e.Handled = True
End If
End Sub
Private Sub txtDistance1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDistance1.Leave
# User has completed their entry and is leaving the Textbox
# Create a Textbox variable so that the code below is generic and can be pasted into any Textbox Leave event
Dim tbx As System.Windows.Forms.TextBox = sender
Dim value As Double
If Not Double.TryParse(tbx.Text, value) Then
# Textbox value is invalid, so replace it with the minimum default value (in this case 0)
tbx.Text = 0
ElseIf value = vbNull Then
# The user has blanked out the Textbox, so fill in the Textbox with the minimum value of 0
tbx.Text = 0
ElseIf value >= 0 Then
# value is positive so round to 4 decimal places and correct to conventional format
tbx.Text = Round(value, 4)
Else
# value is negative so round to 4 decimal places, apply the absolute value and correct to conventional format
tbx.Text = Abs(Round(value, 4))
End If
End Sub Again, I hope this helps.
... View more
08-28-2012
03:24 PM
|
0
|
29
|
19271
|
|
POST
|
It looks like you have configured a MapFrame as your PageLayout. If so, look at the IMapFrame interface to control the border and other properties. The label in the middle disappers as soon as a layer is associated with the MapFrame. I do not think there is any other way to remove the center label. You could also try casting to the IFrameElement interface, which controls a border on virtually all frame types. The IMapFrame inherits from that interface.
... View more
08-27-2012
12:12 PM
|
0
|
0
|
2500
|
|
POST
|
I was curious if anyone knew how I would go about creating a tool which allowed the user to select a shapefile from an interactive map, for example select a particular state from a shapefile of all the states in the U.S. and then the tool will use that particular state shapefile as the clipping extent for the tool. I have a climate dataset for the entire United States and I would like the user to be able to select a particular state on a map so the climate dataset is clipped to just that state. I know how to add the shapefile as a parameter on the tool's gooey, but instead of the user navigating to a shapefile saved somewhere on their computer, I would like them to be able to interactively select that state's shapefile on a map and then that shapefile will be used as the clip extent. If anyone has an idea about how I would go about this please share, thanks!! Python is incapable of setting a data frame's clip geometry. It has no arcpy.mapping method to do that. So if that is what you mean by setting a clip extent then you must use the IMap.ClipGeometry ArcObjects interface. I am programming an Add-In extension that will listen to AfterDraw events and watch a hidden text object in my map to get messages from Python to set a data frame clip after a long Python script. If want your routine to use the shapefile in connection with the Clip geoprocessing tool that is a different matter (straight Python can do that), but I would normally assume that an interactive map involves dealing with data frame clipping.
... View more
08-27-2012
11:56 AM
|
0
|
0
|
940
|
|
POST
|
I have decided to give my original idea a try and set up a listener for the AfterDraw event in an Add-in extension. Even though Python's refresh of an ActiveView does not seem to trigger the extension code, it appears that this approach will work because the mere act of closing the geoprocessing results window when the script is done triggers the extension code to detect an AfterDraw event if that dialog covered any portion of the map. This behavior should be nearly unavoidable. Even if closing that tool dialog does not work, if anything covers a portion of the map for even a moment, like a messagebox or a dockable window expansion, the code is triggered and should be able to evaluate the map configuration to determine if it needs to execute its custom code. And failing all of that if any other user action triggers a refresh the code will fire. At this point I mainly need to identify the optimum code sequence to ensure that the AfterDraw event always fires in connection with the proper ActiveView (the LayoutView) and that it quickly determines when it does or does not need to implement its custom behavior. The map must be in Layout view because the Python code I have written ensures this is the view when it finishes running, and if that is the case it should then determine if the Text object exists in the map, and if that is the case it should detect if the Text object has the proper information for executing the code. If there are any suggestions on how to best optimize such code, I would appreciate them. I will continue experimenting in the meantime.
... View more
08-26-2012
05:36 PM
|
0
|
0
|
3047
|
|
POST
|
This will kill ArcMap itself.
import os
os.system("TASKKILL /F /IM ArcMap.exe")
I stand corrected.
... View more
08-26-2012
07:30 AM
|
0
|
0
|
3843
|
|
POST
|
How Can I Close an mxd using arcpy script. Thanks Python is still more of a geoprocessing oriented language is GIS than a full blown windows application management language. The arcpy options only let you save or saveacopy of the document, but there is no close option. I haven't seen any native Python that manages open Wndows applications. Perhaps there is an extension someone has written that I am unaware of, but the python.org help does not come up with anything I can find. I think you are expecting more out of Python than ESRI has tried to support at this time.
... View more
08-25-2012
09:51 PM
|
0
|
0
|
3843
|
|
POST
|
In .NET maybe it is hard to capture every possible user "oops". In Java, it's straight-forward. DecimalFormat.. DateFormat.. fun stuff. If you enter junk into this text field, it will default to 0.00
// Create an instance of DecimalFormat to limit the number of integers the user can type into certain fields.
DecimalFormat temperatureFormat = new DecimalFormat("##0.00");
ftfTemperature = new JFormattedTextField(new DefaultFormatterFactory(new NumberFormatter(temperatureFormat),new NumberFormatter(temperatureFormat),new NumberFormatter(temperatureFormat)));
ftfTemperature.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
ftfTemperature.selectAll();
}
});
}
});
ftfTemperature.setBounds(120, 8, 85, 20);
panel.add(ftfTemperature);
Leo: Could you screen shot what this code actually produces as far as an interface that the user would see? Searching help on Java Add-ins has left me completely in the dark on what this code would end up looking like or how it launches or anything. Is the Java IDE environment text based only for defining the form or does it have visual drag and drop tools? I need the real basics to get oriented to decide if I want to even attempt to go down this path. How is building a Java add-in any different from building a .Net add-in?
... View more
08-25-2012
09:22 PM
|
0
|
0
|
3047
|
|
POST
|
What was the problem with the Spatial Join and Dissolve? I am certain they will work if you do it with the One-To-Many option as far as I can see. I assume the field shape has no date and that only the influence areas are dated. If that is the case it does not matter if they cut up. If you need to compare to a complete polygon's area, precalulate that into the shapes and use it for percentage comparisons with the Min summary. Anyway, the influence areas should not mix at all with the One-To-Many option. So do it an then post pictures of the results if you still do not know how to get what you want. (Next time post shots of the tableviews of the field and influence areas and tell us what fields you need to combine from each).
... View more
08-25-2012
06:15 PM
|
0
|
0
|
3780
|
|
POST
|
I spoke too soon. While the script and console application work perfectly when I run the Python script from Idle, it hangs when I run the same code from within a script tool. The Console application window opens, but the parameters never get read when the script tool runs the code. Anyway, I know how to get the Data Frame Clip Geometry updated from the ArcObjects side, but I still need to find a way to connect it automatically to the Python code at runtime. If the parameters are all that is hanging it up, I may be able to eliminate the need for any parameters on the Console application by using the original technique I suggested of using an intermediate text object for passing parameter information between Python and ArcObjects. That would be acceptable for my needs. However, I will have to do additional testing to be certain that the Console application will run from a script tool and not hang if parameters are eliminated. Edit: It hangs without parameters as well from a script tool. Now I am looking at the subprocess options to see if it can create a shell that works within the script tool, but I am not optimistic. Edit2: The shell option causes an error and using call instead of check_call hangs also. So it looks like a script tool does not work with a Console application at all. Bummer.
... View more
08-25-2012
05:10 PM
|
0
|
0
|
3047
|
|
POST
|
I spoke too soon. While the script and console application work perfectly when I run the Python script from Idle, it hangs when I run the same code from within a script tool. The Console application window opens, but the parameters never get read when the script tool runs the code. Anyway, I know how to get the Data Frame Clip Geometry updated from the ArcObjects side, but I still need to find a way to connect it automatically to the Python code at runtime.
... View more
08-25-2012
05:09 PM
|
0
|
0
|
2833
|
|
POST
|
Getting back to the original question of this thread, by using suggestions from Leo Donahue I have found a way to create a C# ArcMap Console Application using Visual Studio 2010 that can be triggered by Python to change the data frame clip geometry. This should work for ArcGIS 10.0 and above and the C# code should compile in Visual Studio 2010 express and above. While there are a number of ways to obtain the geometry for use in updating the data frame, I designed my routine to use a single polygon feature obtained from a map layer. I can set up Python to execute the console application and pass string parameters that provide the console application with the mxd name, the data frame name, and the layer name that will be used as the feature geometry of the data frame clip shape. Normally prior to running this code arcpy would set a Definition Query filter on the layer to restrict it to a single polygon feature. The code also assumes that the layer is found in the same data frame that is to be clipped. It should be possible to adapt this code to use a graphic in a layout, or a geometrybag combination of multple polygon features as the clipping geometry instead of, or in addition to, a single feature's geometry, but this does what I wanted. Here is the Python code to call the Console Application: from subprocess import check_call # format is check_call([ConsoleApp_Path_and_Name, MXD_Name, Data_Frame_Name, Layer_Name]) check_call(["SetFrameClipGeometry.exe", "Collision_Segment_Diagram2.mxd", "Bottom_Split", "Bottom Clip Shape Left"]) # perform a refresh of the data frame using arcpy after setting the data frame geometry. Here is the Code I used in the C# ArcMap Desktop Console Application: using System; using System.Collections.Generic; using System.Text; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Framework; using ESRI.ArcGIS.ArcMapUI; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.ADF; using ESRI.ArcGIS.Geometry; namespace SetFrameClipGeometry { class Program { private static LicenseInitializer m_AOLicenseInitializer = new SetFrameClipGeometry.LicenseInitializer(); [STAThread()] static int Main(string[] args) { //ESRI License Initializer generated code. if (!m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeArcView, esriLicenseProductCode.esriLicenseProductCodeArcEditor, esriLicenseProductCode.esriLicenseProductCodeArcInfo }, new esriLicenseExtensionCode[] { })) { System.Console.WriteLine(m_AOLicenseInitializer.LicenseMessage()); System.Console.WriteLine("This application could not initialize with the correct ArcGIS license and will shutdown."); m_AOLicenseInitializer.ShutdownApplication(); return 1; } //ESRI License Initializer generated code. String mxdName = null; String dfName = null; String layerName = null; if (args.Length < 3) { System.Console.WriteLine("Insufficient parameters. Expected Three Strings"); return 1; } else { mxdName = args[0]; dfName = args[1]; layerName = args[2]; } try { IAppROT aprot = new AppROT(); if (aprot.Count == 0) { System.Console.WriteLine("No ArcMap application is open"); return 1; } IApplication application = null; IMxDocument mxd = null; for (int a = 0; a < aprot.Count; a++) { application = aprot.get_Item(a); System.Console.WriteLine("Search Application Title: " + application.Document.Title); if (application.Document.Title == mxdName) { System.Console.WriteLine("Found Open ArcMap Document Named: " + mxdName); mxd = application.Document as IMxDocument; break; } } IMap pMap = null; IMaps pMaps = null; if (mxd == null) { System.Console.WriteLine("No ArcMap Document Named " + mxdName + " Was Found"); return 1; } pMaps = mxd.Maps; for (int i = 0; i <= pMaps.Count - 1; i++) { pMap = pMaps.get_Item(i); if (pMap.Name == dfName) { Console.WriteLine("Found Data Frame Named: " + pMap.Name); break; } } if (pMap == null) { System.Console.WriteLine("No DataFrame Exists In " + mxdName); return 1; } if (pMap.Name != dfName) { System.Console.WriteLine("No Data Frame Named " + dfName + " Was Found"); return 1; } if (pMap.LayerCount == 0) { return 1; } // Fetch all the feature layers in the focus map // to determine if at least one is selectable. UIDClass uid = new UIDClass(); uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}"; IEnumLayer pEnumLayer = pMap.get_Layers(uid, true); pEnumLayer.Reset(); ILayer pLayer = pEnumLayer.Next(); while (pLayer != null) { if (pLayer.Name == layerName) { Console.WriteLine("Found Layer Named: " + pLayer.Name); break; } pLayer = pEnumLayer.Next(); } if (pLayer == null) { System.Console.WriteLine("No Layer Named " + layerName + " Was Found"); return 1; } using (ComReleaser comReleaser = new ComReleaser()) { IFeatureLayer pFLayer = pLayer as IFeatureLayer; IFeatureCursor pFCursor = pFLayer.Search(null, false); comReleaser.ManageLifetime(pFCursor); IFeature pFeat = null; IGeometry pGeom = null; while ((pFeat = pFCursor.NextFeature()) != null) { pGeom = (IGeometry)pFeat.Shape; } if (pGeom == null) { System.Console.WriteLine("No Feature Geometry Was Found!"); return 1; } pMap.ClipGeometry = pGeom; System.Console.WriteLine("Feature Geometry Set!"); } } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); System.Console.ReadLine(); return 1; } //System.Console.ReadLine(); // Uncomment this line if you want to pause the Console application before it closes. //Do not make any call to ArcObjects after ShutDownApplication() m_AOLicenseInitializer.ShutdownApplication(); return 0; } } }
... View more
08-25-2012
10:48 AM
|
0
|
0
|
7339
|
|
POST
|
Doesn't python have an OS module that you can call? os.system(your application, your parameter) My question is now answered and the solution is much better than my original idea. Using the method below I can now create a Python script that calls an ArcMap Console Application and that passes an argument with a name of the map that Python wants the Console Application to update. The Console Application is able use the IAppROT interface to get an application hook to the Map that Python wants updated and can then do things using ArcObjects code that arcpy mapping cannot do. Python can pass as many additonal standard C type (char, int, date, etc.) arguments that the Console Application may need to coordinate its actions with the Python script. I am fairly certain that the Console application can pass back a result to Python using the method outlined below as well. Therefore, there is no need to wait on the user to do anything to coordinate the triggering of the code, or to use an Add-in extension event listener, or store notification text objects in the map to handle communications between Python and ArcObjects. The Python subprocess.check_call method works for calling an ArcMap Desktop Console Application with arguments in this format: from subprocess import check_call
check_call(["DesktopConsoleApplication1.exe", "Collision_Segment_Diagram2.mxd"]) The following ArcMap Desktop Console Application code worked to notify me whether or not a map is open and whether or not it matches the title python passed as an agrument to the console application: using System;
using System.Collections.Generic;
using System.Text;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Framework;
namespace DesktopConsoleApplication1
{
class Program
{
private static LicenseInitializer m_AOLicenseInitializer = new DesktopConsoleApplication1.LicenseInitializer();
[STAThread()]
static void Main(string[] args)
{
//ESRI License Initializer generated code.
m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeArcView, esriLicenseProductCode.esriLicenseProductCodeArcEditor, esriLicenseProductCode.esriLicenseProductCodeArcInfo },
new esriLicenseExtensionCode[] { });
//ESRI License Initializer generated code.
try
{
IAppROT aprot = new AppROT();
IApplication application = null;
for(int a = 0; a < aprot.Count; a++)
{
application = aprot.get_Item(a);
System.Console.WriteLine("Application Title = " + application.Document.Title);
foreach (string curItem in args)
{
System.Console.WriteLine("Args: " + curItem);
if (application.Document.Title == curItem)
{
System.Console.WriteLine("The map was found! Do something!");
}
else
{
System.Console.WriteLine("The open map does not match that title.");
}
}
}
if (aprot.Count == 0)
{
System.Console.WriteLine("No ArcMap application is open");
}
//System.Console.ReadLine(); //Uncomment this line if you want to have the console pause before closing.
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
//Do not make any call to ArcObjects after ShutDownApplication()
m_AOLicenseInitializer.ShutdownApplication();
}
}
}
... View more
08-24-2012
08:18 PM
|
0
|
0
|
3047
|
|
POST
|
This prints the title of the only mxd open on my machine, index = 0. You would probably have to make sure you have the right mxd application name by iterating over the count of open mxds and getting the title.
public class Console {
public static void main(String[] args) {
EngineInitializer.initializeEngine();
initializeArcGISLicenses();
try {
IAppROT aprot = new AppROT();
IApplication application = aprot.getItem(0);
System.out.println(application.getDocument().getTitle());
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
static void initializeArcGISLicenses() {
try {
com.esri.arcgis.system.AoInitialize ao = new com.esri.arcgis.system.AoInitialize();
if (ao.isProductCodeAvailable(com.esri.arcgis.system.esriLicenseProductCode.esriLicenseProductCodeArcView) == com.esri.arcgis.system.esriLicenseStatus.esriLicenseAvailable)
ao.initialize(com.esri.arcgis.system.esriLicenseProductCode.esriLicenseProductCodeArcView);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Do you know how to call this console application from the Python side and have Python provide a parameter? Would the Python ctypes interface be the way to go? If so then this seems to have everything I would need to chain the two together and from there could decide what I wanted Python to do and what I wanted the console application to do.
... View more
08-24-2012
11:05 AM
|
0
|
0
|
3047
|
|
POST
|
In .NET maybe it is hard to capture every possible user "oops". In Java, it's straight-forward. DecimalFormat.. DateFormat.. fun stuff. If you enter junk into this text field, it will default to 0.00
// Create an instance of DecimalFormat to limit the number of integers the user can type into certain fields.
DecimalFormat temperatureFormat = new DecimalFormat("##0.00");
ftfTemperature = new JFormattedTextField(new DefaultFormatterFactory(new NumberFormatter(temperatureFormat),new NumberFormatter(temperatureFormat),new NumberFormatter(temperatureFormat)));
ftfTemperature.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
ftfTemperature.selectAll();
}
});
}
});
ftfTemperature.setBounds(120, 8, 85, 20);
panel.add(ftfTemperature);
Lines of Python code to restrict a script tool field to a long = None: Define the input as a Long in the parameter dialog. Lines of Python code to restrict a script tool field to a date = None: Define the input as a Date in the parameter dialog. Hard to get any simpler than that. Since I have no background in using Java I can't say the code above gives me confidence that I could easily convert what I have done to a Java add-in, but I will start looking into that as another option.
... View more
08-24-2012
10:37 AM
|
0
|
0
|
3047
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-24-2026 11:37 PM | |
| 1 | 03-24-2026 08:01 PM | |
| 6 | 02-23-2026 08:34 AM | |
| 1 | 03-31-2025 03:25 PM | |
| 1 | 03-28-2025 06:54 PM |
| Online Status |
Online
|
| Date Last Visited |
a week ago
|