CAD 2020 ARX C++ 开发配置
CAD 2020 ARX C++ 配置
安装SDK
- 下载ObjectArx文件:objectarx_for_autocad_2020_win_64_bit.sfx.exe;
- 安装到指定目录,即进行了解压;
安装模板
- 下载模板向导安装包:ObjectARXWizard2020.msi
- 安装,即使配置正确的SDK路径,但模板依旧是使用默认路径;
异常与修复
- 导致搭配vs 2017使用会出现找不到正确SDK的异常;
无法读取项目文件"ArxProject1.vcxproj"。
F:\dev-tool\(cad\Projects\ArxProject1\ArxProject1\Autodesk.arx-2020.props(37,3)
:未找到导入的项目“C:\ObjectARX\inc\arx.props"。请确认 <Import>声明中的路径正确,且磁盘上存在该文件。
- RTCc异常;
错误 C2338 /RTCc rejects conformant code, so it isn't supported by the C++ Standard Library.
Either remove this compiler option, or define _ALLOW_RTCc_IN_STL to acknowledge that you have received this warning.
test1 D:\Apps\win-dev\vs\Visual Studio 2017 Enterprise\VC\Tools\MSVC\14.10.25017\include\yvals.h 182
修复找不到正确SDK
- 找到模板向导安装路径:C:\Program Files (x86)\Autodesk\ObjectARX 2020 Wizards\ArxAppWiz\Templates\1033;
- 修改Autodesk.arx-2020.props中的
条目值,使得指向SDK的真实目录;
<!--修改前-->
<ArxSdkDir>C:\ObjectARX\</ArxSdkDir>
<!--修改后-->
<ArxSdkDir>F:\dev-tool\cad\ObjectARX2020\</ArxSdkDir>
修复RTCc异常
- 项目中右键-属性-配置属性-C/C++-预处理器,在[预处理定义]中加入
_ALLOW_RTCc_IN_STL
- 重新编译后,异常消失。
SDK下载连接
参考https://blog.csdn.net/u010150437/article/details/88965274
开发环境
| 版本 | 开发环境 |
|---|---|
| 2024 | Visual Studio 2022 version 17.2.6 |
| 2023 | Visual Studio 2019 version 16.11.5 |
| 2022 | Visual Studio 2019 version 16.7 |
| 2021 | Visual Studio 2019 (v16.0) |
| 2019-2020 | Visual Studio 2017 with Update 2 |
| 2018 | Visual Studio 2015 with Update 3 |
| 2017 | Visual Studio 2015 with Update 1 |
| 2015-2016 | Visual Studio 2012 with Update 4 |
一个栗子
#include "StdAfx.h"
#include "resource.h"
#include "tchar.h"
#include <aced.h>
#include <dbents.h>
//...
static void TESTDrawPolyline()
{
TCHAR prompt[256];
AcGePoint3d basePt, prevPt;
AcGePoint3dArray ptArray;
int ret = acedGetPoint(NULL, _T("\n指定折线起点: "), asDblArray(basePt));
if (ret != RTNORM)
{
acutPrintf(_T("\n命令取消!"));
return;
}
ptArray.append(basePt);
prevPt = basePt;
while (true)
{
_stprintf_s(prompt, _T("\n指定下一点 [回车完成]: "));
ret = acedGetPoint(asDblArray(prevPt), prompt, asDblArray(basePt));
if (ret == RTNONE || ret == RTCAN) // 回车或者ESC退出循环
break;
if (ret != RTNORM)
continue;
ptArray.append(basePt);
prevPt = basePt;
}
if (ptArray.length() < 2)
{
acutPrintf(_T("\n至少需要两个点!"));
return;
}
AcDbPolyline* pPoly = new AcDbPolyline();
for (int i = 0; i < ptArray.length(); i++)
{
AcGePoint2d pt2d(ptArray[i].x, ptArray[i].y);
pPoly->addVertexAt(i, pt2d, 0.0, 0.0, 0.0);
}
pPoly->setElevation(ptArray[0].z);
AcDbBlockTable* pBlockTable;
acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord* pModelSpace;
pBlockTable->getAt(ACDB_MODEL_SPACE, pModelSpace, AcDb::kForWrite);
pBlockTable->close();
AcDbObjectId polyId;
pModelSpace->appendAcDbEntity(polyId, pPoly);
pModelSpace->close();
pPoly->close();
acutPrintf(_T("\n折线绘制成功!共 %d 个顶点"), ptArray.length());
}
//...
ACED_ARXCOMMAND_ENTRY_AUTO(Ctest1App, TEST, DrawPolyline, DPL, ACRX_CMD_MODAL, NULL)
更多
https://github.com/HexTTX/ObjectARX-SDK/tree/master
更新记录
- 2026.8.10 于佛山市禅城区祖庙街道,季华五路附近

浙公网安备 33010602011771号