Text Object Service

Service for accessing text object. Text objects can be loaded and its content modified and sent back to windPRO. Properties of the object can be found here TApiObjText. A small example can be found below.

"""
Copyright 2024 EMD International
License for this script: MIT https://opensource.org/license/mit/
License for windPRO commercial software: https://www.emd-international.com/contact-us/general-terms-conditions-sale/
"""

import os
from windproapi.utils import get_windpro_sample_path
from windproapi import WindProApi
from windproapi import nan_to_skipvalue

# Opening windPRO
_windproapi = WindProApi()
working_dir = os.path.join(get_windpro_sample_path('4.1'), 'ObjTextService')
os.makedirs(working_dir, exist_ok=True)
_windproapi.start_windpro_random_port()

# Project service for making a new project
project_service = _windproapi.get_service('ProjectService')
objects_service = _windproapi.get_service('ObjectsService')
obj_text_service = _windproapi.get_service('ObjTextService')

# Project path and location
project_path = os.path.join(working_dir, 'ObjTextService.w41p')
lng = 10.
lat = 55.

# Making a new empty project and saving it
project_service.NewProject(lng=lng, lat=lat, filename=project_path)

# Making new radar object and getting its parameters
obj = objects_service.AddObject(apiObjType='UsrTextData',
                                lat=lat,
                                lng=lng,
                                userDesc='Description, script generated')
text_object = obj_text_service.GetTextObject(obj.Handle)

# Setting some parameter
text_object.Text = 'Hello world'
text_object.BackColor.Red = 124
text_object.BackColor.Green = 212

nan_to_skipvalue(text_object)
obj_text_service.SetTextObject(text_object)