Menu

component attribute 'FREECAD' - picking the right variant *e.g., LED5MM-Red/Green/Blue/White/..."

Help
2022-09-01
2022-09-11
  • David Smart

    David Smart - 2022-09-01

    There's one or two requests in here -
    1. Update the documentation to how the component attribute 'FREECAD' is/should/can be used.
    2. Consider an enhancement to that, where the attribute is appended to the base package name.

    Memory/Research/Details
    I don't recall where exactly I learned about this - freecad-pcb will look for a custom attribute 'FREECAD' associated with a component. It can then use that attribute to choose the right package - overriding the package name that would have come from Eagle.

    I think the scenario I saw (which I can't find in the user guides) involved placing an LED of a given package (e.g. LED5MM), and then using this attribute to choose the Red/Blue/Green/White/... variant.

    As my memory serves:

    • Eagle schematic:
    • Add an LED with package LED5MM.
    • Set the FREECAD attribute for this component, for example, to "LED5MM-White".
    • Layout the PCB
    • Launch FreeCAD from the Eagle integration
    • PCB Renders and the LED5MM-White component is rendered on the board.

    I have previously set it like shown in the user guide, where I can add the R/B/G/W/... leds as variants, and then it asks me for each LED, but that is a bit cumbersome when there are many LED models under one component and each must be manually chosen in turn.

    I dug around in the code and found in librepcb.py:

     try:
         freecadPackage = re.sub('[^a-zA-Z0-9 _\+\.\-]+', '', re.search(r'\(attribute\s+"FREECAD".+?\(value\s+"(.+?)"\)\)', component).groups()[0])
     except:
    

    I re-discovered I can assign it FREECAD=LED5MM-White, and then FreeCAD-PCB will let me associate the 'missing' device into its db of parts and it shows properly.

    I was wondering if there is a more highly recommended way to do this.

    And if not, could it be a little simplified -

    • Starting with a "Base Part" (e.g. "LED5MM") which is properly associated in the db,
    • Create the attribute with a simpler "-White" (the '-' signifying that this attribute is a suffix to the package, not a replacement.
    • Since all of the colored LED5MM variant models were (likely) derived from a single model and just recolored, the rest of the db records x,y,z and rotations, would all be exactly as the base-model.
    • If the actual stp file doesn't exist (because now it doesn't have to be in the parts db), the user looks at the "Package" attribute in FreeCAD to see that it is set for LED5MM-White. Create it and update the part.
    • The variant is now rendered.

    Thanks for taking the time to review this!

    Using: FreeCAD 0.20, the latest PCB module that installs from the Tools | Addon manager. Eagle 7.7.0. Win11 host.

     
  • Mariusz

    Mariusz - 2022-09-04

    Hi,

    "I was wondering if there is a more highly recommended way to do this."
    Not at the moment.

    As for the second part, it won't be that easy at the moment. Currently, paths in DB are stored like this (one cell)

    led/0805_R.stp;led/0805_B.stp;led/0805_Y.stp;led/0805_G.stp

    So at the moment it is not possible to add an Attribute/Variant to the path - to do this it will be necessary to add a new table in the DB (with paths) or a new column in an existing table.

    I will check which solution will be the easiest to implement.

     
  • Mariusz

    Mariusz - 2022-09-11

    Hi,
    check version from github (testing branch): https://github.com/marmni/FreeCAD-PCB/tree/testing (use "database.db" file from github or make a backup of your file).

    Name of the attribute to change the model: FREECAD or FCM
    Name of the attribute to change the model version (def. path): FREECAD (value should start with --) or FCMV

    Check file from the attachment (for LED 0805 and 1206).
    It would be nice to get feedback.

     
  • David Smart

    David Smart - 2022-09-11

    Hi Marius,

    Here's my experience - as I'm performing it - for the most accurate notes:
    1) Make a backup of my PCB folder (which includes my db).
    2) Compare the testing branch - wow there's a lot of changes, and most (perhaps all) seem related to this request!
    3) Copy the testing branch over top of my version (I think it said there were 418 'overwrites').
    4) Copy my database.db over top of the testing/data/database.db
    5) Open the untitled.brd file, observe the 3 LEDs and their attributes FCM, FCMV and FREECAD, depending on the part.
    6) Launch FreeCAD/pcb against this .brd file
    7) Observe a dialog "Old database format detected - upgrading database format is required. This may take several seconds." Question to ponder - did I not properly backup and replace with your update?. Hit OK (the only option)
    8) PCB Settings dialog - observed the new (i) tips on Colorize, Adjust, and Group - nice!
    9) Selected all layers, and Debug import. Accept.
    10) Choose model appears, with the list of led/0805_R, B, Y, G. I had expected here that it would auto-select the right models based on the parts/db.
    11) Select one color for each choose model dialog.
    12) Image1,png, image2.png are the result.

    OK, let me repeat that with the db from the testing branch.
    1) Copy database.db from the testing branch over top of my db.
    2) Launch FreeCAD/pcb against the .brd file
    3) Select all and debug (as before)
    4) Observe that no dialog appeared as before (to update the db)
    5) Choose model appears, as before.
    6) Select one color for each choose model dialog.
    7) Resulting PCB model appears identical to the first trial.

    Studying the images you attached - I went in to the db to check the attributes on the LEDs.
    1) E$1 has package CHIP-LED0805.
    2) Opened the "Assign models" dialog into the db.
    3) Type "CHIP-" into the search and it went red with the '-'. The LEDs listed (matching 'CHIP' show "CHIPLED_0805", so a little different format.
    4) In Eagle, E$1 had special attribute FREECAD with value "--YELLOW". I'm uncertain how it chose an LED based on what I see here.

    Python console - nothing unusual shown there.
    Report View - most of it is just the 'typical' stuff I see, but being a little uncertain, here is part of it. Seeing that it imported different parts was confusing.

    10:19:29  PCB Workbench: Warning
        Incompatible FreeCAD version. Supported versions: 0.18-0.19.
    10:19:29  The file was created in Eagle 7.7.0.
    10:19:29  Read database
    10:19:38  
    Initializing
    Generate board: done
    Generate holes: Part::FeaturePython: Link(s) to object(s) 'PCB_Holes' go out of the allowed scope 'Board'. Instead, the linked object(s) reside within 'N/A'.
    10:19:38  done
    Importing parts: Package 'CHIPLED_1206' will be used for the element E$2 (instead of CHIP-LED0805).
    10:19:38  Package 'CHIPLED_1206' will be used for the element E$4 (instead of R1206).
    10:19:38  
        E$1 (CHIP-LED0805): No *.col file. It is necessary to generate a new one.
    10:20:39  done
        E$2 (CHIPLED_1206): done
        E$3 (CHIP-LED0805): No *.col file. It is necessary to generate a new one.
    10:20:46  done
        E$4 (CHIPLED_1206): done
    

    I think part of the problem may be that I am "not as familiar" with the PCB db configuration process - so perhaps not applying all the necessary changes that you would have taken for granted.

    side-note 1: for FreeCAD (0.20, but I think I had this on prior versions also). Even when 'Printed Circuit Board' is the starting module (Preferences), the toolbars for PCB don't always appear (but sometimes they do). If I switch workbench to anything else and back, then they do appear. I don't know if this is FreeCAD, or the PCB addon.

    side-note 2: on the PCB Settings dialog - a bit of text spilled outside where it was intended "Import polygons from copper layers". See Image3.png

    side-note 3: Since it might take another exchange of information. If there are code-changes required, perhaps a little bit of extra diagnostic would be helpful. When it modifies a part name based on the extra attributes, showing that into the report view may be helpful.

     

    Last edit: David Smart 2022-09-11
  • Mariusz

    Mariusz - 2022-09-11

    Hi,

    7) Observe a dialog "Old database format detected - upgrading database format is required. This may take several seconds." Question to ponder - did I not properly backup and replace with your update?. Hit OK (the only option)
    This is ok. My "database.db" file is in v3 format (new tables), yours was v2 (now it is v3).

    8) PCB Settings dialog - observed the new (i) tips on Colorize, Adjust, and Group - nice!
    These are very old modifications :)

    4) Copy my database.db over top of the testing/data/database.db
    10) Choose model appears, with the list of led/0805_R, B, Y, G. I had expected here that it would auto-select the right models based on the parts/db.
    11) Select one color for each choose model dialog.

    Did you add attributes to paths after using your "database.db" file? If not, you will see a dialog for each component (LED in this case).


    Ok, for component E$1 (package CHIP-LED0805) there is one attribute FREECAD="--YELLOW". So during importing the brd file the module will search for the package "CHIP-LED0805" (in this case it is model 0805 in the LED category) and will automatically load the 3D file which has the attribute value = "YELLOW" for the specified path.

    If you want to load different package you have to define specific attributes - for example E$4 where we want to import package FCM = "CHIPLED_1206" (LED -> 1206) with specific color FCMV = "BLUE" (if attribute does not exist you will see a dialog) instead of resistor R1206.


    side-note 1:
    I have the same, at the moment I do not know what is the reason.

    side-note 2:
    Ignore this option - I forgot to blank it :).

    side-note 3
    I will add annotations.

     

Anonymous
Anonymous

Add attachments
Cancel