Thank you very much, it works.
Could you please tell me how to make sure the text displayed (using AIS_Textlabel) doesn't rotate when the camera is facing it and always stays within the display size?
And could you also please tell me how to make sure the text displayed using AIS_Textlabel doesn't change size when the camera zooms in?
My OCC version is 7.9.0
If I use this code, it doesn't work and the index keeps rotating and zooming when zoomed in:
label = AIS_TextLabel()
label.SetText(str(text))
pnt = gp_Pnt(float(position[0]), float(position[1]), float(position[2]))
label.SetPosition(pnt)
trsf_pers = Graphic3d_TransformPers(Graphic3d_TMF_ZoomPers, pnt)
label.SetTransformPersistence(trsf_pers)
label.SetHeight(25.0)
color_obj = Quantity_Color(color[0], color[1], color[2], Quantity_TOC_RGB)
if hasattr(label, "SetColor"):
label.SetColor(color_obj)
self._context.Display(label, update)
I also tried this option with SetIsZoomable and SetZoomable, but it didn't work either and I got an error('Graphic3d_AspectText3d' object has no attribute 'SetIsZoomable'):
drawer = text_label.Attributes()
text_aspect = drawer.TextAspect()
try:
text_aspect.SetIsZoomable(False)
except AttributeError:
text_aspect.Aspect().SetIsZoomable(False)
text_label.SetHeight(20.0)
I want the output text "1" to lie in the size plane and not turn towards us while the camera is moving, and so that it does not change its size when the camera zoom changes.
In the first photo, the text is rotated, in the second photo, the magnification is "1" when the camera is moving away: