Hi there!
I need to assign a color to the Text2D element, so when I run my script the text show in a specific color in the drawing.
this is surprisingly lacking in TextProperty.
any aIdea?
Support Forum
- Forum
- CAD Parametric Modelling
- Visual Scripting
[Frage] set text color for Text2D
The Text2D element is a normal ModelElement2d.
That means, it has CommonProperties, where the Color is defined.
In the NodeText2D the current set common properties are used:
def create_text(self, text, text_prop, ref_point): com_prop = AllplanBaseElements.CommonProperties() com_prop.GetGlobalProperties() location = AllplanGeo.Point2D(ref_point) return AllplanBasisElements.TextElement(com_prop, text_prop, str(text), location)
If you want to have another one, try to add CommonProperties with some Node.
Or use the color formatting inside the text:
%C{n|text%C} with n...Color-Number and text ... the text with this color.
thanks for the response,
since I need the color to be changed with a pattern (eg. 5 different colors for 5 different text) i cannot use the formatting inside the text.
with CommonProperties i need some more explanation.
is there a way to add color to TextProperty.py or any other way?