zoukankan      html  css  js  c++  java
  • CAD ObjectARX扩展工具的源码(二)

    CAD ObjectARX扩展工具的源码(二)
      //
    AcDbObjectId CDrawFunction::createtextAll(AcGePoint3d pt,char *text,AcDb::TextHorzMode hMode,AcDb::TextertMode Mode,double hight,double widthFactor,double rotation,int color,CString smallFontName,CString bigFontName,CString layerName)
    {
    ASSERT(text!=NULL);
    AcDbText *pText=NULL;
    pText=new AcDbText;
    if(pText==NULL)
    throw Acad::eOutOfMemory;
    AcDbObjectId textId;
    textId=createTextStyle(smallFontName,bigFontName,"xianlu");
    pText->setTextStyle(textId);
    pText->setTextString(text);
    pText->setHeight(hight);
    pText->setColorIndex(color);
    pText->setRotation(rotation);
    pText->setWidthFactor(widthFactor);
    pText->setPosition(pt);
    if(layerName!="")
    pText->setLayer(layerName.GetBuffer(0));
    addToModelSpace(textId, pText);
    pText->close();
    return textId;
    }

    //设置尺寸文本样式
    oid CDrawFunction::setDimTextStyle(AcDbObjectId dimId,AcDbObjectId textStyleId,
    int colorIndex,double textHeight,double textScator,
    double textGap,bool align)
    {
    AcDbDimension *dimText;
    acdbOpenObject(dimText,dimId,AcDb::kForWrite);
    dimText->setDimtxsty(textStyleId); //文本字体DIMTXSTY
    AcCmColor color;
    color.setColorIndex(colorIndex);
    dimText->setDimclrt(color);//文本颜色DIMCLRT
    dimText->setDimtxt(textHeight); //文本高度DIMTXT
    dimText->setDimtfac(textScator);//文本高宽比DIMTFAC
    dimText->setDimgap(textGap);//文本距尺寸距离DIMGAP
    dimText->setDimtoh(align);//文本标注DIMTOH
    dimText->close();
    }

    //设置尺寸延伸线类型
    Acad::ErrorStatus CDrawFunction::setextensionlineStyle(AcDbObjectId dimId,int colorIndex,double length,
    double offLength,bool 1,bool 2)
    {
    Acad::ErrorStatus es=Acad::eOk;
    AcDbDimension *dimText=NULL;
    if((es=acdbOpenObject(dimText,dimId,AcDb::kForWrite))!=Acad::eOk)
    return es;
    AcCmColor color;
    if((es=color.setColorIndex(colorIndex))!=Acad::eOk)
    {
    dimText->close();return es;
    }
    dimText->setDimclre(color);//设置颜色DIMCLRE
    dimText->setDimexe(length);//设置超出长度DIMEXE
    dimText->setDimexo(offLength);//尺寸偏离长度DIMEXO
    dimText->setDimse1(1);//是否注第一条线DIMSE1
    dimText->setDimse2(2);//是否注第二条线DIMSE2
    dimText->close();
    return es;
    }
    //绘制对齐尺寸线
    AcDbObjectId CDrawFunction::drawDimension(AcGePoint3d xLine1Point,AcGePoint3d xLine2Point,
    double fwj,int direction,double distance,CString dimText,CString m_cLayerName)
    {

    AcDbAlignedDimension *dimension=new AcDbAlignedDimension;
    AcGePoint3d dimLinePoint;
    // CCalcuMethod *calcu=new CCalcuMethod();
    // calcu->calEndZbSelf(xLine2Point,distance*direction,fwj,dimLinePoint);
    // delete calcu;calcu=NULL;
    dimension->setXLine1Point(xLine1Point);
    dimension->setDimLinePoint(dimLinePoint);
    dimension->setXLine2Point(xLine2Point);
    dimension->setDimensionText(dimText.GetBuffer(0));
    dimension->setLayer(m_cLayerName.GetBuffer(0));
    AcDbObjectId dimId;
    addToModelSpace(dimId,dimension);
    dimension->close();
    return dimId;
    }

    Acad::ErrorStatus CDrawFunction::createLine(AcDbObjectId &lineId,AcGePoint3d startPt,AcGePoint3d endPt,int color,CString Layer,char *linetype)
    {
    Acad::ErrorStatus es=Acad::eOk;
    ASSERT(linetype!=NULL);
    AcDbLine *pLine = new AcDbLine(startPt, endPt);
    if((es=pLine->setColorIndex(color))!=Acad::eOk)
    {
    pLine->close();return es;
    }
    if(Layer!="")
    {
    if(pLine->setLayer(Layer)==Acad::eKeyNotFound /
    ||pLine->setLayer(Layer)==Acad::eDeletedEntry )
    {
    createNewLayer(Layer);
    if((es=pLine->setLayer(Layer.GetBuffer(0)))!=Acad::eOk)
    {
    pLine->close();return es;
    }
    }
    }
    if(linetype!=NULL)
    {
    AcDbObjectId lineTypeId;
    if(getLinetypeIdFromString(linetype,lineTypeId))
    {
    if((es=pLine->setLinetype(lineTypeId))!=Acad::eOk)
    {
    pLine->close();return es;
    }
    if((es=pLine->setLinetypeScale(1))!=Acad::eOk)
    {
    pLine->close();return es;
    }
    }
    }
    es=addToModelSpace(lineId,pLine);
    return es;
    }

    Acad::ErrorStatus CDrawFunction::createCircle(AcDbObjectId& circleId,AcGePoint3d center,double radius,int color,CString layer)
    {
    Acad::ErrorStatus es=Acad::eOk;
    AcGeector3d normal(0,0,1);
    AcDbCircle *circle=new AcDbCircle(center,normal,radius);
    if((es=circle->setColorIndex(color))!=Acad::eOk)
    {
    circle->close();return es;
    }
    if(layer!="")
    {
    if(circle->setLayer(layer)==Acad::eKeyNotFound /
    ||circle->setLayer(layer)==Acad::eDeletedEntry )
    {
    createNewLayer(layer);
    if((es=circle->setLayer(layer.GetBuffer(0)))!=Acad::eOk)
    {
    circle->close();return es;
    }
    }
    }
    es=addToModelSpace(circleId,circle);
    return es;
    }


    Acad::ErrorStatus CDrawFunction::DrawPolyline(AcDbObjectId& polylineId, AcGePoint3dArray ptArr, int Color, double Width,bool IsClose,CString Layer,char *linetype)
    {
    Acad::ErrorStatus es=Acad::eOk;
    AcDb2dPolyline *pNewPline;
    if(IsClose)pNewPline=new AcDb2dPolyline(AcDb::k2dSimplePoly,ptArr,0,Adesk::kTrue,Width,Width);
    else pNewPline=new AcDb2dPolyline(AcDb::k2dSimplePoly,ptArr,0,Adesk::kFalse,Width,Width);
    if((es=pNewPline->setColorIndex(Color))!=Acad::eOk)
    {
    pNewPline->close();return es;
    }
    if(Layer!="")
    {
    if(pNewPline->setLayer(Layer)==Acad::eKeyNotFound /
    ||pNewPline->setLayer(Layer)==Acad::eDeletedEntry )
    {
    createNewLayer(Layer);
    if((es=pNewPline->setLayer(Layer))!=Acad::eOk)
    {
    pNewPline->close();return es;
    }
    }
    }
    if(linetype!=NULL)
    {
    AcDbObjectId lineTypeId;
    if(getLinetypeIdFromString(linetype,lineTypeId))
    {
    if((es=pNewPline->setLinetype(lineTypeId))!=Acad::eOk)
    {
    pNewPline->close();return es;
    }
    if((es=pNewPline->setLinetypeScale(1))!=Acad::eOk)
    {
    pNewPline->close();return es;
    }
    }
    }
    if(!pNewPline->isLinetypeGenerationOn())
    {
    if((es=pNewPline->setLinetypeGenerationOn())!=Acad::eOk)
    {
    pNewPline->close();return es;
    }
    }
    es=addToModelSpace(polylineId,pNewPline);
    return es;
    }

    Acad::ErrorStatus CDrawFunction::DrawSplinePolyline(AcDbObjectId& polylineId, AcGePoint3dArray ptArr, int Color, double Width,bool IsClose,CString Layer,char *linetype)
    {
    Acad::ErrorStatus es=Acad::eOk;
    AcDb2dPolyline *pNewPline;
    if(IsClose)pNewPline=new AcDb2dPolyline(AcDb::k2dQuadSplinePoly,ptArr,0,Adesk::kTrue,Width,Width);
    else pNewPline=new AcDb2dPolyline(AcDb::k2dQuadSplinePoly,ptArr,0,Adesk::kFalse,Width,Width);
    if((es=pNewPline->setColorIndex(Color))!=Acad::eOk)
    {
    pNewPline->close();return es;
    }
    if(Layer!="")
    {
    if(pNewPline->setLayer(Layer)==Acad::eKeyNotFound /
    ||pNewPline->setLayer(Layer)==Acad::eDeletedEntry )
    {
    createNewLayer(Layer);
    if((es=pNewPline->setLayer(Layer))!=Acad::eOk)
    {
    pNewPline->close();return es;
    }
    }
    }
    if(linetype!=NULL)
    {
    AcDbObjectId lineTypeId;
    if(getLinetypeIdFromString(linetype,lineTypeId))
    {
    if((es=pNewPline->setLinetype(lineTypeId))!=Acad::eOk)
    {
    pNewPline->close();return es;
    }
    if((es=pNewPline->setLinetypeScale(1))!=Acad::eOk)
    {
    pNewPline->close();return es;
    }
    }
    }
    if(!pNewPline->isLinetypeGenerationOn())
    {
    if((es=pNewPline->setLinetypeGenerationOn())!=Acad::eOk)
    {
    pNewPline->close();return es;
    }
    }
    es=addToModelSpace(polylineId,pNewPline);
    return es;
    }
    ————————————————
    版权声明:本文为CSDN博主「sw283632534」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/sw283632534/article/details/5401646

  • 相关阅读:
    scikit_learn 官方文档翻译(集成学习)
    机器学习之SVM与逻辑回归的联系和区别
    有序数组寻找中位数以及寻找K大元素
    有向图算法之拓扑排序
    机器学习之离散型特征处理--独热码(one_hot_encoding)
    计算广告学(2)--广告有效性模型
    机器学习实战--k-均值聚类
    SonarQube 扫描代码,SonarQube 进行代码质量检查
    Docker 搭建 Nexus3
    informix 安装 linux 客户端
  • 原文地址:https://www.cnblogs.com/mjgw/p/12609682.html
Copyright © 2011-2022 走看看