Per-project metrics

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
actuatedgear
Posts: 3
Joined: Wed Dec 22, 2021 8:01 pm

Re: Per-project metrics

Post by actuatedgear »

Well it's a good trick but that still has my units displayed wrong and me swapping the display for that purpose every time I change to those uses.

Thanks. Any thoughts on the coding?
kjeib
Posts: 4
Joined: Wed Jun 20, 2018 11:33 pm

Re: Per-project metrics

Post by kjeib »

I would like to see units selectable at three levels:

- User preferences
- File (document)
- Dimension property

When you create a dimension, you would be able to specify the units to display for that dimension only. If nothing is specified, the system would look to the file default, if one has been specified. If none is given, the measurement displays according to the user preference.

This would allow individual files to work with inches, feet, mm, meters, angstroms, etc. But even individual dimensions within a document could display differently. No reason why even a purely metric project might not want to use cm in some places and mm elsewhere.
fmccourry
Posts: 4
Joined: Thu Jun 10, 2021 2:20 pm

Re: Per-project metrics

Post by fmccourry »

PLEEEASE......
AgCaliva
Posts: 1
Joined: Tue Mar 07, 2023 9:32 am
Contact:

Re: Per-project metrics

Post by AgCaliva »

Hi people i want to do this, i have readed carefully all your input and most of the things said i agree.
Talking a bit precise and to make sure we are on the same line i would say that:
yorik:
I'm not sure a per-project setting is the best path, because some people will want to adopt the file unit when opening the file, some not.
I'd be more in favor of adding an easy units switch to the UI, like I did with the BIM workbench. For me that solved it all, one mouse click to change the unit.

It seems to me the best path for that would be to add a field in File -> Project information
TODO:
Maybe an action btn with "Apply user metrics" and other "Apply project metrics" or switch in preferences?

It seems to me the best path for that would be to add a field in File -> Project information
-----------------------
mtsinc:
I'd say that there's a lot of sense in enforcing the unit system in a project. I seem to recall that a rather valuable space probe was allegedly lost because people weren't paying proper attention to the unit system being used.
I think each user should control which system of measurement is being used(from the project one or from user)
via an switch in menu when opening file or something similar.

mtsinc:
I briefly toyed with the idea of putting in a plea to make the project header also remember the last workbench used before saving, but recollected that things of that nature probably better go in the user's local metadata not the project - based on how I've seen that work in IDE's, where sharing projects is rampant.
I agree. It should use some user metadata or app metadata.
mtsinc:
I've been playing with the source code and getting per-project metrics injected into each project is easy enough, but the other half of the task is re-rendering the MainWindow when you switch to reflect the new settings. When you change global metrics, this event fires automatically, but I can't tell what sets it off - it's "magic". If anyone could steer me in the right direction, it would be very helpful!
I haven't attempted to offer it, however, because even though I can shift the metrics internally, there's not any good event I can find to fire to cause the change to propagate when switching view panes. This is especially noticeable when opening a project file.

It would be nice if there was something for this. For one thing, even with the current every-project-the-same setup I've seen the units changes lag on recent production releases.

There's obviously some existing mechanisms, since you can change your metric system via the master properties dialog and the UI will update, but I haven't been able to make that work as an internally-invoked function fired from the tab-
activation logic. I need something I can broadcast the change to.
I will try to look for that and provide you some help in general, then you can share your code or as you want so we put everything together.
-----------------------
chrisb:
You can use different instances of FreeCAD using different config files. All metric stuff is then edited in the metric instance and imperial models are modeled in the imperial instance. Instead of switching tabs it is switching applications.
I dont think that having multiple FreeCAD instances its something good, it will just consume resources and i guess it can be avoided so we should.
-----------------------
kjeib:
I would like to see units selectable at three levels:

- User preferences
- File (document)
- Dimension property

When you create a dimension, you would be able to specify the units to display for that dimension only. If nothing is specified, the system would look to the file default, if one has been specified. If none is given, the measurement displays according to the user preference.

This would allow individual files to work with inches, feet, mm, meters, angstroms, etc. But even individual dimensions within a document could display differently. No reason why even a purely metric project might not want to use cm in some places and mm elsewhere.
I have to check how the code works with precision and internal system measurement being used. But i agree in whats said here.

I will work the things said here, and should think what to do with scripting i guess because everything talked here was just IDE side of the feature i guess, someone here do more scripting? i personally have not done scripting yet so have to test that too. Thanks in advance.
Last edited by AgCaliva on Tue Mar 07, 2023 10:17 am, edited 1 time in total.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Per-project metrics

Post by onekk »

About scripts. Python is very generic and unitless, so you add decimal numbers.

Regarding FreeCAD it is related to what WB you are using and how.

When you script as example "Part module" you are using internal units ie mm, as you are working with CAD kernel that is using mm, but if you are dealing with DocumentObjects ie the Part WB you are on a different thing (sadly names are not helping here) from what I remember, in some property field you could specify a visualisation unit, or leave the field as is and it usually use the default unit set in Preferences.

What I have not tried is if you could specify with Python a Unit different from the default unit, as it seems possible to specify it.

You could script many things in FreeCAD so PartDesign could be different from Path (that notably is geared toward G-Code that accepts only mm and inches), or some other WB.

Maybe one of these days I will make some experiments, maybe with some Part WB cubes to see if I could specify as example a cube 20mm wide and 1 inch tall (Z dir) and if units are retained in the UI.

What could be difficult in having three levels is that you have to add some ways to :

- apply all the default chosen unit to the file, even if there is a per file setting.

- manage unitless values as example in expressions, what unit they have to use the "per file" unit or default unit.

- show in some way that "per file" units are used to inform the user that if he has set inches and see mm is not a FreeCAD bug. A warning at start could suffice, if default chosen unit mismatch with "per file" unit, but even an indicator is a good thing, plus the choice has to be persistent so you could save this preference in the file to avoid to always specify your will at each file opening?

More doubt to come, as it is not as plain as it seem to have such mechanism, it could result in a big mess, user cases could be complicated, how to deal with as example dimensions? with TechDraw drawings? with Sketcher Constraints?

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
Post Reply