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


1. Python console


In Window - Show Console, select a new Python console in the console that appears on the right:


 



This opens a new Python command window


Enter the following command:


ce.setSelection(ce.getObjectsFrom(ce.scene, ce.withName(\"*Broadway*\")))


This command selects elements in the scene that contain Broadway in their names


 

2. Python editor

Using the Python editor is helpful when planning to use more advanced Python commands.

(1) Select File—New...—Python Module

(2) In the Python module wizard, select the folder location where the Python script is stored

(3) Name the python script to be created, here named myHelper

(4) Select a template, here the Main function template is used as an example.

(5) Click Finish to complete the creation.

 

After creation, a Python editor window is opened in the window.

(6) Create a new selectByAttribute(attr,value) function in the editor:

def selectByAttribute(attr, value):

    objects = ce.getObjectsFrom(ce.scene)

    selection = []

    for o in objects:

        attrvalue = ce.getAttribute(o, attr)

        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