arx绘制临时图像
Posted zeqi1991
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了arx绘制临时图像相关的知识,希望对你有一定的参考价值。
有时候需要绘制临时图像,这些图像不能被选中等属性
static AcArray<AcDbEntity*> _markers;
static AcArray<int> viewportNumbers;
static void ClearTransientGraphics()
AcGiTransientManager* pTransientManager = acgiGetTransientManager();
int numOfMarkers = _markers.length();
if (numOfMarkers > 0)
for (int index = 0; index < numOfMarkers; index++)
AcDbEntity *pMarker = _markers.at(index);
pTransientManager->eraseTransient(pMarker, viewportNumbers);
delete pMarker;
_markers.removeAll();
static void CreateTransientGraphics(void)
Acad::ErrorStatus es;
AcDbDatabase *pDb =acdbHostApplicationServices()->workingDatabase();
ads_point pickPnt;
ads_name ent_name;
int ret = acedEntSel(ACRX_T("\\n Select a polyline\\n"),ent_name,pickPnt);
if(ret != RTNORM)
return;
AcDbObjectId plOid;
es = acdbGetObjectId(plOid, ent_name);
if (es != Acad::eOk)
return;
ads_point adsTestPoint;
ret = acedGetPoint(NULL,ACRX_T("\\n Select an internal point\\n"),adsTestPoint);
if(ret != RTNORM)
return;
AcGePoint3d testPoint = asPnt3d(adsTestPoint);
ads_real rayAngle = 0.0;
ret = acedGetAngle(asDblArray(testPoint),ACRX_T("Specify ray direction"),&rayAngle);
if(ret != RTNORM)
return;
AcGePoint3d tempPoint = testPoint + AcGeVector3d::kXAxis;
tempPoint = tempPoint.rotateBy(rayAngle,AcGeVector3d::kZAxis,testPoint);
AcGeVector3d rayDir = tempPoint - testPoint;
ClearTransientGraphics();
AcDbTransactionManager* pTM = pDb->transactionManager();
AcTransaction *pTransaction = pTM->startTransaction();
AcDbObject *pCurveObj = NULL;
es = pTransaction->getObject(pCurveObj,plOid,AcDb::kForRead);
AcDbCurve *pCurve = AcDbCurve::cast(pCurveObj);
AcGiTransientManager* pTransientManager = acgiGetTransientManager();
viewportNumbers.removeAll();
struct resbuf res;
acedGetVar(_T("CVPORT"), &res);
viewportNumbers.append(res.resval.rint);
if(pCurve != NULL)
for (int cnt = 0; cnt < 2; cnt++)
if (cnt == 1)
rayDir = rayDir.negate();
AcDbRay ray;
ray.setBasePoint(testPoint);
ray.setUnitDir(rayDir);
AcGePoint3dArray IntersectionPoints;
es = pCurve->intersectWith(&ray,AcDb::kOnBothOperands,IntersectionPoints);
if(es == Acad::eOk)
int numberOfInters = 0;
numberOfInters = IntersectionPoints.length();
for(int i=0; i < numberOfInters; ++i)
AcGePoint3d pt = IntersectionPoints[i];
AcDbCircle *marker = new AcDbCircle(pt,AcGeVector3d::kZAxis,0.2);
AcCmColor color;
color.setColor(2);
marker->setColor(color);
_markers.append(marker);
pTransientManager->addTransient(marker,kAcGiDirectShortTerm,0,viewportNumbers);
acutPrintf(ACRX_T("\\n Point : %lf %lf"),pt.x,pt.y);
pTM->endTransaction();
以上是关于arx绘制临时图像的主要内容,如果未能解决你的问题,请参考以下文章