CAD ObjectARX扩展工具的源码(二)

2024-02-29 06:48

本文主要是介绍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;
}

这篇关于CAD ObjectARX扩展工具的源码(二)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/757910

相关文章

Java中有什么工具可以进行代码反编译详解

《Java中有什么工具可以进行代码反编译详解》:本文主要介绍Java中有什么工具可以进行代码反编译的相关资,料,包括JD-GUI、CFR、Procyon、Fernflower、Javap、Byte... 目录1.JD-GUI2.CFR3.Procyon Decompiler4.Fernflower5.Jav

使用Python创建一个能够筛选文件的PDF合并工具

《使用Python创建一个能够筛选文件的PDF合并工具》这篇文章主要为大家详细介绍了如何使用Python创建一个能够筛选文件的PDF合并工具,文中的示例代码讲解详细,感兴趣的小伙伴可以了解下... 目录背景主要功能全部代码代码解析1. 初始化 wx.Frame 窗口2. 创建工具栏3. 创建布局和界面控件4

Docker部署Jenkins持续集成(CI)工具的实现

《Docker部署Jenkins持续集成(CI)工具的实现》Jenkins是一个流行的开源自动化工具,广泛应用于持续集成(CI)和持续交付(CD)的环境中,本文介绍了使用Docker部署Jenkins... 目录前言一、准备工作二、设置变量和目录结构三、配置 docker 权限和网络四、启动 Jenkins

MobaXterm远程登录工具功能与应用小结

《MobaXterm远程登录工具功能与应用小结》MobaXterm是一款功能强大的远程终端软件,主要支持SSH登录,拥有多种远程协议,实现跨平台访问,它包括多会话管理、本地命令行执行、图形化界面集成和... 目录1. 远程终端软件概述1.1 远程终端软件的定义与用途1.2 远程终端软件的关键特性2. 支持的

Java数字转换工具类NumberUtil的使用

《Java数字转换工具类NumberUtil的使用》NumberUtil是一个功能强大的Java工具类,用于处理数字的各种操作,包括数值运算、格式化、随机数生成和数值判断,下面就来介绍一下Number... 目录一、NumberUtil类概述二、主要功能介绍1. 数值运算2. 格式化3. 数值判断4. 随机

使用Navicat工具比对两个数据库所有表结构的差异案例详解

《使用Navicat工具比对两个数据库所有表结构的差异案例详解》:本文主要介绍如何使用Navicat工具对比两个数据库test_old和test_new,并生成相应的DDLSQL语句,以便将te... 目录概要案例一、如图两个数据库test_old和test_new进行比较:二、开始比较总结概要公司存在多

Java中基于注解的代码生成工具MapStruct映射使用详解

《Java中基于注解的代码生成工具MapStruct映射使用详解》MapStruct作为一个基于注解的代码生成工具,为我们提供了一种更加优雅、高效的解决方案,本文主要为大家介绍了它的具体使用,感兴趣... 目录介绍优缺点优点缺点核心注解及详细使用语法说明@Mapper@Mapping@Mappings@Co

使用Python实现图片和base64转换工具

《使用Python实现图片和base64转换工具》这篇文章主要为大家详细介绍了如何使用Python中的base64模块编写一个工具,可以实现图片和Base64编码之间的转换,感兴趣的小伙伴可以了解下... 简介使用python的base64模块来实现图片和Base64编码之间的转换。可以将图片转换为Bas

使用Java实现一个解析CURL脚本小工具

《使用Java实现一个解析CURL脚本小工具》文章介绍了如何使用Java实现一个解析CURL脚本的工具,该工具可以将CURL脚本中的Header解析为KVMap结构,获取URL路径、请求类型,解析UR... 目录使用示例实现原理具体实现CurlParserUtilCurlEntityICurlHandler

Rsnapshot怎么用? 基于Rsync的强大Linux备份工具使用指南

《Rsnapshot怎么用?基于Rsync的强大Linux备份工具使用指南》Rsnapshot不仅可以备份本地文件,还能通过SSH备份远程文件,接下来详细介绍如何安装、配置和使用Rsnaps... Rsnapshot 是一款开源的文件系统快照工具。它结合了 Rsync 和 SSH 的能力,可以帮助你在 li