dprojects / getDimensions

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

Dimensions of not-rectangle #8

Closed LeonB closed 2 years ago

LeonB commented 2 years ago

Thanks for the great project!

I tried it with a little organizer I'm designing. But the sides have a non-rectangular shape:

Screenshot 2022-06-29 at 00 23 37

The macro then doesn't calculate the outside dimensions correctly:

Screenshot 2022-06-29 at 00 23 19

It picks the dimensions of the first (smallest) rectangle. Not the outside dimensions what I would need to cut from my sheet.

I've attached the part as seen in the screenshot:

freecad-getdimensions-test.FCStd.zip

I've looked at the python script but I was a little bit too large to quickly find where the issue was.

dprojects commented 2 years ago

Hi, Leon, nice dog ;-)

If you use non-rectagle shape you have options:

  1. Change your project and make this shape from 3 rectangular pieces.
  2. Use Sketch and describe all needed constraints, than you can use c - report type
  3. You can generate p - report type to show all non-zero constraints and describe each one by hand at the piece of paper.

Feel free to reopen this issue if this not solved your problem.

Thanks Darek

LeonB commented 2 years ago

Thanks! I've opted to get the outside dimensions of the sketch via the get_sketch_dims function I copied from https://wiki.freecadweb.org/Macro_Shake_Sketch. Now it does what I want!

Screenshot 2022-06-29 at 22 41 55
dprojects commented 2 years ago

So, the code is not so hard if you were able to change it ;-) I make comments because in my opinion the open source code should be clear and well-documented, not spaghetti code.

Regarding the problem, it is depending from user's choice so it can't be calculated automatically correctly. Sketch allows you to draw anything, and you never know what constraints are the interesting ones, what shape it is, unless user mark the exact dimensions somehow. Also you have wrong m2 calculation because to calculate different shape than rectangle you need to know what shape it is and if this would involve curve you need to calculate it using integrals or even more advance mathematics. This is not for it ;-)

In my opinion it would be better to use c - report type because you can describe any shape like this. But if you are happy with this solution, why not.

LeonB commented 2 years ago

I supports what I need from it at the moment: a spreadsheet I can export to custlistoptimizer. Thanks for your hard work!

dprojects commented 2 years ago

I have already added new approximation report a - report type. This report calculate vertex in raw form but it has exactly the same columns order so it can be imported directly at this page ;-) Thanks for the info about this page, nice tool.

LeonB commented 2 years ago

@dprojects this is awesome! Works perfectly for my needs.

Shouldn't the thickness (now in column label) be in the column material? And then the name (like in the n report) be in the label column?

dprojects commented 2 years ago

n - report is special type of report but it is list of objects, the quantity there is always 1, so label of the object make sense. If you have items grouped by quantity, more than one, there can't be label of the single object, there should be some kind of group name, thickness can be. There is also g - report type with folder name.

Thickness in material column make sense to me. But the label would be empty then. I was thinking to add auto-edgeband but there is little problem with that. At normal cube you have 6 faces, for array there can be more faces. But at the report you have only 4 columns for edgeband. And even If you assign 1,2,3,4 faces from Cube you can't be sure this will be correct. Also you never know which one should be left or right.

About material column I was thinking more like type of wood, text not value, or color, oak, white or plywood. There are many options, depends what someone use. In fact at the custlistoptimizer the thickness is not used at all, because it is 2D optimizer.

It would be nice to fill automatically all the columns but this is little problematic as you see.

LeonB commented 2 years ago

Thanks! Clear. It's very usable as it is now. So no sweat keeping it as it is. I wouldn't mind if the qty is always 1 in that report and a label could get added.

The material column, in cutlistoptimizer at least, is for distinguishing the cuts for different sheets. So poplar ply 12mm vs poplar ply 18mm for example. But also white laminated 18mm vs black laminated 18mm for example.

dprojects commented 2 years ago

So maybe in this case the thickness should be at label and also at material? the object label is important for you? maybe at label it would be better to place group name? similar to this https://github.com/dprojects/getDimensions/tree/master/Docs#wood-properties---grain-type-color-etc so you would be able to add "18 mm, plywood, white" or something like that. Is there any custlistoptimizer documentation? what they say about those columns? how they describe the label and material column? are there any examples?

LeonB commented 2 years ago

@dprojects group name sounds like a nice solution!

No documentation about cutlistoptimizer as I can see.

Label is only used for labeling the pieces in the diagram.

Screenshot 2022-07-13 at 23 32 18

cutlistoptimizer_2022-07-13_230152

dprojects commented 2 years ago

You have Qty = 1 everywhere so this make sense. What if the Qty is != 1 ? there should be some kind of group name. The "18 mm, white" could be but in fact the next spreadsheet "Stock sheets" should have named sheets and if you have for example 2 sheets of "18 mm, white" and 1 sheet with "18 mm, black" and you want to cut 4 pieces with label "18 mm, brown" this should not be allowed. But the label, material columns are probably some kind of notes for user and they are not involved in calculation? the material column is checked somehow? if you want to cut Material 2 but you have only Material 1 this will be still allowed?

dprojects commented 2 years ago

Little improved. Material is thickness. Label is from group name. And grain direction also from group name. So missing part is only edgeband, maybe someday, because I have to recognize "exact size" and "edge type". https://github.com/dprojects/getDimensions/tree/master/Docs#a---report-type

LeonB commented 2 years ago

@dprojects I'm getting an error at the moment:

21:47:28  Traceback (most recent call last):
  File "/Users/leon/Library/Preferences/FreeCAD/Macro/getDimensions.py", line 3960, in <module>
    selectView("main")
  File "/Users/leon/Library/Preferences/FreeCAD/Macro/getDimensions.py", line 3861, in selectView
    setViewA(iCaller)
  File "/Users/leon/Library/Preferences/FreeCAD/Macro/getDimensions.py", line 2596, in setViewA
    g = more[1]
<class 'IndexError'>: list index out of range

If I create a new document with a standard cube and execute the getDimensions macro, report A, I get this error:

Screenshot 2022-07-23 at 21 52 22
dprojects commented 2 years ago

Well yes ;-) I forgot that someone may not want to use the group and comma syntax ;-) this should be in try block ;-) if you remove the fakeCube and put the Cube in any Group with name that contains comma this will be OK. I will fix it, soon.

LeonB commented 2 years ago

@dprojects thanks again!