天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 55|回复: 0

ARX读取数据展Cass一般高程点

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
[code]struct resbuf oSysRb, iSysRb;
ads_real blc, blc1;
acedGetVar("USERR1", &oSysRb);
iSysRb.restype = RTREAL;
iSysRb.resval.rreal = 500;
blc = oSysRb.resval.rreal;
if (blc == 0)
{
    if (acedGetReal("\n请输入比例尺<1:500>", &blc1) != RTNORM)
    {
        iSysRb.resval.rreal = 500;
        acedSetVar("USERR1", &iSysRb);
    }
    acedSetVar("USERR1", &iSysRb);
    blc = iSysRb.resval.rreal;
}

AcDbBlockTable *pBlkTbl;
acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl, AcDb::kForWrite);
CString blkName;
blkName.Format("%s", "GC200");
if (!pBlkTbl->has(blkName))
{
    acutPrintf("\n当前图形中未包含GC200的块定义!");
    pBlkTbl->close();
    return;
}

double xyzScale = blc * 0.001;
double textH = blc * 0.002;  // 设置文字高度
CString strH;
strH.Format("%.3lf", textH);

char strTag[100];
CString str("height");
strncpy(strTag,(LPCTSTR)str,sizeof(strTag));

int rc, i;
ads_point pt1;
FILE *FP;
char height[80];
double r;

TCHAR *fName;
struct resbuf *rb;
rb = acutNewRb(RTSTR);
int  stat = acedGetFileD("选择txt文件", NULL, "txt;dat",  0, rb);
if ((stat != RTNORM) || (rb == NULL))
{
    acutRelRb(rb);
    return;
}
const size_t nSize = _tcslen(rb->resval.rstring) + 1;
fName =  (TCHAR*)acad_malloc(nSize *  sizeof(TCHAR));
strcpy(fName, rb->resval.rstring);
acutRelRb(rb);

CString filename;
filename.Format("%s", fName);

FP = fopen(filename, "r");    //以只读形式打开文件
do
{
    fscanf(FP, "%d, %lf, %lf, %lf", &i, &pt1[X], &pt1[Y], &pt1[Z]);

    AcGePoint3d blkbasePt (pt1[X], pt1[Y], pt1[Z]);
    AcGePoint3d textPt (pt1[X] + 0.0012 * blc, pt1[Y] - 0.001 * blc, 0.0);
    AcGePoint3d AlimPt (pt1[X] + 0.0012 * blc, pt1[Y], 0.0);
    r = pt1[Z];
    acdbRToS(r, 2, 2, height);

    AcDbObjectId blkDefId;
    pBlkTbl->getAt(blkName, blkDefId);
    AcDbBlockReference *pBlkRef = new AcDbBlockReference(blkbasePt, blkDefId);
    AcDbBlockTableRecord *pBlkTblRcd;
    pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForWrite);
    pBlkTbl->close();

    // 块比例系数
    pBlkRef->setScaleFactors(xyzScale);
    // 扩展数据
    struct resbuf *pRb;
    CString appName = "SOUTH";
    CString typeName = "202101";
    pRb = acutBuildList(AcDb::kDxfRegAppName, appName, AcDb::kDxfXdAsciiString, typeName, RTNONE);
    pBlkRef->setXData(pRb);
    acutRelRb(pRb);

    AcDbObjectId entId;
    pBlkTblRcd->appendAcDbEntity(entId, pBlkRef);
    // 插入属性
    AcDbEntity *pEnt;
    acdbOpenObject(pEnt, entId, AcDb::kForWrite);
    AcDbBlockTableRecord *pBlkDefRcd;
    acdbOpenObject(pBlkDefRcd, blkDefId, AcDb::kForRead);        
    AcDbBlockTableRecordIterator *pItr;
    pBlkDefRcd->newIterator(pItr);
    for (pItr->start(); !pItr->done(); pItr->step())
    {
        pItr->getEntity(pEnt, AcDb::kForRead);
        AcDbAttributeDefinition *pAttDef = new AcDbAttributeDefinition;
        pAttDef = AcDbAttributeDefinition::cast(pEnt);
        AcDbAttribute *pAttr = new AcDbAttribute;
        pAttr->setPropertiesFrom(pAttDef);           
        pAttr->setHorizontalMode(AcDb::kTextLeft);   // 左对齐
        pAttr->setVerticalMode(AcDb::kTextVertMid);  // 左中
        pAttr->setPosition(textPt);       // 文本的位置点
        pAttr->setAlignmentPoint(AlimPt); // 对齐点
        pAttr->setWidthFactor(0.8);       // 宽度比例
        pAttr->setHeight(textH);          // 高度
        pAttr->setTag(strTag);            // 属性标签
        pAttr->setTextString(height);     // 属性值
        // 扩展数据
        struct resbuf *pRb;
        CString appName = "SOUTH";
        CString typeName = "202111";
        pRb = acutBuildList(AcDb::kDxfRegAppName, appName, AcDb::kDxfXdAsciiString, typeName, RTNONE);
        pAttr->setXData(pRb);
        acutRelRb(pRb);
        // 追加属性
        pBlkRef->appendAttribute(pAttr);
        pAttr->close();
    }
    pBlkRef->setLayer("GCD");
    delete pItr;
    pBlkDefRcd->close();
    pEnt->close();
    pBlkRef->close();
    pBlkTblRcd->close();

    rc = feof(FP);
}
while (rc == 0);
fclose(FP);  //关闭文件
acedCommand(RTSTR, "ZOOM", RTSTR, "E", 0);[/code]

 

 

 

 

ARX读取数据展Cass一般高程点
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 11:32 , Processed in 0.143099 second(s), 26 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表