Improvements to material editor and card handling

A forum to discuss the implementation of a good Materials system in FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
oliveroxtoby
Posts: 812
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: Improvements to material editor and card handling

Post by oliveroxtoby »

Kunda1 wrote: Thu Apr 13, 2023 1:44 am Guessing for them to look at the code and give some feedback ?

CC
@oliveroxtoby (CFDoF)
Looks good to me!
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Improvements to material editor and card handling

Post by grandcross »

Added support for modules specifying their own module folders. Here's what the preference file looks like:

Code: Select all

            <FCParamGroup Name="Resources">
              <FCBool Name="UseBuiltInMaterials" Value="1"/>
              <FCBool Name="UseMaterialsFromConfigDir" Value="1"/>
              <FCBool Name="UseMaterialsFromCustomDir" Value="1"/>
              <FCText Name="CustomMaterialsDir"/>
              <FCBool Name="UseMaterialsFromModules" Value="1"/>
              <FCParamGroup Name="Modules">
                <FCParamGroup Name="Rocket">
                  <FCText Name="ModuleIcon">C:/Users/dcarter/AppData/Roaming/FreeCAD/Mod/Rocket/Resources/icons/RocketWorkbench.svg</FCText>
                  <FCText Name="ModuleDir">C:\Users\dcarter\AppData\Roaming\FreeCAD\Mod\Rocket\Resources\Material</FCText>
                </FCParamGroup>
              </FCParamGroup>
            </FCParamGroup>
Each workbench will add a new FCParamGroup under "User parameter:BaseApp/Preferences/Mod/Material/Resources/Modules". The name is the name of the workbench, in this case "Rocket". Each group would then have the directory where materials are stored, and an icon to associate with materials defined by the module. I'll add another post to show sample code later.

In the preferences, I've added an option to use or ignore the workbench defined material definitions.
material-prefs.png
material-prefs.png (11.89 KiB) Viewed 5660 times
Material cards will then show in the drop down with their preferred icon
material-icons.png
material-icons.png (30.77 KiB) Viewed 5660 times
No attempt is made to resolve name conflicts. Cards are loaded in sequence, starting from system cards, workbench cards in the order in which they're defined, card in the user's FreeCAD preference directory, followed by cards in any user defined custom directory. If cards have the same name, the one loaded last will be the one used. This allows user modified cards to supersede system cards.
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Improvements to material editor and card handling

Post by grandcross »

Some code to set this from within your workbench:

Code: Select all

p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Material/Resources/Modules/Rocket")
p.SetString("ModuleDir", FreeCAD.getUserAppDataDir() + "Mod/Rocket/Resources/Material")
p.SetString("ModuleIcon", FreeCAD.getUserAppDataDir() + "Mod/Rocket/Resources/icons/RocketWorkbench.svg")
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Improvements to material editor and card handling

Post by Kunda1 »

This looks amazing!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Improvements to material editor and card handling

Post by grandcross »

Thanks!

Maybe post 0.21 I'll look at a more comprehensive material update. Maybe.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Improvements to material editor and card handling

Post by Kunda1 »

grandcross wrote: Mon May 08, 2023 11:32 pm Thanks!

Maybe post 0.21 I'll look at a more comprehensive material update. Maybe.
Yes, please!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Improvements to material editor and card handling

Post by grandcross »

Kunda1 wrote: Mon May 08, 2023 11:38 pm Yes, please!
I did a thing... :roll:

viewtopic.php?t=78242
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Improvements to material editor and card handling

Post by grandcross »

It's looking more and more like this PR won't be part of 0.21 despite being ready for months. This is very disappointing. By the time this gets merged it will likely be obsolete, and likely at least another year before any useful changes are made.

To say I'm disappointed is an understatement. I don't like wasting my time.
Post Reply