Skip to main content

Module query

Module query 

Source
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

PatternMeaningExample
U1Component by designatorMatch component U1
R*Designator patternMatch R1, R2, R100, etc.
$LM358Component by part numberMatch by lib_reference
~VCCNet by nameMatch net labels/power objects
@10KComponent by valueMatch by Value parameter
#PowerSheet by nameMatch sheet (reserved)
U1:3Pin by numberPin 3 of component U1
U1:VCCPin by nameVCC pin of component U1
R*@10KCombined query10K 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

PatternMeaning
componentAll components
#U1Component with ID “U1”
pin[type=input]Input pins
net:powerPower nets
#U1 > pinDirect children (pins of U1)
#U1 >> componentElectrically connected components
#VCC :: pinPins on VCC net
component:countCount 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§

AttributeSelector
Attribute selector
ComponentView
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
PortView
High-level view of a port
PowerView
High-level view of a power symbol
PropertyFilter
A property filter like [rotation=90] or [x>1000].
QueryExecutor
Query executor that matches selectors against a schematic view
QueryParser
Query parser
QueryResult
Query result containing matched elements from SchQL
RecordQueryMatch
Result of a query: record ID with optional metadata.
RecordSelector
A parsed selector, which may contain multiple alternatives (comma-separated).
SchematicQuery
Main query engine for schematic documents using SchQL
SchematicView
High-level schematic document view with connectivity
SelectorChain
A chain of selector segments connected by combinators.
SelectorEngine
Query execution engine for schematic records.
SelectorParser
Parser for selector strings.
SelectorSegment
A single segment in a selector chain.

Enums§

AttributeOp
Attribute comparison operators
Combinator
Combinators connecting selector segments.
CombinatorType
Combinator types for relationship queries
CommonFilterValue
Value types for filter comparisons.
ConnectionPoint
A connection point in the schematic
ElectricalFilter
Electrical filter pseudo-selector (shared between systems).
ElectricalType
Electrical type for pins (shared between systems).
ElementType
Element types that can be queried
FilterOp
Comparison operators for property/attribute filters.
FilterOperator
Comparison operators for property filters.
FilterValue
Value in a property filter.
NetConnectedTarget
Target for net connectivity queries.
PseudoSelector
Pseudo-selector types
QueryError
Query parsing error
QueryMatch
A matched element from a SchQL query
RecordMatcher
What records a segment matches.
RecordPseudoSelector
Pseudo-selectors for additional filtering.
RecordType
Record types that can be matched.
Selector
Parsed query AST node
StandardAttribute
Standard attribute names with aliases
VisibilityFilter
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