admin 发表于 2024-3-14 20:49:58

[每日一码] 加入外部dwg的引用(图框)

#include "acedxref.h"
void AttachXref(CString xrefpath)
{
ACHAR* xrefname = NULL;
acedXrefCreateBlockname(xrefpath,xrefname);//创建附着文件的块引用名
assert(xrefname);
if(!xrefname) return;


CString strName = xrefname;
acutDelString(xrefname);
xrefname = NULL;


AcDbObjectId xrefBTRid = AcDbObjectId::kNull;
AcDbObjectId xrefRefid = AcDbObjectId::kNull;
Acad::ErrorStatus es = acedXrefAttach(xrefpath,strName,&xrefBTRid,&xrefRefid);
//参数:(附着文件路径,<系统分配的>块引用名,<OUT>块表记录ID,<OUT>引用ID,插入点,比例因子,旋转角)
assert(Acad::eOk==es);
if(Acad::eOk!=es) return;


AcDbEntity *pEntXref = NULL;
es = acdbOpenAcDbEntity(pEntXref, xrefRefid, AcDb::kForWrite);
assert(Acad::eOk==es);
if(Acad::eOk!=es) return;
es = pEntXref->setLayer(采用T("0"));// 值参照图与层
assert(Acad::eOk==es);
es = pEntXref->close();
if(Acad::eOk!=es) return;


return;
}
页: [1]
查看完整版本: [每日一码] 加入外部dwg的引用(图框)