Assembly3: Help reusing object class.

Discussion about the development of the Assembly workbench.
User avatar
jruiz
Posts: 174
Joined: Tue Oct 28, 2014 1:07 pm
Contact:

Assembly3: Help reusing object class.

Postby jruiz » Thu Nov 22, 2018 2:32 pm

Good morning.
Could anybody give me some hints for doing the following?
  1. Suppose an object o, of certain class c depending on n parameters, p1, p2,..., is located in file f
  2. Suppose an assembly consisting on m objects, o1,o2,..., of class c is done in file a.
  3. Suppose o1, o2,... are almost the same but differs each other on, say, just one or two parameters.
How this task could be done reusing existing code on file f?
Is it possible to avoid file duplication?

Regards.
I have uploaded some FreeCAD video tutorials to www.youtube.com/yosoyvenezolano
User avatar
ceremcem
Posts: 211
Joined: Sun Jan 07, 2018 11:10 am

Re: Assembly3: Help reusing object class.

Postby ceremcem » Mon Dec 03, 2018 3:46 am

No, currently not. However @realthunder works on this one: https://forum.freecadweb.org/viewtopic. ... 20#p265391

Currently I'm performing such operations with spreadsheet + macro:
1. Suppose you placed a spreadsheet s in your file f which provides the parameters p1,p2,....
2. Place a regex in a cell to parse the filename f to generate p1, p2, ...
3. Use the following macro to parse the filename and generate the parameters: https://github.com/ceremcem/assembly-dimensions

Now your workflow will look like this:

1. Design your model (say this is a bolt)
2. Copy and paste your fcstd file with appropriate names (such as "M2x15mm.fcstd", "M3x20mm.fcstd", etc...)
3. Open the files you just copied
4. Run the macro to update the parameters
5. Use those files (models) in your actual model.
6. When it's time to make some updates in your "bolt" model, delete all copies
7. Make your changes
8. Re-copy with the same names (okay, you may need a bash script for that purpose)
9. Open every newly created file again
10. Run the macro to update the parameters
11. Your model will be updated accordingly.

Those pin-headers are made with this approach: https://github.com/ceremcem/FreeCAD-Asm ... pin-header
User avatar
ceremcem
Posts: 211
Joined: Sun Jan 07, 2018 11:10 am

Re: Assembly3: Help reusing object class.

Postby ceremcem » Tue Apr 02, 2019 4:53 am

Solved by Expression Engine, see this example. Workflow is as follows:

1. Enter your parameter parsing regex into a cell.
2. Extract the variant parameters into the other cells (see the example).
3. Save your model.
4. Duplicate your model with any possible name you like.
5. Import as usual.

Upgrading the model:

If you make any enhancements in your model and want to propagate the changes to all of the variants, follow the steps:

1. Save your new model as the base model.
2. Delete all auto-generated models.
3. Re-populate the models.