// (C) Copyright 2002-2007 by Autodesk, Inc. // // Permission to use, copy, modify, and distribute this software in // object code form for any purpose and without fee is hereby granted, // provided that the above copyright notice appears in all copies and // that both that copyright notice and the limited warranty and // restricted rights notice below appear in all supporting // documentation. // // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. // // Use, duplication, or disclosure by the U.S. Government is subject to // restrictions set forth in FAR 52.227-19 (Commercial Computer // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) // (Rights in Technical Data and Computer Software), as applicable. // //----------------------------------------------------------------------------- //----- acrxEntryPoint.cpp //----------------------------------------------------------------------------- #include "StdAfx.h" #include "resource.h" //----------------------------------------------------------------------------- #define szRDS _RXST("ahlzl") static AcArray<AcDbEntity*> _markers; static AcArray<int> viewportNumbers; //----------------------------------------------------------------------------- //----- ObjectARX EntryPoint class CARX_App : public AcRxArxApp { public: CARX_App () : AcRxArxApp () {} virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) { // TODO: Load dependencies here // You *must* call On_kInitAppMsg here AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ; // TODO: Add your initialization code here return (retCode) ; } virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) { // TODO: Add your code here // You *must* call On_kUnloadAppMsg here AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ; // TODO: Unload dependencies here return (retCode) ; } virtual void RegisterServerComponents () { } static void ClearTransientGraphics() { AcGiTransientManager* pTransientManager = acgiGetTransientManager(); int numOfMarkers = _markers.length(); if (numOfMarkers &gt; 0) { for(int index = 0; index < numOfMarkers; index++) { AcDbEntity *pMarker = _markers.at(index); pTransientManager->eraseTransient(pMarker, viewportNumbers); delete pMarker; } _markers.removeAll(); } } // - ahlzlARX_._test command (do not rename) static void ahlzlARX__test(void) { // Add your code for command ahlzlARX_._test here AcDbDatabase *pDb = acdbHostApplicationServices()-&gt;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; Acad::ErrorStatus 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-&gt;transactionManager(); AcTransaction *pTransaction = pTM-&gt;startTransaction(); AcDbObject *pCurveObj = NULL; pTransaction-&gt;getObject(pCurveObj, plOid, AcDb::kForRead); AcDbCurve *pCurve = AcDbCurve::cast(pCurveObj); AcGiTransientManager* pTransientManager = acgiGetTransientManager(); viewportNumbers.removeAll(); struct resbuf res; acedGetVar(L"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.setColorIndex(1); marker->setColor(color); // 或?marker-&gt;setColorIndex(2); _markers.append(marker); pTransientManager-&gt;addTransient(marker, kAcGiDirectShortTerm, 128, viewportNumbers); acutPrintf(ACRX_T("\n Point : %lf %lf"), pt.x, pt.y); } } } } pTM-&gt;endTransaction(); } } ; //----------------------------------------------------------------------------- IMPLEMENT_ARX_ENTRYPOINT(CARX_App) ACED_ARXCOMMAND_ENTRY_AUTO(CARX_App, ahlzlARX_, _test, test, ACRX_CMD_TRANSPARENT, NULL)