[Fixed] Bug #2876: Value of Part::Thickness is missing unit

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

[Fixed] Bug #2876: Value of Part::Thickness is missing unit

Post by Kunda1 »

issue #2876: Value of Part::Thickness is missing unit
Description
It's inconvenient that "Part::Thickness" doesn't use "mm" units for "Value".

In the example below, to compute the inside diameter of a pipe, the (negative) wall thickness needs to be multiplied with "1mm" before adding to the outside diameter.

Steps To Reproduce

Code: Select all

App.newDocument("Unnamed");
Cylinder = App.ActiveDocument.addObject("Part::Cylinder", "Cylinder")
Gui.ActiveDocument.Cylinder.hide()
Pipe = App.ActiveDocument.addObject("Part::Thickness", "Pipe")
Pipe.Faces = (Cylinder, ["Face2", "Face3"])
Pipe.Mode = 1
Pipe.Value = -1 # negative wall thickness
Spreadsheet = App.ActiveDocument.addObject('Spreadsheet::Sheet', 'Spreadsheet')
Spreadsheet.set('A1', 'Pipe OD')
Spreadsheet.set('B1', 'Pipe WT')
Spreadsheet.set('C1', 'Pipe ID')
Spreadsheet.set('A2', '=2*Cylinder.Radius')
Spreadsheet.set('B2', '=-Pipe.Value*1mm')
Spreadsheet.set('C2', '=2*(Cylinder.Radius + Pipe.Value*1mm)')
App.ActiveDocument.recompute()
# double click Spreadsheet, click on C2 field
Additional Information
Maybe introduce a new property "Offset" that is aliased to "Value" but uses "mm".
Last edited by Kunda1 on Sun Jul 23, 2017 9:09 pm, edited 1 time in total.
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
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #2876: Value of Part::Thickness is missing unit

Post by Kunda1 »

DeepSOIC wrote:...
This is pretty low priority.. but nevertheless, wanted to check if it has merit to keep in the bugtracker.
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
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Bug #2876: Value of Part::Thickness is missing unit

Post by DeepSOIC »

There is a more serious bug associated with this, which I probably forgot to put on tracker. There is a unit mismatch between field in offset dialog and the property, which causes problems with expression support. E.g. an expression with a unit, accepted by dialog, will fail to be bound to a unit-less Value property.

I thought I wrote a report and assigned it to myself, but apparently I didn't :oops: . Because I added the expression support to the dialog, effectively creating the bug. And I knew about it before I even made pull-request. I was just too lazy to upgrade property type, because it involved writing porting code for support of old projects (and it came along with big new thing called 2D Offset).
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #2876: Value of Part::Thickness is missing unit

Post by Kunda1 »

@eivindkvedalen submitted PR#894 as a fix.
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
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Bug #2876: Value of Part::Thickness is missing unit

Post by Kunda1 »

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
Post Reply