Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to right-align custom graphics text?

1 REPLY 1
Reply
Message 1 of 2
perryK67ZX
91 Views, 1 Reply

How to right-align custom graphics text?

I don't see a way via the API to right-align text, but I do see the `formattedText` property. Is there a list of formatting options available? Is there an option for right-aligning the text?

Labels (3)
1 REPLY 1
Message 2 of 2
j4n.vokurka
in reply to: perryK67ZX

Hello,

I've used custom graphics - more precisely billboard - to display text on screen as well. I will share my creation and setting of custom graphics written in C++ so you have a reference:

Ptr<CustomGraphicsGroup> graphics = customGroups->add();
graphics->id(BillboardID);

Ptr<Matrix3D> matrix = Matrix3D::create();
Ptr<CustomGraphicsText> graphicsText = graphics->addText(BillboardBlock, "Arial", 0.5, matrix);

Ptr<CustomGraphicsBillBoard> billBoard = CustomGraphicsBillBoard::create(Point3D::create(0, 0, 0));
billBoard->billBoardStyle(CustomGraphicsBillBoardStyles::ScreenBillBoardStyle);
graphicsText->billBoarding(billBoard);

Ptr<CustomGraphicsViewScale> viewScale = CustomGraphicsViewScale::create(30, Point3D::create(0, 0, 0));
graphicsText->viewScale(viewScale);

Ptr<CustomGraphicsViewPlacement> viewPlace = CustomGraphicsViewPlacement::create(
	Point3D::create(0, 0, 0),
	static_cast<ViewCorners>(currentCorner),
	Point2D::create(XCoordinate, YCoordinate));
graphicsText->viewPlacement(viewPlace);

graphicsText->isSelectable(false);

Ptr<CustomGraphicsSolidColorEffect> BlackColor = CustomGraphicsSolidColorEffect::create(Color::create(0, 0, 0, 255));
graphicsText->color(BlackColor);


This basically displays a text block (formattedText) that:
- is always facing towards my screen

- has certain size and color

- is not selectable

- is located in one of the corners of the screen

- is indented by x, y values according to which corner it is located in and according to the size of the text block so it doesn't "overflow" and is in it entirety displayed 

Now if your criteria are mostly the same, you will face the same problem as me. Text block has x, y coordinates and according to the size and the selected corner you have to adjust these coordinates so the text displays properly. Both x and y coordinates' origin is in the top-left corner.

For example if you display your text in top-left corner you don't have to indent the text at all because that's the point from which the text starts to display. However if you have selected bottom-right corner (which is imo the most convenient spot for these graphics) you will have to indent the text block by its full width and height so it stays on the screen. 

If you display for example a numerical value of which you know how many maximum decimal places it should have it's easy. If you try to display dynamic text it's something completely different. You would probably have to calculate the number of characters before "\n" is entered and then use the highest value and the number of rows to set the indentation. 

Good luck
 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report