fetch-elements-of-category
Retrieve BIM elements by category from IFC files, enabling structured querying of building information model data with configurable attribute and relation options.
Instructions
Fetch elements of a specified category
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | Category name. e.g. IFCWALL | |
| config | Yes | Configuration for fetching elements |
Implementation Reference
- main.ts:124-146 (handler)MCP server tool handler function. Checks if fragments are loaded, calls the core fetchElementsOfCategory helper, and returns the results as JSON text content.({ category, config }) => { if (!fragments) { return { content: [ { type: 'text', text: 'No fragments loaded. Please call load-frag first.', }, ], } } const itemsData = fetchElementsOfCategory(fragments, category, config) return { content: [ { type: 'text', text: JSON.stringify(itemsData), }, ], } }
- main.ts:105-123 (schema)Zod schema for tool inputs: category (string) and config (object with attributesDefault, attributes array, and relations for HasAssociations and IsDefinedBy).{ category: z.string().describe('Category name. e.g. IFCWALL'), config: z .object({ attributesDefault: z.boolean(), attributes: z.array(z.string()), relations: z.object({ HasAssociations: z.object({ attributes: z.boolean(), relations: z.boolean(), }), IsDefinedBy: z.object({ attributes: z.boolean(), relations: z.boolean(), }), }), }) .describe('Configuration for fetching elements'), },
- main.ts:102-147 (registration)Registration of the 'fetch-elements-of-category' tool using server.tool(), including name, description, schema, and handler.server.tool( 'fetch-elements-of-category', 'Fetch elements of a specified category', { category: z.string().describe('Category name. e.g. IFCWALL'), config: z .object({ attributesDefault: z.boolean(), attributes: z.array(z.string()), relations: z.object({ HasAssociations: z.object({ attributes: z.boolean(), relations: z.boolean(), }), IsDefinedBy: z.object({ attributes: z.boolean(), relations: z.boolean(), }), }), }) .describe('Configuration for fetching elements'), }, ({ category, config }) => { if (!fragments) { return { content: [ { type: 'text', text: 'No fragments loaded. Please call load-frag first.', }, ], } } const itemsData = fetchElementsOfCategory(fragments, category, config) return { content: [ { type: 'text', text: JSON.stringify(itemsData), }, ], } } )
- fragments.ts:50-64 (helper)Core helper function that implements the logic to fetch elements of a category: gets items matching category regex, filters valid IDs, and retrieves items data with given config.export const fetchElementsOfCategory = ( fragments: FRAGS.SingleThreadedFragmentsModel, category: string, config: Partial<FRAGS.ItemsDataConfig> ) => { const elementsOfCategory = fragments.getItemsOfCategories([ safeRegExp(category), ]); const ids = Object.values(elementsOfCategory) .flat() .filter((id) => id !== undefined && id !== null); const itemsData = fragments.getItemsData(ids, config); return itemsData; };