[ Ticket #4430 ] [ Bug ] Mesh_BuildRegularSolid: parametric props have no units in Property editor

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
User avatar
Roy_043
Posts: 1897
Joined: Thu Dec 27, 2018 12:28 pm

[ Ticket #4430 ] [ Bug ] Mesh_BuildRegularSolid: parametric props have no units in Property editor

Postby Roy_043 » Wed Jul 29, 2020 1:34 pm

If you create a mesh object with the Mesh_BuildRegularSolid command the dialog box shows parameters with units, but once created those same parameters are displayed in the Property editor without units. See attached image.

A bug IMO.

Code: Select all

OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22111 (Git)
Build type: Release
Branch: master
Hash: cb2099aa6bb287a8d7843eb70684cce79bdef26b
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Dutch/Netherlands (nl_NL)
Attachments
Mesh_BuildRegularSolid_NoUnits.png
Mesh_BuildRegularSolid_NoUnits.png (23.22 KiB) Viewed 306 times
Last edited by Roy_043 on Mon Sep 07, 2020 8:44 am, edited 1 time in total.
chrisb
Posts: 27983
Joined: Tue Mar 17, 2015 9:14 am

Re: [ Ticket #4430 ] [ Bug ] Mesh_BuildRegularSolid: parametric props have no units in Property editor

Postby chrisb » Mon Sep 07, 2020 11:53 am

I can confirm (a bit late, because the error report exists already :roll: ) and add that with a different unit system things are worse: While the creation dialog works correctly the values in the property editor are always in mm. For the inattentive user this could lead to problems.
User avatar
Roy_043
Posts: 1897
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Ticket #4430 ] [ Bug ] Mesh_BuildRegularSolid: parametric props have no units in Property editor

Postby Roy_043 » Mon Sep 07, 2020 12:38 pm

chrisb wrote:
Mon Sep 07, 2020 11:53 am
a bit late
I would say that you are 5 weeks late. :lol:
LXC
Posts: 16
Joined: Mon Sep 07, 2020 3:05 pm

Re: [ Ticket #4430 ] [ Bug ] Mesh_BuildRegularSolid: parametric props have no units in Property editor

Postby LXC » Mon Sep 07, 2020 3:34 pm

@chrisb is right. This issue is worse than the bug report indicates. The values' Formula editor is stuck in mm, even when global preferences are changed to another unit system. This means that the spreadsheet is stuck in metric, too. This is terrible. I am new to FreeCad, and I immediately encounter a significant issue with units?! How is anyone using this app like this?

1. I set my units to 'Imperial decimal'.
2. In the Formula editor, I edit the Height of a cylinder as: 0.5
3. The Formula editor result shows: 0.0197 in (because it inferred my unit-less input was mm, despite my default unit being in)

Workaround: If I use 0.5in then the editor properly converts my inches to inches. No conversion should occur or be necessary.

The Spreadsheet is also broken. If I bind a value to a cell that just has a number, like my 0.5, the drawing treats it as 0.5mm; yet, if I enter 0.5in in the spreadsheet cell, when I leave the cell, the spreadsheet converts it to 12.7mm.

Workaround: I need two dimension columns in my spreadsheet: one in inches, to match my materials, then one converted to mm, to bind in the Formula editor since FreeCAD forces me to use mm, even with my units set to inches.

These are serious bugs, regarding the fundamental "interface" of the app: units of measure.

Have these been addressed in the v19 pre-release?
vocx
Posts: 5206
Joined: Thu Oct 18, 2018 9:18 pm

Re: [ Ticket #4430 ] [ Bug ] Mesh_BuildRegularSolid: parametric props have no units in Property editor

Postby vocx » Mon Sep 07, 2020 5:12 pm

Roy_043 wrote:
Wed Jul 29, 2020 1:34 pm
...
A bug IMO.
It's not a bug because the object works as designed. Nevertheless, it probably could be improved.

https://github.com/FreeCAD/FreeCAD/blob ... #L147-L164

Code: Select all

class Cube : public Mesh::Feature
{
  PROPERTY_HEADER(Mesh::Cube);

public:
  Cube();
  App::PropertyFloatConstraint Length;
  App::PropertyFloatConstraint Width;
  App::PropertyFloatConstraint Height;

  /** @name methods override Feature */
  //@{
  /// recalculate the Feature
  App::DocumentObjectExecReturn *execute(void);
  short mustExecute() const;
  //@}
};
As I can see, the issue is that the properties of these objects (Cube, Cylinder, Cone, etc.), are App::PropertyFloatConstraint. This type of property allows you to enter floats, but doesn't manage units.

Normally, parametric objects that have dimensions use App::PropertyLength properties so you can enter any length unit defined in the system.

Code: Select all

public:
  Cube();
  App::PropertyLength Length;
  App::PropertyLength Width;
  App::PropertyLength Height;
If you want to test, make this change, compile, and verify that it works well. I think that this shouldn't cause compatibility problems because when an older object is loaded the properties (Length, Width, and Height for example) will be automatically migrated from the simple float, say, 10.0, to a "length", say, 10.0 mm.

Why is it using PropertyFloat and not PropertyLength? Probably historical reasons. These objects seem to be quite old, created before 2010 or so; maybe at that time the unit system didn't exist like it does today, and the code was never updated.

Or maybe Werner can comment on whether this was a conscious decision with meshes; in many programs that use meshes (FE analysis), the mesh is unitless because there are options to set units globally (each value is assumed to be either mm, or cm, or m, etc.).
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
Roy_043
Posts: 1897
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Ticket #4430 ] [ Bug ] Mesh_BuildRegularSolid: parametric props have no units in Property editor

Postby Roy_043 » Mon Sep 07, 2020 6:13 pm

LXC wrote:
Mon Sep 07, 2020 3:34 pm
Have these been addressed in the v19 pre-release?
The issue discussed in this topic, as indicated in the OP, affects the V0.19 version. It still exists in the version listed below. If you are now using V0.18, you should definitely upgrade to V0.19. There have been many improvements. But please start a new topic for any issues that you find.

Code: Select all

OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22366 (Git)
Build type: Release
Branch: master
Hash: 34c11fcc63efa2fc72cbc74c75c76e9f19d5c84c
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Dutch/Netherlands (nl_NL)
User avatar
Roy_043
Posts: 1897
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Ticket #4430 ] [ Bug ] Mesh_BuildRegularSolid: parametric props have no units in Property editor

Postby Roy_043 » Mon Sep 07, 2020 6:16 pm

vocx wrote:
Mon Sep 07, 2020 5:12 pm
It's not a bug because
Strictly speaking you are probably right. But looking at this from a broader UI/UX perspective I would still call it a bug.
chrisb
Posts: 27983
Joined: Tue Mar 17, 2015 9:14 am

Re: [ Ticket #4430 ] [ Bug ] Mesh_BuildRegularSolid: parametric props have no units in Property editor

Postby chrisb » Mon Sep 07, 2020 8:50 pm

vocx wrote:
Mon Sep 07, 2020 5:12 pm
It's not a bug because the object works as designed.
That's not how it's designed, that's how it is implemented.
While LXC talks about something different - he wants to have a default input unit for expressions - the situation with the Mesh solid is different: It shows the number in the property fields were no mm are expected. A tracker entry is perfectly jusitfied, be it as bug or be it as feature request.