Hello @maxhamelynck,
by default, Karamba3D internally works with kN, meters and tons. These base units can be changed via the âkaramba.iniâ file which resides in the installation folder.
For changing the base units via a C# script, one needs to reset some parts of Karamba3D so that no inconsistencies arise (see e.g, âComponent_Settingsâ in karamba.gha):
with
using Karamba.CrossSections;
using Karamba.Materials;
using Karamba.Utilities;
using Materials;
using Utilities;
one needs to clear these singletons
INIReader.ClearSingleton();
UnitsConversionFactory.ClearSingleton();
Material_Default.ClearSingleton();
CroSec_Default.ClearSingleton();
Default_Material_Table_220.ClearSingleton();
Default_Material_Table.ClearSingleton();
Default_CroSec_Table.ClearSingleton();
then it is possible to set
var ini_reader = INIReader.Instance();
ini_reader.Values[âUnitLengthâ] = âYourFavouriteLengthUnitsâ
like you would in the karamba.ini-file.
I recommend that however only in case of very large or very small structures. Otherwise, it is more comfortable to work with K3D units-conversion objects:
with
using Karamba.Utilities;
one gets a units-conversion object like this:
var ucf = UnitsConversionFactories.Conv();
UnitConversion cm = ucf.cm();
in order to convert a value from base units to an output unit use
cm.toUnit(YourValueInBaseUnitsHere)
the other way round works via
cm.toBase(YourValueInCMHere)
Be aware that âucf.cm()â returns a conversion from/to cm only by default and only for the SI system. In Imperial Units inch is used instead. The string representation of the actual unit can be found via âcm.unitBâ.
âClemens