Skip to content
Discussion options

You must be logged in to vote

That’s pretty much it. If it’s the current drawing, you can use a selection set filter. But you will find that iterating is actually faster than selection sets, plus the code is reusable with side databases.

Even though opening entities for read is relatively cheap, if your searching for multiple properties, maybe move the loop to the outside, something like

def has_proprty_layer(ent : Db.Entity, filter : dict) -> bool:
    return ent.layer() in filter["layer"]

def has_proprty_color_index(ent : Db.Entity, filter : dict) -> bool:
    return ent.colorIndex() in filter["color"]

@command
def doit():
    db = Db.curDb()
    
    filter = {}
    filter["layer"] = set(["0", "2"])
    filter["c…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@CEXT-Dan
Comment options

Answer selected by gswifort
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants