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?
Das Wissen aller Anwender nutzen
Im Allplan Connect Forum tauschen sich Anwender aus, geben wertvolle Tipps oder beraten sich bei ganz konkreten Aufgabenstellungen − auch international.
Und damit wirklich keine Frage unbeantwortet bleibt, unterstützen die Mitarbeiter des Technischen Supports ebenfalls aktiv das Forum.
Es erwarten Sie:
- Foren-Vielfalt aus CAD Architektur, CAD Ingenieurbau uvm.
- Tipps von User für User
- international: Deutsch, Englisch, Italienisch, Französisch und Tschechisch
Melden Sie sich jetzt an und diskutieren Sie mit!
- Forum
- CAD Parametric Modelling
- Visual Scripting
[Frage] set text color for Text2D [Gelöst]
Lösung anzeigen Lösung verbergen
There are two nodes for the CommonProperties: NodeFormat and NodeFormatPalette.
Unfortunately, neither of them works with NodeText2D.
But you can expand the NodeText2D with an Input.
Therefore you have to modify NodeText2D.py and NodeText2D.pypsub in directory
C:\ProgramData\Nemetschek\Allplan\2025\Etc\VisualScripts\NodeLib\Classic Library\Layout.
I have done this for you (see Node2DFormat.zip)
With this modified NodeText2D you can create Text with Colors (see text_with_format.png)
Anhänge (3)
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?
There are two nodes for the CommonProperties: NodeFormat and NodeFormatPalette.
Unfortunately, neither of them works with NodeText2D.
But you can expand the NodeText2D with an Input.
Therefore you have to modify NodeText2D.py and NodeText2D.pypsub in directory
C:\ProgramData\Nemetschek\Allplan\2025\Etc\VisualScripts\NodeLib\Classic Library\Layout.
I have done this for you (see Node2DFormat.zip)
With this modified NodeText2D you can create Text with Colors (see text_with_format.png)
Anhänge (3)
you are amazing
^I have the same problem with FillingPallete, I need the Filling color also change with a list, according to the text color (see first image please). although I cannot connect a list with the desired colors to FirstColor in FillingPallete
Anhänge (1)
I have created a new new NodeSolidFilling2D (derived from NodeFilling2D).
This Node has an input Color instead of FillingProperties.
Together with NodeColorInput you can easily create a solid filling.
The file Std_Visualscripts.zip has to unpack to STD\VisualScripts.
Anhänge (2)
thanks.
but it seems like it cannot take a list as input paramater.
Anhänge (1)
Try this one, please.
Anhänge (1)
its functioning perfectly. thanks again.
is there a way taht run this .pyp I made in the layout mode (not drawing mode) in allplan?