How do I use TextAlignment in TextEntity?

Open
#607 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp
Domain
tooling

Research direction

The issue does not name a file or test. Start by locating TextEntity and reading how its alignment properties are used when writing or rendering text; then check any existing tests for text alignment. Done means identifying why the shown alignment setup does not work and confirming the behavior with a focused test.

Written by the indexing model from the issue text.

Description

This is my code for the text alignment but is doesn't work.
Could you help me figure out what's wrong?

            TextEntity textEntity = new TextEntity();            
            textEntity.Height = height;
            textEntity.Rotation = rotation * Math.PI / 180.0;            
            textEntity.Value = text;  

            textEntity.AlignmentPoint = position ;
            textEntity.InsertPoint = position ;
            textEntity.Normal = CSMath.XYX.AxisY;

            switch (hAlign)
            {
                case TextRender.HorzAlign.Left: textEntity.HorizontalAlignment = ACadSharp.Entities.TextHorizontalAlignment.Left; break;
                case TextRender.HorzAlign.Right: textEntity.HorizontalAlignment = ACadSharp.Entities.TextHorizontalAlignment.Right; break;
                case TextRender.HorzAlign.Center: textEntity.HorizontalAlignment = ACadSharp.Entities.TextHorizontalAlignment.Center; break;
                default:
                    textEntity.HorizontalAlignment = ACadSharp.Entities.TextHorizontalAlignment.Left; break;
            }
            
            switch (vAlign)
            {
                case TextRender.VertAlign.Top: textEntity.VerticalAlignment = ACadSharp.Entities.TextVerticalAlignmentType.Top; break;
                case TextRender.VertAlign.Bottom: textEntity.VerticalAlignment = ACadSharp.Entities.TextVerticalAlignmentType.Bottom; break;
                case TextRender.VertAlign.Center: textEntity.VerticalAlignment = ACadSharp.Entities.TextVerticalAlignmentType.Middle; break;
                default:
                    textEntity.VerticalAlignment = ACadSharp.Entities.TextVerticalAlignmentType.Baseline; break;
            }
            
            btr.Entities.Add(textEntity);
Dominant language
C#
Stars
873
Forks
223
Avg merge
1d 15h
Merged PRs (30d)
28

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DomCR/ACadSharp

All issues in DomCR/ACadSharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.