dprojects / getDimensions

FreeCAD macro to get chipboards dimensions to cut
MIT License
22 stars 4 forks source link

Compound objects nested in arrays not correctly counted #10

Closed johndoe2323 closed 1 year ago

johndoe2323 commented 1 year ago

Dear Darek - many thanks for your efforts and for providing the excellent getDimensions and Woodworking for free!

I have the following issue: as arrays only allow one nested object, I make compound objects from the Part workbench. In my case, I made a bunch of drawers, generated a compound object, then put that object into an array. Unfortunatley the getDimensions macro does not count all parts properly, it only counts the part from one compound object.

This bug can be recreated as follows:

  1. new document
  2. create two cubes in Part workbench
  3. create a compound object in Part workbench of the two cubes
  4. create an array in the Draft worbench
  5. call getDimensions macro
johndoe2323 commented 1 year ago

Darek, I see that scanObjects has no subroutine for handling compound objects. I have trouble setting up a basic development environment for adding that sub-routine, e.g. how to connect Visual Studio Code to the FreeCAD process for debugging and how to reload your module (import importlib; importlib.reload(WoodworkingWorkbench) did not work). Do you have an article how to jump start into development - all the links on the official FreeCAD-documentation (https://wiki.freecadweb.org/Python_Development_Environment) did not help... Thanks!

dprojects commented 1 year ago

Who taught you to model like that? What is the purpose of creation compound object and Array on that? However there are more stupid approaches at FreeCAD, for example MultiTransform on MultiTransform. But who calculate that? Ancient aliens?

This tool supports Array on Array. It not support Compound objects at all. It supports LinkGroup instead. So it is obvious the objects hidden behind Compound is not visible for this tool.

Currently I am busy with "containers support" so I don't have time to add support for "Compound". The containers feature is complicated feature and the biggest ever, however I have almost everything done. So maybe soon I will look into that.

FYI: To be honest I still thinking if I am doing right to share the code for free. I like coding but maybe I should not share the code, I am not sure.

johndoe2323 commented 1 year ago

Hi darek, you are right! I replaced the compound object with a Std_Part and getDimensions worked flawlessly. It also worked with the LinkGroup feature. I'm not sure though, which way is the better modelling technique. Both are only available in the PartDesign workbench - the compound object was recommended in the FreeCAD forum as a standard tool in the Part workbench...

dprojects commented 1 year ago

the compound object was recommended in the FreeCAD forum as a standard tool in the Part workbench...

FreeCAD forum, I knew ;-)

I'm not sure though, which way is the better modelling technique.

If you want to calculate objects, you want BOM, cut-list, you should rather avoid packing objects. This tool support many complicated, packed, objects, but there many combinations not-supported yet. The "Compound" is one of them.

Maybe I will commit the workbench soon, so I will look into that. However, I thinking if should I freeze the current state before commit, because the "containers feature" touch almost everything, it is almost new workbench. So this may have too big impact...

johndoe2323 commented 1 year ago

Can you share your development workflow - most of my desired code changes are pretty obvious but the lack of a debugging environment or the ability to reload the woodworking workbench is really a hinderance...

dprojects commented 1 year ago

Can you share your development workflow - most of my desired code changes are pretty obvious but the lack of a debugging environment or the ability to reload the woodworking workbench is really a hinderance...

I don't understand what you mean... you don't have to reload workbench if you change tool. If you change library you have to only reload the library, so you don't have to restart FreeCAD. To reload library I use simple script:

import sys

try:
    del sys.modules["MagicPanels"]
except:
    skip = 1

try:
    del sys.modules["MagicPanelsController"]
except:
    skip = 1

try:
    del sys.modules["RouterPatterns"]
except:
    skip = 1

For debugging I use:

FreeCAD.Console.PrintMessage("\n\n")
FreeCAD.Console.PrintMessage(oRef.Label)

very often I use scanObjects If you change workbench init files, config, adding new tool, icon, than yes, you have to restart FreeCAD.

dprojects commented 1 year ago

I made fix for array on compound, so you can test it. Feel free to reopen this issue if this is not working correctly.

johndoe2323 commented 1 year ago

thanks!

johndoe2323 commented 1 year ago

Darek, unfortunately not working. My test:

  1. create new file
  2. create two cubes in Part wb
  3. combine both cubes into a compound object
  4. switch to Draft wb
  5. make an array of the compound object
  6. switch to Woodworking wb
  7. create report
  8. only two cubes are counted

array_with_nested_compound_part.zip

dprojects commented 1 year ago

Darek, unfortunately not working. My test: array_with_nested_compound_part.zip

Your file works for me, it return 4 Cubes. Make sure you have latest version updated correctly. Sometimes macro are cached and the old version is executed.

johndoe2323 commented 1 year ago

You are right - it works - I guess I was using an older FreeCAD instance in my previous test. Many thanks for fixing this so fast!