CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2020 开发者帮助

创建复杂实体

2024-5-18 18:25| 发布者: admin| 查看: 83| 评论: 0|原作者: admin|来自: AutoCAD

创建复杂实体

此示例演示如何创建对象并设置其某些属性(图层、颜色索引、闭合参数)。然后,它创建四个顶点对象 (),设置它们的位置,并将它们追加到折线对象。最后,它关闭所有打开的对象 - 顶点、折线、块表记录和块表。关闭折线对象后,AutoCAD 会自动将对象添加到其中。AcDb2dPolylineAcDb2dPolylineVertexAcDbSequenceEnd

void
createPolyline()
{
    // Set four vertex locations for the pline.
    //
    AcGePoint3dArray ptArr;
    ptArr.setLogicalLength(4);
    for (int i = 0; i < 4; i++) {
        ptArr[i].set((double)(i/2), (double)(i%2), 0.0);
    }
    // Dynamically allocate an AcDb2dPolyline object,
    // given four vertex elements whose locations are supplied
    // in ptArr.  The polyline has no elevation, and is
    // explicitly set as closed.  The polyline is simple;
    // that is, not curve fit or a spline.  By default, the
    // widths are all 0.0 and there are no bulge factors.
    //
    AcDb2dPolyline *pNewPline = new AcDb2dPolyline(
        AcDb::k2dSimplePoly, ptArr, 0.0, Adesk::kTrue);
    pNewPline->setColorIndex(3);
    // Get a pointer to a block table object.
    //
    AcDbBlockTable *pBlockTable;
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pBlockTable, AcDb::kForRead);
    // Get a pointer to the MODEL_SPACE BlockTableRecord.
    //
    AcDbBlockTableRecord *pBlockTableRecord;
    pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,
        AcDb::kForWrite);
    pBlockTable->close();
    // Append the pline object to the database and
    // obtain its object ID.
    //
    AcDbObjectId plineObjId;
    pBlockTableRecord->appendAcDbEntity(plineObjId,
        pNewPline);
    pBlockTableRecord->close();
    // Make the pline object reside on layer "0".
    //
    pNewPline->setLayer("0");
    pNewPline->close();
}

父主题:

  1. 复杂实体

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1   苏公网安备32011402011833)

GMT+8, 2024-12-15 12:37

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部