.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Transient text color

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
alberto_manero_geograma
8658 Views, 7 Replies

Transient text color

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
7 REPLIES 7
Message 2 of 8

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




Fenton Webb
AutoCAD Engineering
Autodesk

Message 3 of 8

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
Message 4 of 8

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

Message 5 of 8

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
Message 6 of 8

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

Message 7 of 8

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
Message 8 of 8

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

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

”Boost