TA的每日心情 | 开心 半小时前 |
---|
签到天数: 20 天 [LV.4]偶尔看看III
管理员
- 积分
- 1393
|
- void FlipText()
- {
- ads采用point pt;
- ads采用name ent;
- AcDbObjectId objId;
- if (acedEntSel(采用T("\nSelect text"), ent, pt) != RTNORM)
- return;
- if (acdbGetObjectId(objId, ent) != Acad::eOk)
- return;
- // Get the current viewdir
- struct resbuf var;
- acedGetVar(采用T("VIEWDIR"), &var);
- AcGeVector3d viewdir;
- acdbUcs2Wcs(var.resval.rpoint, asDblArray(viewdir), true);
- Acad::ErrorStatus es;
- AcDbText *text;
- if ((es = acdbOpenObject(text, objId, AcDb::kForRead)) == Acad::eOk)
- {
- AcGeVector3d normal(text->normal());
- double dp = normal.dotProduct(viewdir);
- if (dp < 0.0) // if <0 we look at the text from the wrong side. Flip it.
- {
- es = text->upgradeOpen();
- if (!es)
- {
- // Flip the normal but keep the insertion/aligment point
- AcDb::TextHorzMode h = text->horizontalMode();
- AcDb::TextVertMode v = text->verticalMode();
- bool bUsePos=((h==AcDb::kTextLeft)&&(v==AcDb::kTextBase));
- AcGePoint3d pt(bUsePos? text->position() : text->alignmentPoint());
- text->setNormal(-normal); // flip the normal
- if (bUsePos)
- es = text->setPosition(pt);
- else
- es = text->setAlignmentPoint(pt);
- }
- }
- text->close();
- }
- }
复制代码 |
|