AutoCAD ActiveX AppendOuterLoop: Visual C++ Guide
Here are the steps to use AppendOuterLoop of Autocad ActiveX with Visual C++:
- Create a new Visual C++ project in Visual Studio.
- In the Solution Explorer, right-click on the project name and select 'Add Reference...'.
- In the Reference Manager, select the 'COM' tab and search for 'AutoCAD Type Library'.
- Select the version of AutoCAD that you have installed and click 'Add'.
- In the code file where you want to use AppendOuterLoop, add the following include statement at the top of the file:
#import "acax17enu.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
- Create an instance of the AcadLWPolyline object:
Acad::IAcadApplicationPtr pAcadApp;
Acad::IAcadDocumentPtr pAcadDoc;
Acad::IAcadModelSpacePtr pAcadModelSpace;
Acad::IAcadLWPolylinePtr pAcadLWPolyline;
pAcadApp = GetAcadApplication();
pAcadDoc = pAcadApp->ActiveDocument;
pAcadModelSpace = pAcadDoc->ModelSpace;
pAcadLWPolyline = pAcadModelSpace->AddLightWeightPolyline(_T("0,0,0"));
- Create an instance of the AcadLoop object:
Acad::IAcadLoopPtr pAcadLoop;
pAcadLoop = pAcadLWPolyline->AppendOuterLoop();
- Add vertices to the loop:
Acad::IAcadVertex2dPtr pAcadVertex1, pAcadVertex2, pAcadVertex3;
pAcadVertex1 = pAcadLoop->AppendVertex(1.0, 1.0);
pAcadVertex2 = pAcadLoop->AppendVertex(2.0, 1.0);
pAcadVertex3 = pAcadLoop->AppendVertex(2.0, 2.0);
- Save the changes:
pAcadLWPolyline->Update();
- Run the project and the LWPolyline with an outer loop and vertices will be created in AutoCAD.
原文地址: https://www.cveoy.top/t/topic/nDWZ 著作权归作者所有。请勿转载和采集!