Appearance
Import Query
Read metadata about a source before importing it — so a plugin can discover the values the importers need. Accessed via snaptrude.core.io.query.
Functions
getPdfPageCount(source)
Count the pages of a PDF without importing it. source is an https:// or data: URL. Returns the page count, or null if it can't be read as a PDF. Pairs with import.pdf's page argument.
ts
const pages = await snaptrude.core.io.query.getPdfPageCount(url);
for (let p = 1; p <= (pages ?? 0); p++) {
await snaptrude.core.io.import.pdf(url, p, p); // one page per storey
}listCadLayers(cad)
List the distinct CAD layer names tagged on a parsed CAD JSON's entities (same shape import.cadJson accepts). Read-only inspection: imports always bring in every layer (there is no layer filter on import.dwg / import.cadJson) — use the names to decide whether to import at all. Returns an array (empty if none).
ts
const layers = await snaptrude.core.io.query.listCadLayers(cad);
if (layers.some((l) => l.toUpperCase().includes("WALL"))) {
await snaptrude.core.io.import.cadJson(cad, 1); // all layers import together
}Errors
Failed calls reject with a typed PluginError — see Error Handling. This namespace adds no conditions of its own — an unreadable or unparseable source is reported on the success channel (getPdfPageCount → null, listCadLayers → []), never as a rejection.