Expand description
Query systems for schematic records and documents.
This module provides two complementary query systems:
§1. Record Selector System (Low-Level)
Domain-specific selector syntax for querying raw schematic records in a RecordTree.
Optimized for engineers working directly with component designators and part numbers.
§Syntax Overview
| Pattern | Meaning | Example |
|---|---|---|
U1 | Component by designator | Match component U1 |
R* | Designator pattern | Match R1, R2, R100, etc. |
$LM358 | Component by part number | Match by lib_reference |
~VCC | Net by name | Match net labels/power objects |
@10K | Component by value | Match by Value parameter |
#Power | Sheet by name | Match sheet (reserved) |
U1:3 | Pin by number | Pin 3 of component U1 |
U1:VCC | Pin by name | VCC pin of component U1 |
R*@10K | Combined query | 10K resistors |
ⓘ
use altium_format::query::{query_records, SelectorParser, SelectorEngine};
let results = query_records(&tree, "R*@10K").unwrap();§2. SchQL System (High-Level)
CSS-style query language for querying schematic documents with computed connectivity.
Provides a SchematicView abstraction with nets, connections, and relationship queries.
§Syntax Overview
| Pattern | Meaning |
|---|---|
component | All components |
#U1 | Component with ID “U1” |
pin[type=input] | Input pins |
net:power | Power nets |
#U1 > pin | Direct children (pins of U1) |
#U1 >> component | Electrically connected components |
#VCC :: pin | Pins on VCC net |
component:count | Count of components |
ⓘ
use altium_format::query::{SchematicView, SchematicQuery};
let view = SchematicView::from_schdoc(&doc);
let query = SchematicQuery::new(&view);
let result = query.query("component[part*=7805] > pin[type=input]").unwrap();Structs§
- Attribute
Selector - Attribute selector
- Component
View - High-level view of a component
- NetView
- High-level view of a net
- Pattern
- A compiled glob-style pattern for matching strings.
- PinView
- High-level view of a pin
- Port
View - High-level view of a port
- Power
View - High-level view of a power symbol
- Property
Filter - A property filter like
[rotation=90]or[x>1000]. - Query
Executor - Query executor that matches selectors against a schematic view
- Query
Parser - Query parser
- Query
Result - Query result containing matched elements from SchQL
- Record
Query Match - Result of a query: record ID with optional metadata.
- Record
Selector - A parsed selector, which may contain multiple alternatives (comma-separated).
- Schematic
Query - Main query engine for schematic documents using SchQL
- Schematic
View - High-level schematic document view with connectivity
- Selector
Chain - A chain of selector segments connected by combinators.
- Selector
Engine - Query execution engine for schematic records.
- Selector
Parser - Parser for selector strings.
- Selector
Segment - A single segment in a selector chain.
Enums§
- Attribute
Op - Attribute comparison operators
- Combinator
- Combinators connecting selector segments.
- Combinator
Type - Combinator types for relationship queries
- Common
Filter Value - Value types for filter comparisons.
- Connection
Point - A connection point in the schematic
- Electrical
Filter - Electrical filter pseudo-selector (shared between systems).
- Electrical
Type - Electrical type for pins (shared between systems).
- Element
Type - Element types that can be queried
- Filter
Op - Comparison operators for property/attribute filters.
- Filter
Operator - Comparison operators for property filters.
- Filter
Value - Value in a property filter.
- NetConnected
Target - Target for net connectivity queries.
- Pseudo
Selector - Pseudo-selector types
- Query
Error - Query parsing error
- Query
Match - A matched element from a SchQL query
- Record
Matcher - What records a segment matches.
- Record
Pseudo Selector - Pseudo-selectors for additional filtering.
- Record
Type - Record types that can be matched.
- Selector
- Parsed query AST node
- Standard
Attribute - Standard attribute names with aliases
- Visibility
Filter - Visibility filter (shared between systems).
Functions§
- compare_
filter - Compare a string value against a filter using the specified operator.
- parse_
selector - Parse a selector string.
- query_
records - Convenience function to parse and execute a selector query.
- query_
records_ with_ doc_ name - Convenience function to parse and execute a selector query with optional document name. The document name is used as the sheet name for sheet queries (not the Title parameter).
- query_
schdoc - Convenience function to query a SchDoc directly using SchQL