Surprise at the end of the article, welcome to pick it up! Can be directly drawn to the end of the article!


Don't miss the prize!


As long as the relevant product is purchased in a retail store, it must be activated. So don't give too much introduction.


Features: genuine, paid, after-sales service, permanent activation

It took a few days for the command line to figure out this stuff.


After opening Python, there are three command windows: pycharm (python GUI), python (comand line), Module Docs.


Module Docs is a search box for functions that are not known in python.





Comparing IDLE and the command line: both are interactive modes


IDLE (python GUI):


White window. There are code highlighting, automatic indentation, code hints and menu bar;


You can create a new python file, you can copy and paste the code, but the result will not be returned;

The previous command cannot be repeated with the up arrow, and delete cannot be selected.

python(comand line):

A black window will only report an error message after execution.

There is no menu bar, you can only type commands line by line, and paste a piece of code will be disassembled into command execution one by one;

If you cannot paste the tabs and spaces after for, an error will be reported.

Use the up arrow to reproduce the previous command, which is faster, and you can select the current editing line code to delete it directly.

Double-click to run the file: If you want to get rid of the script mode and directly write the code to run, first add the python installation location to the environment variable path. You can then double-click to open the .py file. The solution to the crash: add raw_input() or input() at the end of the .py file according to the version.

There are two ways to run a .py file from the command line:

cmd: switch to the path where the file is located, execute: python myName.py

python.exe:

import os

os.chdir('current path')//Switch to the current path

os.getcwd()//Get the current path

Run: execfile('myName.py')

Or directly: execfile (whole pathname + filename)

If you use import myName.py, you can only return the execution result when you import it for the first time, and an error will be reported when you import it again.

        if attrvalue == value:


            selection.append(o)       


    ce.setSelection(selection)


 


Then call the function in the main function:


if __name__ == '__main__':


    selectByAttribute(\"connectionStart\",\"JUNCTION\")


 


(The meaning of the above code is to select all elements whose value is JUNCTION in the connectionStart attribute in the scene)


After writing the code, click Save, and then press F9 to run this code,


You can also specify the path of the script in the Python console, import the script, and then call the myHelper you just wrote in the console, and fill in the required parameters. The command is as follows:


>>> sys.path.append(ce.toFSPath(\"scripts\"))


>>> import myHelper


>>> myHelpers.selectByAttribute(\"connectionEnd\", \"CROSSING\")


 


At this time, the element whose value is CROSSING in the connectionEnd attribute is selected.


*Add a startup script


Create a new startup.py script in the CityEngine workspace, and add the following statement to this script so that the myHelper script you just wrote can be loaded when CityEngine starts.


import sys


sys.path.append({PATH_TO_YOUR_SCRIPTS_DIRECTORY})


# eg sys.path.append(\"C:\\user\\CityEngine\\MyProject\\scripts\\")


import myHelper


 


The next time CityEngine starts, myHelper will be loaded automatically, and the selection function can be used in the Python console in the following way:


>>> startup.myHelpers.selectByAttribute(\"connectionEnd\", \"JUNCTION\")


 


startup.py will only be loaded when CityEngine starts, so after modifying this script, you need to restart CityEngine.


Genuine authorized users can log in to the Microsoft account for management. It is extremely convenient to download, install and activate, as shown in the figure below, which saves time and cost, and is convenient and fast! You can download the online installer and offline installer (about 4GB). If necessary, the editor has prepared the installation package in the background!



Follow and reply to [software] to get it for free!



Please send a message to [Little Sweet] from Jiangsu , who won the prize at the end of the last issue, and provide the courier address. The prize will be mailed within one week after receiving the address. Those that cannot be shipped temporarily due to the epidemic will be shipped as soon as possible after the unblocking .


🎁The draw at the end of the article🎁

Retweet this article to say your blessings


Pull 5 treasures to take the heart, practical high-end natural & salt stone lamp

picture

Selection conditions:

1-Follow this official account


2-Retweet this tweet to the circle of friends. You cannot only see it yourself. You need to keep it until you check it. You cannot take fake screenshots.


3- After the lottery is drawn ( the calculation time ends at 12:00 on August 26 ), please check it within 3 working days. If the award is not redeemed within the time limit or does not meet the requirements, the award will be disqualified.

After paying attention to this public account, you can reply to [Lottery Draw]



Thank you all for reading, watching and forwarding all the time, 1000T super exquisite learning materials are given to you! Please get it by yourself


English vocabulary must memorize 3500 syllabus vocabulary list to memorize artifact out of order version of the new class standard mind map diagram clever shorthand junior high school high frequency words Daquan

                                                         picture