AcDb::kForWrite); // 生成新的图层表记录
AcDbLayerTableRecord *pLayerTableRecord = new AcDbLayerTableRecord; pLayerTableRecord->setName(LayerName); // 设置图层名 pLayerTableRecord->setColor(LayerColor); // 设置图层颜色 AcDbObjectId layerId;
pLayerTable->add(layerId,pLayerTableRecord); // 关闭图层表和图层表记录 pLayerTable->close(); pLayerTableRecord->close(); return layerId; }
//==========================================================
功能:在指定图层上新建一条直线
参数:见注释
返回:直线ID
//==========================================================
AcDbObjectId CreateLine( double x1,double y1,double z1, // 起点坐标 double x2,double y2,double z2, // 终点坐标 AcDbObjectId layer) // 直线所在图层 {
AcGePoint3d StartPt(x1,y1,z1); // 起点 AcGePoint3d EndPt(x2,y2,z2); // 终点
AcDbLine *pLine = new AcDbLine(StartPt,EndPt); // 获得当前图形数据库的符号表 AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,
AcDb::kForRead);
// 获得符号表中的模型空间块表记录指针,用于添加对象 AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);
pBlockTable->close();
// 将直线添加到模型空间块表记录中 AcDbObjectId lineId;
pLine->setLayer(layer,Adesk::kTrue); // 设置直线所在图层
pBlockTableRecord->appendAcDbEntity(lineId,pLine); // 关闭块表记录指针和直线指针 pBlockTableRecord->close(); pLine->close(); // 返回直线ID号 return lineId; }
不太常用的啊
已知一段弧的起点和终点以及其凸度,求其圆心
int getCenter(ads_point startPoint,ads_point endPoint,double bulge,ads_point& center)
{
if (bulge==0.0) {
ads_point_set(startPoint,center); return 0; }
ads_point startPt,endPt;
if (bulge<0.0) {
ads_point_set(endPoint,startPt); ads_point_set(startPoint,endPt); bulge=bulge*(-1.0); } else {
ads_point_set(startPoint,startPt); ads_point_set(endPoint,endPt); }
double distStartToEnd,distX,distY,radius; distStartToEnd=ads_distance(startPt,endPt); distX=distStartToEnd/2.0; distY=bulge*distX;
radius=((distX*distX)+(distY*distY))/(2.0*distY);
double tmpAng; ads_point tmpPt;
tmpAng=ads_angle(startPt,endPt); ads_polar(startPt,tmpAng,distX,tmpPt);
ads_polar(tmpPt,(tmpAng+(_PI/2.0)),(radius-distY),center); return 1;
};
create hatch的
AcDbObjectId CreateHatch( AcDbObjectId dbOId, char cLayer[],
char cPattern[] = \int nColor = 256, double dAngle = 0.0, double dScale = 1.0,
AcDbDatabase * pDbDatab = acdbHostApplicationServices()->workingDatabase())
{
AcCmColor CmC;