by Fenton Webb
Using ObjectARX to create and define a Custom Entity type you can implement Viewport specific draw functionality, amongst other things. The same can also be achieved with .NET Overrules which is really cool. A common question we get from developers is, how can I make my custom entity Text follow the same direction as the View, in other words, plan to the View.
Here’s how…
void drawTextPlanView(AcGiViewportDraw* pVd,
AcGePoint3d insPnt, TCHAR *textStr)
{
// get the current viewport
AcGiViewport* pView = &pVd->viewport();
AcGePoint3d cam, tar;
// work out the viewing properties
pView->getCameraLocation(cam);
pView->getCameraTarget(tar);
// now calc the normal vector
AcGeVector3d normal = cam – tar;
normal.normalize();
// finally draw the text in the viewport
AcGiTextStyle giStyle;
fromAcDbTextStyle(giStyle, curDoc()->database()->textstyle());
AcGeVector3d dir = insPnt.asVector().crossProduct(normal);
dir.y = 0;
pVd->geometry().text(insPnt, normal, dir,
textStr, _tcslen(textStr), Adesk::kFalse, giStyle);
}

Leave a Reply