Core: No way to access schemas directly in Base UnitsAPI.h
- Dominant language
- C++
- Stars
- 33.6k
- Forks
- 6k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 196
Description
### Area / Workbench affected
Core (App, Gui, Base, ...)
### Problem description
I am trying to support multi document operations and one of the biggest issues with multi-documents is the lack of support for accessing units per document without being forced to call setSchema which can be a problem since i don't wanna mess with the current user set active document or units (i.e. trying to do a read-only operation).
currently cannot do something like (due to Base::UnitsApi::schemas being private):
```c++
const App::PropertyEnumeration &unitSystem = doc->UnitSystem;
for( std::vector::iterator itrUnitSpec = Base::UnitsApi::schemas->pack.specs.begin(); itrUnitSpec != Base::UnitsApi::schemas->pack.specs.end(); ++itrUnitSpec)
{
if(itrUnitSpec->num == unitSystem.getEnum().getInt())
{
//std::map>::iterator itrTranslation = itrUnitSpec->translationSpecs.begin();
break;
}
}
```
### Impact
The impact this has is on plugin multi document support with read only unit operations.
### Suggested improvement (optional)
add an accessor for Base::UnitsApi::schemas
### References / evidence
https://github.com/FreeCAD/FreeCAD/blob/bfddba44e91f479ed8e3fe655d8c0e05363838bf/src/Base/UnitsApi.h#L77
### Development version (if relevant)
```shell
```
Contributor guide
Research direction
Start in src/Base/UnitsApi.h around the referenced schemas declaration and inspect how Base::UnitsApi exposes unit information. Add a read-only way for plugin code to access the schemas without calling setSchema, then verify that a document's unit system can be inspected without changing the active user settings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 58/100