CAD读信息

/读出所有的对象//
bool getAllEntity(AcDbObjectIdArray& IdArr)
{
        Acad::ErrorStatus es=Acad::eOk;
                ads_name ssname;
        ads_name fname;
        if (acdbEntNext(NULL, fname) != RTNORM)
        {
                acdbFail("No entities in drawing\n");
                return (0);
        }
        if (acedSSGet(NULL,NULL,NULL,NULL,ssname) !=RTNORM)
        {
                ads_alert("acedSSGet失败");
                return (0);
        }
        long ilast;

        if (acedSSLength(ssname, &ilast) != RTNORM)
    {
                acedSSFree(ssname);
                return (0);
        }
   
        AcDbObjectId Idtemp;
        ads_name ntemp;
        for (long i=0;i<ilast;i++)
        {       
                ads_alert("1");
                acedSSName(ntemp,i,ssname);
                acdbGetObjectId(Idtemp,ntemp);
                IdArr.append(Idtemp);
        }
        acedSSFree(ssname);

//        acutPrintf("eend");
        return (1);
}
// 节点的搜寻


//读点///
bool getAllPoints(AcDbObjectIdArray& IdArr, AcGePoint3dArray& pntArr)
{       

        AcDbObjectId objId;
        for (int i=0 ; i<IdArr.length();i++)
        {
                AcDbObject *SelEnt;
                objId=IdArr.at(i);
       
                acdbOpenObject(SelEnt, objId,AcDb::kForRead);
               
                if (SelEnt->isKindOf(AcDbLine::desc()))
                {       
                        ads_alert("line");
                        SelEnt->close();
                        pLine(objId,pntArr);
                        break;
                }
                else               
                if (SelEnt->isKindOf(AcDbPolyline::desc()))
                {       
                        ads_alert("poly");
                        SelEnt->close();
                        pPolyLine(objId,pntArr);
                        break;
                }
                else               
                if (SelEnt->isKindOf(AcDbCurve::desc()))
                {       
                        ads_alert("curve");
                        SelEnt->close();
                        collectVertices(objId,pntArr);
                        break;
                }
                else
                {       
                        ads_alert("不能识别的类型进入");
                        ads_fail("不能识别的类型");
                        SelEnt->close();
                        return (0);
                }
        }
        return (1);

}







//椭圆,半圆,曲线等//
void collectVertices( AcDbObjectId& ellipseId, AcGePoint3dArray& pts)
{
        AcDbCurve *pEllipse;
    acdbOpenObject(pEllipse, ellipseId, AcDb::kForRead);
    if (pEllipse->isClosed())
        {
                pEllipse->close();
                return;
        }
        AcGePoint3d temp;
        pEllipse->getEndPoint(temp);
        pts.append(temp);
        pEllipse->getStartPoint(temp);
        pts.append(temp);
    pEllipse->close();
        //AcDbObjectId newCurveId;
    //addToModelSpace(newCurveId, pProjectedCurve);

}
///多义线/
void pPolyLine( AcDbObjectId plineId, AcGePoint3dArray& pts)
{
       
        AcDb2dPolyline *pPline;
        acdbOpenObject (pPline,plineId,AcDb::kForRead);
        if (pPline->isClosed())
        {
                pPline->close();
                return;
        }
        AcDbObjectIterator *pVertIter=pPline->vertexIterator();
        pPline->close();
        AcDb2dVertex *pVertex;
        AcGePoint3d location;
        AcDbObjectId vertexObjId;
        for (int vertexNumber = 0;!pVertIter->done();
        vertexNumber++,pVertIter->step())
        {
                vertexObjId = pVertIter->objectId();
                acdbOpenObject (pVertex,vertexObjId,AcDb::kForRead);
                location =  pVertex->position();
                pVertex->close();
                pts.append(location);
        }
        delete pVertIter;
}

//直线//
void pLine( AcDbObjectId LineId, AcGePoint3dArray& pts)
{
        AcDbLine *pLine;
        acdbOpenObject (pLine,LineId,AcDb::kForRead);
        AcGePoint3d location = pLine->startPoint() ;
        pts.append(location);
        location = pLine->endPoint() ;
        pts.append(location);
        pLine->close();
       
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值