|
- void PluginCommand::Test()
- {
- struct resbuf sysVar;
- acedGetVar(_T("SCREENSIZE"), &sysVar);
- int nScreenX = (short)sysVar.resval.rpoint[0];
- int nScreenY = (short)sysVar.resval.rpoint[1];
- acedGetVar(_T("VIEWSIZE"), &sysVar);
- double dViewSize = sysVar.resval.rreal;
- acedGetVar(_T("PICKBOX"), &sysVar);
- double dScale = dViewSize / nScreenY;
- acutPrintf(_T("nScreenX = %d, nScreenY = %d, dViewSize = %.3f, dScale = %.3f\n"), nScreenX, nScreenY, dViewSize, dScale);
- //获取view的rect
- CRect viewRect;
- GetClientRect(acedGetAcadDwgView()->m_hWnd, &viewRect);
- //viewRect转到图纸中的点
- acedDwgPoint dwgPt1, dwgPt2;
- //获取视口编号
- struct resbuf v;
- if (acedGetVar(_T("cvport"), &v) == RTNORM)
- {
- int wndNum = v.resval.rint;
- acedCoordFromPixelToWorld(wndNum, viewRect.TopLeft(), dwgPt1);
- acedCoordFromPixelToWorld(wndNum, viewRect.BottomRight(), dwgPt2);
- }
- else
- {
- acedCoordFromPixelToWorld(viewRect.TopLeft(), dwgPt1);
- acedCoordFromPixelToWorld(viewRect.BottomRight(), dwgPt2);
- }
- //pt1和pt2是世界坐标系下的点
- AcGePoint3d ptStart = PublicFunction::TransWcs2Ucs(asPnt3d(dwgPt1));
- ptStart.z = 0.0;
- AcGePoint3d ptEnd = PublicFunction::TransWcs2Ucs(asPnt3d(dwgPt2));
- ptEnd.z = 0.0;
- ads_point p1;
- ads_point_set(asDblArray(ptStart), p1);
- ads_point p2;
- ads_point_set(asDblArray(ptEnd), p2);
- //选择该视图内的全部实体
- ads_name ssname;
- int ret = acedSSGet(_T("C"), p1, p2, NULL, ssname);
- acedSSSetFirst(ssname, NULL);
- ads_ssfree(ssname);
- }
复制代码 |
|