Zuken.symbols
1from .e3 import Job 2 3_symbol = Job.CreateSymbolObject() 4_ = None 5 6def placeSymbol(name: str, version, sheet: int, x: float, y: float) -> int: 7 """ 8 Places specified symbol on the sheet 9 10 Args: 11 name: Symbol Name 12 version: Symbol Version 13 sheet: Sheet to place on 14 x: x coordinate 15 y: y coordinate 16 17 Returns: 18 ID of the new symbol (0 if not created) 19 """ 20 21 _symbol.Load(name, version) 22 # I personally don't have any need for the rotation/scale optional parameters 23 return _symbol.Place(sheet, x, y) 24 25def extractSymbolText(symbol: int, category=0, text="") -> list: 26 """ 27 Returns the text IDs from a symbol. Able to filter by category (text type) and text content 28 29 Args: 30 symbol: Symbol ID to get text from 31 category: Text type to filter the text IDs to. Can be found in Database Editor -> Format -> Text Types 32 text: Text string to search for (must be an exact match) 33 34 Returns: 35 List of text IDs, will be empty if none are found 36 """ 37 38 _symbol.SetId(symbol) 39 return list(_symbol.GetTextIds(_, category, text)[1][1:]) 40 41def filterBySymbolName(symbols: list[int], name: str) -> list: 42 """ 43 Filters by the symbol name, uses startswith to cast a broader net of matching symbols 44 45 Args: 46 symbols: List of symbol IDs 47 name: Symbol name to search for 48 49 Returns: 50 List of symbols whose name matches the (start of the) string 51 """ 52 53 def GetName(symbol): 54 _symbol.SetId(symbol) 55 return _symbol.GetSymbolTypeName() 56 57 return [s for s in symbols if GetName(s).startswith(name)] 58 59def deleteSymbol(symbol: int) -> int: 60 """ 61 Wrapper to delete symbols in one line 62 63 Args: 64 symbol: Symbol ID 65 66 Returns: 67 0 for successful deletion, symbol ID otherwise 68 """ 69 _symbol.SetId(symbol) 70 return _symbol.Delete()
def
placeSymbol(name: str, version, sheet: int, x: float, y: float) -> int:
7def placeSymbol(name: str, version, sheet: int, x: float, y: float) -> int: 8 """ 9 Places specified symbol on the sheet 10 11 Args: 12 name: Symbol Name 13 version: Symbol Version 14 sheet: Sheet to place on 15 x: x coordinate 16 y: y coordinate 17 18 Returns: 19 ID of the new symbol (0 if not created) 20 """ 21 22 _symbol.Load(name, version) 23 # I personally don't have any need for the rotation/scale optional parameters 24 return _symbol.Place(sheet, x, y)
Places specified symbol on the sheet
Arguments:
- name: Symbol Name
- version: Symbol Version
- sheet: Sheet to place on
- x: x coordinate
- y: y coordinate
Returns:
ID of the new symbol (0 if not created)
def
extractSymbolText(symbol: int, category=0, text='') -> list:
26def extractSymbolText(symbol: int, category=0, text="") -> list: 27 """ 28 Returns the text IDs from a symbol. Able to filter by category (text type) and text content 29 30 Args: 31 symbol: Symbol ID to get text from 32 category: Text type to filter the text IDs to. Can be found in Database Editor -> Format -> Text Types 33 text: Text string to search for (must be an exact match) 34 35 Returns: 36 List of text IDs, will be empty if none are found 37 """ 38 39 _symbol.SetId(symbol) 40 return list(_symbol.GetTextIds(_, category, text)[1][1:])
Returns the text IDs from a symbol. Able to filter by category (text type) and text content
Arguments:
- symbol: Symbol ID to get text from
- category: Text type to filter the text IDs to. Can be found in Database Editor -> Format -> Text Types
- text: Text string to search for (must be an exact match)
Returns:
List of text IDs, will be empty if none are found
def
filterBySymbolName(symbols: list[int], name: str) -> list:
42def filterBySymbolName(symbols: list[int], name: str) -> list: 43 """ 44 Filters by the symbol name, uses startswith to cast a broader net of matching symbols 45 46 Args: 47 symbols: List of symbol IDs 48 name: Symbol name to search for 49 50 Returns: 51 List of symbols whose name matches the (start of the) string 52 """ 53 54 def GetName(symbol): 55 _symbol.SetId(symbol) 56 return _symbol.GetSymbolTypeName() 57 58 return [s for s in symbols if GetName(s).startswith(name)]
Filters by the symbol name, uses startswith to cast a broader net of matching symbols
Arguments:
- symbols: List of symbol IDs
- name: Symbol name to search for
Returns:
List of symbols whose name matches the (start of the) string
def
deleteSymbol(symbol: int) -> int:
60def deleteSymbol(symbol: int) -> int: 61 """ 62 Wrapper to delete symbols in one line 63 64 Args: 65 symbol: Symbol ID 66 67 Returns: 68 0 for successful deletion, symbol ID otherwise 69 """ 70 _symbol.SetId(symbol) 71 return _symbol.Delete()
Wrapper to delete symbols in one line
Arguments:
- symbol: Symbol ID
Returns:
0 for successful deletion, symbol ID otherwise