Custom entity with texts

Custom entity with texts

Anonymous
Not applicable
992 Views
5 Replies
Message 1 of 6

Custom entity with texts

Anonymous
Not applicable

Dear Colleagues,

 

I have a problem with my custom entity which should show either the texts. The object "AcDbMText" is used for this.

 

void MyCustomEntity::subViewportDraw (AcGiViewportDraw *pVd)
{

   AcDbMText myText;

 

   // initialize of  myText

 

 

 

  pVd->rawGeometry ()->draw (&myText);

}

 

The Problem:

If user change the visual style from "2D Wireframe" to another -> the texts have disappeared.

In debug mode: the function "draw" returns "false" in this case.

 

What I have to use for text?

 

The Autodesk application is: AutoCAD ARCHITECTURE 2015.

 

0 Likes
993 Views
5 Replies
Replies (5)
Message 2 of 6

tbrammer
Advisor
Advisor

You can use the primitive drawing methods in class AcGiGeometry to draw your custom entity:

 

class AcGiGeometry {
public:
    virtual Adesk::Boolean  text(
        const AcGePoint3d& position,
        const AcGeVector3d& normal,
        const AcGeVector3d& direction,
        const double height,
        const double width,
        const double oblique,
        const ACHAR* pMsg
    ) const = 0;

    virtual Adesk::Boolean  text (
        const AcGePoint3d& position,
        const AcGeVector3d& normal,
        const AcGeVector3d& direction,
        const ACHAR* pMsg,
        const Adesk::Int32 length,
        const Adesk::Boolean raw,
        const AcGiTextStyle &pTextStyle
    ) const = 0;
}

Adesk::Boolean MyEnt::subWorldDraw(AcGiWorldDraw *mode)
{
    AcGiWorldGeometry &wgeo = mode->geometry();
    AcGiGeometry &geo = wgeo;
    geo.text(...)
}

Adesk::Boolean MyEnt::subViewportDraw(AcGiViewportDraw *mode)
{
    AcGiViewportGeometry &vgeo = mode->geometry();
    AcGiGeometry &geo = vgeo;
    geo.text(...)
}

 

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi !

 

Thank you for the post.

 

I have tried to use this functions, but the problem is still here, regardless of how the texts are shown. Could it be a parameter? (but HIDETEST is "OFF").

 

0 Likes
Message 4 of 6

tbrammer
Advisor
Advisor

You mean you can see the text drawn by AcGiGeometry::text() in 2dWireframe only?

Could it be that the text is hidden by any other face geometry?

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 5 of 6

Anonymous
Not applicable

Hi !

 

[tbrammer] You mean you can see the text drawn by AcGiGeometry::text() in 2dWireframe only?

Yes.

 

[tbrammer] Could it be that the text is hidden by any other face geometry?

Yes, probably. But I know the parameter "HIDETEXT" only and it's "OFF". Are there more parameters to be adjusted ?

 

0 Likes
Message 6 of 6

tbrammer
Advisor
Advisor

Please check whether your text is hidden behind faces. I don't know any options that will cause hidden text to be drawn "on top".

You could try to draw it in viewportDraw() moved along the viewing direction above the faces so that it isn't covered anymore. Or you use transparency for the faces that hide your text.

Another option might be to use

 

  Adesk::Boolean AcGiGeometry:: ownerDraw(
    AcGiGdiDrawObject*,
    const AcGePoint3d&,
    const AcGeVector3d&,
    const AcGeVector3d&
  ) const;

 

I have never tried this. Also I have no idea how AutoCAD deals with Z-order or drawing order for objects drawn like this. To use it, you have to implement a class derived from AcGiGdiDrawObject that draws directly to the device context.

 

  class MyGiGdiDrawObject: public AcGiGdiDrawObject {
    virtual Adesk::Boolean draw(HDC hDC, int x, int y, int w, int h);
  }

 

Good luck.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes