天气与日历 切换到窄版

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

CreateSurface

[复制链接]
  • TA的每日心情
    开心
    昨天 15:23
  • 签到天数: 69 天

    [LV.6]常住居民II

    410

    主题

    167

    回帖

    2704

    积分

    管理员

    积分
    2704
    发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
    static void CreateSurface(vector<AcGePoint3d> pts, AcDbObjectId &surfaceOid)
            {
                    ErrorStatus  es = eOk;
                    AcApDocument *pActiveDoc = acDocManager->mdiActiveDocument();
                    AcDbDatabase *pDb = pActiveDoc->database();

                    // (1) Creating 4 lines
                    vector<AcDbObjectId> lineOids;

                    AcDbObjectId lineId = AcDbObjectId::kNull;
                    AcDbLine *pLine = NULL;

                    for(int cnt = 1; cnt < pts.size(); cnt++)
                    {
                            pLine = new AcDbLine(pts[cnt-1], pts[cnt]);
                            Add2Db(pLine, lineId);
                            lineOids.push_back(lineId);
                    }       
                    // Closing line
                    pLine = new AcDbLine(pts[pts.size()-1], pts[0]);
                    Add2Db(pLine, lineId);
                    lineOids.push_back(lineId);

                    // (2) Creating a region out of the lines
                AcDbVoidPtrArray curveSegs;
                    AcDbEntity *pLineEnt = NULL;
                    for(int cnt = 0; cnt < lineOids.size(); cnt++)
                    {
                            es = acdbOpenAcDbEntity(pLineEnt, lineOids[cnt], AcDb::kForRead);
                            if (pLineEnt->isKindOf(AcDbCurve::desc()))
                                    curveSegs.append(static_cast<void*>(pLineEnt));
                    }
                    AcDbVoidPtrArray regions;
                    es = AcDbRegion::createFromCurves(curveSegs, regions);

            // close all open entities used to create the region
                    int lenCurves = curveSegs.length();
                    for (int cnt=0; cnt < lenCurves; cnt ++)
                    {
                            pLineEnt = static_cast<AcDbEntity*>(curveSegs[cnt]);
                            pLineEnt->close();
                    }

            // add all created regions to the database
                    AcDbRegion *pRegion;
                    AcDbObjectId regionOid;
                    int lenRegions = regions.length();
                    for (int cnt=0; cnt < lenRegions; cnt++)
                    {
                            pRegion = static_cast<AcDbRegion*>(regions[cnt]);
                            pRegion->setDatabaseDefaults();
                            Add2Db(pRegion, regionOid);
                    }

                    // (3) Create a surface using the region
                    AcDbEntity *pRegionEntity = NULL;
            es = acdbOpenAcDbEntity(pRegionEntity, regionOid, AcDb::kForRead);
                    AcDbSurface *pSurface = NULL;
                    es = AcDbSurface::createFrom(pRegionEntity, pSurface);
                    pRegionEntity->close();

                    Add2Db(pSurface, surfaceOid);
            }

     

     

     

     

    CreateSurface
    中国膜结构网打造全中国最好的膜结构综合平台 ,统一协调膜结构设计,膜结构施工,膜材采购,膜材定制,膜结构预算全方位服务。 中国空间膜结构协会合作单位。
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

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

    GMT+8, 2024-7-1 05:21 , Processed in 0.057047 second(s), 22 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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