npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

freecad-preview-extractor

v0.1.2

Published

Script extracting freecad previews

Readme

FreeCAD preview extractor

Tests and Lint Integration Tests

A CLI tool for extracting and generating preview thumbnails from FreeCAD files.

Preview is extracted for each FILENAME.FCStd file as FILENAME-preview.png

Features

  • Extract existing previews: Quickly extract embedded thumbnail images from .FCStd files
  • Generate new previews: Use FreeCAD to create fresh previews with isometric view and fit-to-view
  • Batch processing: Process all FreeCAD files in a directory recursively
  • Single file mode: Extract or generate previews for specific files
  • Ignore patterns: Use an ignore config file (like .gitignore) to exclude specific files from batch processing

Installation

Install globally:

npm install -g freecad-preview-extractor

Or run directly with npx:

npx freecad-preview-extractor

Usage

Extract existing previews from all FreeCAD files

fcxtc

or

freecad-preview-extractor

Extract preview from a specific file

fcxtc filename.FCStd

Generate preview with FreeCAD before extraction (requires FreeCAD and desktop environment)

Adding --fit argument will trigger src/isometric-fit.FCMacro FreeCAD macros for each file, the macros sets model to the isometric view, does "fit into view", and saves the file.

fcxtc --fit

or for a specific file:

fcxtc --fit filename.FCStd

Ignore specific files during batch processing

fcxtc --ignore-config .myignore

Create an ignore file (e.g., .myignore) with patterns to exclude:

# Ignore all files in the archived directory
archived/*.FCStd

# Ignore specific files
test-model.FCStd

# Ignore files with specific naming pattern
*backup*.FCStd

The --fit option will:

  1. Open each FreeCAD file with FreeCAD
  2. Run the isometric-fit.FCMacro macro to set Isometric View and Fit All
  3. Save the file with the updated preview
  4. Extract the preview image as usual

The --ignore-config option allows you to exclude specific files from batch processing using pattern matching similar to .gitignore:

  • Supports wildcards (*, ?)
  • Supports ** for recursive matching
  • Supports character ranges ([abc])
  • Lines starting with # are treated as comments
  • Empty lines are ignored

Note: The --fit option requires:

  • FreeCAD installed and available in your system PATH
  • A desktop environment / X server (cannot run headless)
  • UI access for FreeCAD to render the view

Note: The --ignore-config option only works in batch processing mode (when no specific file is provided). It is ignored in single-file mode.

Testing

The project has comprehensive test suites covering unit logic and integration scenarios.

Unit Tests

Run unit tests for core logic (path handling, ignore patterns, etc.):

npm test

Integration Tests

Integration tests are split into two categories based on whether they require a local FreeCAD installation.

1. Standard Integration Tests (No FreeCAD required) These tests check file extraction, CLI behavior, and ignore patterns without invoking FreeCAD.

npm run test:integration-no-freecad

2. Full Integration Tests (FreeCAD required) These tests involve the --fit flag and spawning the FreeCAD process. They require FreeCAD to be installed and available in the system PATH.

npm run test:integration

Note for Developers:

  • Tests ending in .test.js do not require FreeCAD.
  • Tests ending in .test-freecad.js require FreeCAD.

Utilities

The project exports utility functions that can be used programmatically:

  • loadIgnoreConfig(filePath, cwd) - Load ignore patterns from a file
  • filterIgnoredFiles(filePaths, rootDir, patterns, enabled) - Filter files based on patterns
  • shouldIgnoreFile(filePath, rootDir, patterns, enabled) - Check if a single file should be ignored

Development

To set up the project for development:

git clone https://github.com/andruhon/freecad-preview-extractor.git
cd ./freecad-preview-extractor
npm ci
sudo npm install -g ./

Project Files

Key files of the project (not including all files):

  • src/index.js - Main CLI entry point
  • src/extract-png-from-fcstd.js - Thumbnail extraction logic
  • src/isometric-fit.FCMacro - FreeCAD macro for isometric view and fit (used by --fit option)
  • tests/ - Unit tests for ignore functionality

License

MIT