In the Python window of SuperMap iDesktopX, you can use the Python language to call the interface or function based on the SuperMap iObjects Python or third-party dependent library, and efficiently customize and expand the function. Realize more functions that meet the logic of business requirements. The Python window provides two ways to add scripts: typing directly and adding a Python File.
Click the Start-> Browse-> Python button to open the Python window. When opened, the default Python environment is started. Python window consists of toolbox, script input window, information Output window, Prompt window and Help window. As shown in the following figure:
Enter the Python code
Python code can be directly input in the script input window. When the Python code is input, the corresponding method and parameter will be intelligently prompted, and the corresponding method or parameter can be automatically completed. At the same time, the Help window will automatically display the description document of the written method, which is convenient for the user to view the interface, Parameter Description, example code and other information, and assist the user to quickly develop the Extension.
After entering the Python code, click the enter key to execute the script, and the Output Window will prompt the execution of the code, which is convenient for users to debug and trace.
Load the Python file
On the toolbar of the Python window, click the Perform Python File button, select the *.py file on the displayed Select Python File dialog box, and click the Open button. The script Result in the Perform Python File is displayed in the Output Window window.
Application example
- Open the Python window after opening the existing Workspace locally.
- Enter the following scripts
in sequence in the Python window:
//Define Current Workspace as WS ws = Workspace() //Define the first Datasource in Current Workspace as DS ds = ws.get_datasource(0) //Define PointsDataset in dsData source as dataset dataset = ds.get_dataset("Points") //Execute Buffer Zone Analysis on PointsDataset. The left and right radii are both 1000 meters. Other Parameters use the default parameters. create_buffer(dataset,1000,1000)
- After the
analysis is successful, the Result Dataset of a BufferResult can be obtained from the Datasource, and the Analyst Result is shown in the following figure: