马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Acad::ErrorStatus UCS_V()
{
AcGeMatrix3d matUcs;
struct resbuf rbZeroPt;
acedGetVar(_T("UCSORG"), &rbZeroPt); // origin point for current UCS (in WCS, so, we don't need to convert it)
struct resbuf viewTwist;
acedGetVar(_T("VIEWTWIST"), &viewTwist); // view rotation angle
struct resbuf rbViewDir;
acedGetVar(_T("VIEWDIR"), &rbViewDir); // Z vector
AcGeVector3d zAxis = asPnt3d(rbViewDir.resval.rpoint).asVector();
acdbUcs2Wcs(asDblArray(zAxis),asDblArray(zAxis),true); // to WCS convertation
zAxis *= (1.0 / zAxis.length()); // normalization
matUcs = AcGeMatrix3d::planeToWorld(zAxis) * AcGeMatrix3d::rotation(-viewTwist.resval.rreal, AcGeVector3d::kZAxis, AcGePoint3d::kOrigin); // "by view" matrix. origin is (0,0,0)
matUcs.setTranslation(asPnt3d(rbZeroPt.resval.rpoint).asVector()); // set the correct origin
return acedSetCurrentUCS(matUcs);
}
|