[每日一码] 模拟命令UCS+V的ARX实现代码
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);
}
页:
[1]