Here are the steps to use AppendOuterLoop of Autocad ActiveX with Visual C++:

  1. Create a new Visual C++ project in Visual Studio.
  2. In the Solution Explorer, right-click on the project name and select 'Add Reference...'.
  3. In the Reference Manager, select the 'COM' tab and search for 'AutoCAD Type Library'.
  4. Select the version of AutoCAD that you have installed and click 'Add'.
  5. 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
  1. 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"));
  1. Create an instance of the AcadLoop object:
Acad::IAcadLoopPtr pAcadLoop;
pAcadLoop = pAcadLWPolyline->AppendOuterLoop();
  1. 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);
  1. Save the changes:
pAcadLWPolyline->Update();
  1. Run the project and the LWPolyline with an outer loop and vertices will be created in AutoCAD.
AutoCAD ActiveX AppendOuterLoop: Visual C++ Guide

原文地址: https://www.cveoy.top/t/topic/nDWZ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录