Documentation
Go to AppSign InSign Up
    Getting Started
    • Introduction to Flux
    • What is Flux?
    • Quick Start
    • The Flux Method
    • Creating an Account
    • Flux for Organizations
    • Setting Up Your Browser
      • Mouse & Trackpad
      • Multi-Screen Operation
      • Keyboard Shortcuts
    • Your First PCB in Flux
      • DFM & Export
      • PCB Layout & Routing
      • Project Setup
      • Schematic
      • Export & Manufacturing
    • KiCAD to Flux
      • Layout
      • Parts & Libraries
      • Schematics
    • Eagle to Flux
    • EasyEDA to Flux
    • Upverter to Flux
    • Altium to Flux
    • Getting Help
    Tutorials
    • Tutorials
    • Getting Started With Flux
      • Customizing Flux
    • Flux Use Cases
      • AI Architecture Design
      • AI Component Research
      • AI Design Reviews
      • AI Testing & Debugging
      • AI Auto-Layout
      • Generative AI
    • Start Learning Flux, No Matter Your Skill Level
      • Advanced Designer
      • First Time Designer
      • Intermediate Designer
    • Power Regulator
      • 1 – Part Selection
      • 2 – PCB Layout
      • 2 – Schematics
    • Routing
      • High-speed Routing
      • High Density Designs (HDI)
      • Working with Polygons
    • Adding Components to the Library
      • Publishing Components to the Library
      • Creating Components from Scratch
      • Importing Components
      • Working with Footprints
      • Working with Symbols
    • What is a Module?
      • Module Design Best Practices
      • Creating Modules
      • Using Modules
    • Generic Components
      • Creating a generic part
    • Copper Fills Tutorial
      • Creating Copper Cutouts
    • Board Outline Shape and Size
    • The Toolbar
    • Using Layout Rules
    • Intro to collaboration
    • Embedding a Flux Project
    • Reviewing component updates
    • Version Control Deep Dive
    • Custom Shapes
    • AI-Assisted Design with Flux
    • PCB Design Reviews (DRC)
    • Component Placement
    • Component Procurement
    • Multi-Layer PCB Design
    • Working with Ground Signals
    • Reusing Projects
      • Useful links
    Reference
    • Flux Context Menu
    • Calculator Tool
    • Change Project Name
    • Code Tool
    • Convert to component
    • Flux ACUs
    • Overview
    • Data Portability
    • Delete & Archive Projects
    • Design Rule Check (DRC)
    • Expressions
    • File Tool
    • FMEA Report Generation
    • Gerber Exports
    • Help Tool
    • Special Part Types
    • JEP30 PartModel Import/Export
    • Knowledge Base
    • Library Tool
    • Managing Units
    • Measuring Distances
    • Model Selection
    • Nets and Traces
      • Curved Traces
      • Impedance Control
      • Trace Width
    • Object Types
      • AssetNode
      • ControlNode
      • ElementNode
      • ElementTerminalNode
      • OutputNode
      • PropertyNode
      • RouteNode
      • RouteTerminalNode
    • Pads & Holes
    • Passive Component Consolidation
    • Layout Rules Reference
      • Layout Rules List
      • Object-Specific Layout Rules
      • Selector-Based Layout Rules
      • Layout Rules Inheritance & Precedence
      • Layout Rules Modifiers
    • Polygons
    • Comments
    • Cursors
    • Forking & Cloning
    • Copper Fills
    • Importing Schematics
    • Importing Components
    • Schematic Inspector
      • Assets Panel
      • Pricing & Availability Panel
      • Properties Panel
      • Simulation Panel
    • The Library
    • Project Launcher
      • New Blank Project
    • Layout Object Tree
      • PCB Object Types
    • Schematic Object List
    • The PCB Editor
      • Locking
      • Layer View Control
      • Positioning & Routing
      • Selecting Objects
      • Stackup Editor
    • Permission Tiers
    • Preloaded Examples
    • The Profile Page
      • Featured Projects
    • The Schematic Editor
      • Positioning & Wiring
    • Global Search
    • Sharing & Permissions
    • History & Version Control
    • Silkscreen
    • Simulator Tool
    • Star a Project (Favorite)
    • Vias
      • Smart Vias
    Copilot
    • Copilot Overview
    • Model Selection
    • Flux ACUs
    • Knowledge Base
    • Flux Context Menu
    • Calculator Tool
    • Code Tool
    • File Tool
    • Help Tool
    • Library Tool
    • Simulator Tool
    • FMEA Report Generation
    • Passive Component Consolidation
    FAQ
    • Schematic Editor
    • General FAQs
    • Flux and AI FAQs
    • PCB Editor FAQs
    • Parts and Modules
    • Pricing
    • Private and public projects
    • Data security and IP protection
    • When things go wrong: Errors and how to handle them
      • Lost connection
    Legal
    • Terms of Service
    • Privacy Statement
    • Main Services Agreement
    • Subprocessors

Tutorials

Generic Components

Creating a generic part

Tutorials

Creating a generic part


Making a part generic is a powerful way to add versatility to your parts and increase their reusability. A generic part is one where the specific properties of a part, such as a footprint and 3D model, can be determined later while always maintaining the fundamental properties of the part.

Before beginning to design your own generic part, search Flux's built-in part library to see if there is an option that already fit your needs.

