1
$\begingroup$

I am writing an add-on. There are UI elements using FloatProperty. Some of them should have minimum, maximum and default values in absolute terms. This requires the knowledge of the user's scale_length.

These values have to be defined when the add-on is registered. The register() method does not receive a context. bpy.context and bpy.data.scenes are not available yet at this point.

Is there a way to access the user's scale_length?

$\endgroup$
  • 2
    $\begingroup$ I think one good approach is adding a checkbox to the panel header and when checked/updated call a function to set or init the limits based on another property. Another approach is using a handler per file load, which always feels a bit crappy. $\endgroup$ – brockmann Apr 6 at 18:37
  • $\begingroup$ @brockmann Thanks, that looks awesome! But then I run into the problem of re-registering the FloatProperty. This was discussed here: blender.stackexchange.com/q/18686/66651 . I managed to re-register in the console, still struggle to put it in the source properly. But even if I manage that, can I expect stable behaviour? $\endgroup$ – bogl Apr 7 at 10:46
  • $\begingroup$ Pedestrian solution would be to check the limits in the update functions. $\endgroup$ – bogl Apr 7 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.