zoukankan      html  css  js  c++  java
  • AcDbTable表格实体的简单例子

    例子是创建一个含有表格实体的块定义

    效果如下(手动插入的块)

    源代码如下,简单示意,采用了我不是很熟悉的智能指针创建实体对象,代码仅供参考

    AcDbObjectPointer<AcDbTable> pTable;
            Acad::ErrorStatus es= pTable.create();
            if (Acad::eOk != es)
                return;
    
            AcDbDictionary *pDict = NULL;
            AcDbObjectId idTblStyle;
            acdbHostApplicationServices()->workingDatabase()->getTableStyleDictionary(pDict,AcDb::kForRead);
            pDict->getAt(_T("Standard"),idTblStyle);
            pDict->close();
            pTable->setTableStyle( idTblStyle );
    
            AcDbTextStyleTable* pTextStyle = NULL;
            acdbHostApplicationServices()->workingDatabase()->getTextStyleTable(pTextStyle,AcDb::kForRead);
            AcDbObjectId textID;
            pTextStyle->getAt(_T("Standard"),textID);
            pTextStyle->close();
            if( !textID.isNull() )
            {
                pTable->setTextStyle(textID);
            }
    
            pTable->setNumColumns(3);
            pTable->setNumRows(8);
            pTable->generateLayout(); 
            pTable->suppressHeaderRow(false);//禁用表头
            //定义插入点
            pTable->setPosition(AcGePoint3d(100,100, 0));
            //定义行高
            pTable->setRowHeight(0,30);
            pTable->setRowHeight(1,5);
            pTable->setRowHeight(2,5);
            pTable->setRowHeight(3,5);
    //         pTable->setRowHeight(4,5);
    //         pTable->setRowHeight(5,5);
    //         pTable->setRowHeight(6,5);
    //         pTable->setRowHeight(7,5);
            //定义列宽
            pTable->setColumnWidth(0,45);
            pTable->setColumnWidth(1,40);
            pTable->setTextString(1,1,_T("sfsfsdfsd"));
            pTable->setAutoScale(1,1,true);
            //重新计算表格块,在添加到块定义的时候(也许后台数据库也需要),需要重新计算
            //表格样式id一定要给
            pTable->recomputeTableBlock();
            pTable->setRegen();
    
            AcDbDatabase *pDb=acdbHostApplicationServices()->workingDatabase();
            if (NULL == pDb) 
                return;
            AcDbBlockTablePointer pTbl(pDb,AcDb::kForWrite);
            if (Acad::eOk != pTbl.openStatus())
                return;
    //         AcDbBlockTableRecordPointer pModelSpace(ACDB_MODEL_SPACE,pDb,AcDb::kForWrite);
    //         if (Acad::eOk != pModelSpace.openStatus())
    //             return;        
            AcDbBlockTableRecordPointer pBlkRcd;
            if (Acad::eOk != pBlkRcd.create())
                return;
            pBlkRcd->setName(_T("智能指针创建的块"));
            AcDbObjectId objId=AcDbObjectId::kNull;
            pBlkRcd->appendAcDbEntity(objId,pTable);        
            pTbl->add(pBlkRcd);
  • 相关阅读:
    Linux JDK安装
    Redis集群搭建
    Struts2 中添加 Servlet
    js小技巧:数组去重
    修改Request 中的数据
    JAVA 图形界面开发基础详解
    JAVA 类和对象基础知识详解
    Java 类的继承详解
    C++ 大学课堂知识点总结
    数据库简单练习 建表+select
  • 原文地址:https://www.cnblogs.com/edata/p/10718731.html
Copyright © 2011-2022 走看看