目录
一、ACAP类
1.1 AcApGetDatabase函数
- Command.cpp
#include "stdafx.h" #include "Commands.h" #include "Editor.h" #include "Database.h" void AddCommands() { Editor::AddCommand(L"c-test", ACRX_CMD_MODAL, Test); } void Test() { // 函数用于获取指向 CAD 的CView对象 窗口的指针 CView *pView = acedGetAcadDwgView(); // 通过CView对象 窗口的指针 获取数据库对象指针 AcDbDatabase *pDb = AcApGetDatabase(pView); if (pDb == NULL) { acedAlert(_T("获取数据失败!")); return; } // 数据库获取 其自身文件的绝对路径 const ACHAR *fileName; pDb->getFilename(fileName); AfxMessageBox(fileName); }
- 效果
二、AcCm颜色类
2.1 函数accmGetLocalizedColorNames
- 功能:获取系统中,本地颜色名称(ACI颜色名称),用处较少
- Commands.cpp
#include "stdafx.h" #include "Commands.h" #include "Editor.h" #include "Database.h" void AddCommands() { Editor::AddCommand(L"c-test", ACRX_CMD_MODAL, Test); } void Test() { // 指针数组:数组的每个元素都是ACHAR*的指针,[]优先级大于* const ACHAR *colorNames[9]; accmGetLocalizedColorNames(colorNames); for (size_t i = 0; i < 9; i++) acutPrintf(_T("\n颜色本地名:%s"), colorNames[i]); }
- 结果
2.2 函数accmGetColorFromACIName
-
功能:获取AcCmColor颜色类对象,通过ACI颜色名称
-
Commands.cpp
#include "stdafx.h" #include "Commands.h" #include "Editor.h" #include "Database.h" void AddCommands() { Editor::AddCommand(L"c-test", ACRX_CMD_MODAL, Test); } void Test() { ACHAR str[128]; if (acedGetString(NULL, _T("\n输入ACI颜色名称:"), str) != RTNORM) return; AcCmColor col; if (accmGetColorFromACIName(col, str) != Acad::eOk) { acutPrintf(_T("\n颜色输入错误!")); return; } acutPrintf(_T("\n颜色输入成功!")); }
-
获取成功的三个面板
输入正确:
- 索引值:0~256
- 顶级索引:红-red-1,黄-yellow-2,绿-green-3,青-cyan-4,蓝-blue-5,洋红-magenta-6,白-white-7
- 特例:bylayer-256,byblock-0