天气与日历 切换到窄版

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

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

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
[code]//
//
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;
}[/code]

 

 

 

 

CAD ObjectARX扩展工具的源码(二)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-11-1 11:34 , Processed in 0.145645 second(s), 25 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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