In the Python window of SuperMap iDesktopX, users can leverage Python language to efficiently customize and extend functionalities by calling interfaces from SuperMap iObjects Python or third-party libraries. The Python window provides two script input methods: direct input and adding Python files.
Click Start->Browse->Python to open the Python window. The default Python environment will initialize automatically upon opening. The interface consists of a toolbox, script input area, output info window, prompt window, and help window, as shown below:
Input Python Code
The script input area supports intelligent code completion with automatic method and parameter suggestions. The help window dynamically displays documentation for written methods, including interface descriptions, parameter explanations, and sample codes to facilitate rapid extension development.
Press Enter to execute scripts immediately after input. Execution status will be displayed in the output info window for debugging and tracking purposes.
Load Python File
Click Run Python File in the toolbar, select a *.py file through the Select Python File dialog, then click Open to execute the script. Results will be shown in the output info window.
Application Example
- Open the Python window after opening an existing local workspace.
-
Input the following script sequentially:
// Define the current workspace as ws ws = Workspace() // Define the first datasource in current workspace as ds ds = ws.get_datasource(0) // Define the Points dataset in ds as dataset dataset = ds.get_dataset("Points") // Perform buffer analysis on Points dataset with 1000m radius for both sides, using default parameters create_buffer(dataset,1000,1000)
-
After successful execution, a result dataset named BufferResult will be generated in the datasource. The analysis result is shown below: