Announcements
Autodesk Community will be read-only between April 26 and April 27 as we complete essential maintenance. We will remove this banner once completed. Thanks for your understanding
Announcements
We are currently migrating data within this board to improve the community. During this process, posting, replying, editing and other features are temporarily disabled. We sincerely apologize for any inconvenience caused and appreciate your understanding. Thank you for your patience and support.

Transient text color

alberto_manero_geograma
Enthusiast Enthusiast
9,024 Views
7 Replies
Message 1 of 8

Transient text color

alberto_manero_geograma
Enthusiast
Enthusiast

Hello,

 

I am working with transient graphics to show some indicators over the current drawing, those indicators have a polygon with a boundary and a text.

 

I do not have any problems with the polygon and with the boundary, but the text is drawn allways with black color and I need it to be in another color. This is the code that I use to draw them in a class that inherits "Transient":

 

        protected override bool SubWorldDraw(WorldDraw wd)
        {
                //Polygon  properties
                wd.SubEntityTraits.TrueColor = new EntityColor(255, 255, 0);
                wd.SubEntityTraits.FillType = FillType.FillAlways;
                wd.SubEntityTraits.Transparency = new Transparency(75);
                //Filled polygon
                wd.Geometry.Polygon(myP3DCol);

                //Line properties
                wd.SubEntityTraits.FillType = FillType.FillNever;
                wd.SubEntityTraits.Transparency = new Transparency(TransparencyMethod.ByLayer);
                //Outline
                wd.Geometry.Polyline(myP3DCol.p3dCol, Vector3d.ZAxis, new IntPtr());

                TextStyle _style = new TextStyle();
                _style.Font = new FontDescriptor("Arial", false, false, 0, 0);
                _style.TextSize = 10;

                wd.SubEntityTraits.TrueColor = new EntityColor(0, 0, 255);

                //Text
                wd.Geometry.Text(
                    myP3DCol.p3dCol[0],         // Position
                    new Vector3d(0, 0, 1),      // Normal
                    new Vector3d(1, 0, 0),      // Direction
                    "MyText",                   // Text
                    true,                       // Rawness
                    _style                      // TextStyle
                );
            Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.UpdateScreen();
            return true;
        }

 Can anyone tell me why the text is allways black or provide me an example code to check for differences?

 

Thanks!

Luis Alberto Manero, Geograma.com
Reply
Reply
0 Likes
Accepted solutions (1)
9,025 Views
7 Replies
Replies (7)
Message 2 of 8

fenton_webb
Autodesk
Autodesk

can you post a sample project so I can debug it for you please?




Fenton Webb
AutoCAD Engineering
Autodesk

Reply
Reply
0 Likes
Message 3 of 8

alberto_manero_geograma
Enthusiast
Enthusiast

Hello,

 

Attached is a sample C# Project with a cutted off version of the code.

 

To show the transient, use command "TB" and "TBR" to remove it.

Luis Alberto Manero, Geograma.com
Reply
Reply
0 Likes
Message 4 of 8

Balaji_Ram
Alumni
Alumni

Hi Luis,

 

The behavior of text entity color when used with transient graphics and when Visual style is set to “2d Wireframe” is a known behavior. This has been logged in our internal database for our engineering team to consider.

 

Can you please try changing the Visual Style to any other style, say “Realistic” ?

 

Or you may try using overruling as explained in this post :

http://adndevblog.typepad.com/autocad/2013/03/displaying-entities-in-different-colors-using-drawable...

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Reply
Reply
0 Likes
Message 5 of 8

alberto_manero_geograma
Enthusiast
Enthusiast

Hello!

 

Changing to 3D makes the text to show in correct color. In 2D it's color looks like it deppends on the color of the active layer or on the color of the last drown entity or something like that.

 

About the overruling I have a question: How can I overrule the drawing of a transient graphic? Because my text is never added to the drawing.

Luis Alberto Manero, Geograma.com
Reply
Reply
0 Likes
Message 6 of 8

Balaji_Ram
Alumni
Alumni

Hi Luis,

 

Sorry for the confusion.

I did not mean "overruling a transient".

 

I thought you may want to consider using overruling instead of transient graphics.



Balaji
Developer Technical Services
Autodesk Developer Network

Reply
Reply
0 Likes
Message 7 of 8

alberto_manero_geograma
Enthusiast
Enthusiast

Hello,

 

The entities that my program has to draw are redrawn too much to add them to the document and we do not want them to be saved with it also, so adding them to the document is not an option (as far as I know). In the picture, in the red square, you can see what my program really has to draw: a field of view that can be moved as quickly as he wants.

 

Dibujo.JPG

Luis Alberto Manero, Geograma.com
Reply
Reply
0 Likes
Message 8 of 8

fenton_webb
Autodesk
Autodesk
Accepted solution

Don't use a True Type font, use an SHX - then I think your colors will be observed. Using the STYLE command, I set the current text style to use txt.shx instead of arial.ttf and now this code works perfectly...

 

protected override bool SubWorldDraw(WorldDraw wd)

{

  wd.SubEntityTraits.Color = 1;

  TextStyle _style = new TextStyle();

  _style.FromTextStyleTableRecord(Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase.Textstyle);

  _style.TextSize = 10;

  wd.Geometry.Text(

      new Point3d(11, 11, 0),     // Position

      new Vector3d(0, 0, 1),      // Normal

      new Vector3d(1, 0, 0),      // Direction

      "1",                        // Text

      false,                       // Rawness

      _style                      // TextStyle

  );

 

 

Also, a note to all: don't call UpdateScreen from your SubWorldDraw, otherwise you risk going into an endless loop. If your graphics are not being displayed, and you feel you need to call UpdateScreen, then you have another problem somewhere else.




Fenton Webb
AutoCAD Engineering
Autodesk

Reply
Reply