To create a generic part, follow the instructions below:

  1. Open a new project in Flux or fork a part that you wish to make generic.
  • Make sure the pin numbers on the terminals of the part are numbered correctly. This is important for the footprint to be loaded properly. (e.g A resistor usually have 2 terminals should have pin number value of 1 for the terminal P1 and pin number value of 2 for the terminal P2).
  • Make sure your part has a footprint and model node as shown below. If you don't see footprint and model nodes in the Objects panel, just right click on the Root folder then add footprint and/or model from there. Also, the object ID's of these nodes will be important when it comes to the code for generics (don't worry, it is already written for you!).

  1. Add the "Asset" object-specific rule to both the footprint and the model nodes. This is what allows the footprint and model to be imported from a file. Here's what you need to know about adding assets.

  1. Open the Manage Assets panel then upload all of the generic footprints and models as assets to the project. These will be the forms that your part can take.

  • Make sure that the asset ID of each footprint is a concise description of the footprint itself. This is what will have to be entered to select that specific footprint for the part. For example: SMD_2010_5025Metric is any surface mounted devices (SMD) 0.20 inch long and 0.10 inch wide (5.0 mm long and 2.5 mm wide)
  • The asset ID of the 3D model should be the same as the appropriate footprint ID. For example: 3DSMD2010_5025Metric.
  1. In the project properties tab on the right hand side of the schematic editor (when nothing is selected) create a new property called "Package" This is where you need to put all the id of the asset as Autocomplete options.

  1. Go into code editor. Below is all of the code that is needed to implement generics for your part. All you have to do is copy paste this into your generic part's code section.
// Footprint node and Model node ID
const footprintID = "<FOOTPRINT NODE ID HERE>";
const modelID = "<MODEL NODE ID HERE>";

// Declare specific footprint and model node based on their ID as a PcbLayoutNode
const footprintNode = flux.getNodeById(footprintID) as PcbLayoutNode;
const modelNode = flux.getNodeById(modelID) as PcbLayoutNode;

// This will sort and return an array of all available assets in the project with file type .kicad_mod
const footprintAssetNotSorted = flux.assets.filter((asset) => asset.fileType === "kicad_mod").map((asset) => asset.name);
const footprintAssetId = footprintAssetNotSorted.sort();

// This will sort and return an array of all available assets in the project with file type .step
const modelAssetIdNotSorted = flux.assets.filter((asset) => asset.fileType === "step").map((asset) => asset.name);
const modelAssetId = modelAssetIdNotSorted.sort();

// This checks if footprint and model node has Asset rule
if (footprintNode || modelNode) {
    const assetFootprintRule = footprintNode.rules.find((rule) => rule.key === "asset");
    const assetModelRule = modelNode.rules.find((rule) => rule.key === "asset");

		// First, look for property that is named "Package", then use its value to 
		// set the Asset rule value for footprint node and model node.
    flux.on("setup", () => {
        const property = flux.properties.find((prop) => prop.name === "Package");
        if (property) {
            changeFootprintAsset(property.value);
            changeModelAsset(property.value)
        }
    });

		// Listen to any change in the Package property, if change has been detected
  	// set the Asset rule value for footprint node and model node.
    flux.on("propertyChange", (event: PropertyChangeEvent) => {
        if (event.property_name === "Package") {
            changeFootprintAsset(event.value);
            changeModelAsset(event.value);
            flux.notify(event.property_name + " changed to " + event.value, {
                variant: "success",
                });
        }
    });

    // Given a package property value, this set the correct assetID for footprint node
    function changeFootprintAsset(propertyValue: any) {
        if (assetFootprintRule) {
            for (let i = 0; i < footprintAssetId.length; i++){
                if (propertyValue === footprintAssetId[i]){
                    assetFootprintRule.value = footprintAssetId[i];
                    footprintNode.name = footprintAssetId[i];
                    break;
                } else { 
                  // Else, if user didn't selected any pre-set value from the dropdown,
                  // default to 0603 Package
                    assetFootprintRule.value = "SMD_0603_1608Metric";
                    footprintNode.name = "SMD_0603_1608Metric";
                };
            }
        }
    }

    // Given a package property value, this set the correct assetID for a model node
    function changeModelAsset(propertyValue: any) {
        if (assetModelRule) {
            for (let i = 0; i < modelAssetId.length; i++){
                if (propertyValue === footprintAssetId[i]){
                    flux.notify(footprintAssetId[i], {variant: "success",});
                    assetModelRule.value = modelAssetId[i];
                    modelNode.name = modelAssetId[i];
                    break;
                } else { // Else, if user didn't selected any pre-set value from the dropdown, 
                  // default to 0603 Package
                    assetModelRule.value = "3DSMD_0603_1608Metric";
                    modelNode.name = "3DSMD_0603_1608Metric";
                };
            }
        }
    }
};
  1. Once you pasted the code above, the only thing you will have to modify is the footprint and model ID that are required at the top of the code. The underlined text below is the object ID of the footprint node.

Object ID of Footprint node

Below is just an example.

// Footprint node and Model node ID
const footprintID = "a4e3b169-dc6b-4941-bb49-bebd1c2c19e8.defaultFootprint";
const modelID = "3d59e9a9-6410-8a17-e49e-984f31beee43";
  1. To set a default footprint and model for the generic part, add the ID of the desired asset to the footprint and model asset object-specific rule of the part. This will be the initial footprint and model until it is changed via the "Package" property. The package property as well should be set to the default ID before the part is published.
  2. Publish the part and use it in other projects. To change the footprint, just enter the ID of the asset you would like it to take form of and it will change the footprint and model appropriately.

Previous

Generic Components

Next

Copper Fills Tutorial