void asdktest5 () {
    //----- Select the entities
    ads_name ss, en ;
    if ( acedSSGet (NULL, NULL, NULL, NULL, ss) != RTNORM )
        return ;

    //----- Append entity IDs to the collector
    long n ;
    AcDbObjectId id ;
    AsdkHlrCollector collector ;
    acedSSLength (ss, &n) ;
    for ( int i =0 ; i < n ; i++ ) {
        acedSSName (ss, i, en) ;
        acdbGetObjectId (id, en) ;
        collector.addEntity (id) ;
    }
    acedSSFree (ss) ;

    //----- Display a dialog box to select HLR controls, the user wants to apply to the HLR engine
    AfxSetResourceHandle (_hdllInstance) ;
    CControlsDlg dlg ;
    dlg.mnControls =kProject | kEntity | kBlock | kHonorInternals ;
    if ( dlg.DoModal () != IDOK ) {
        AfxSetResourceHandle (acedGetAcadResourceInstance ()) ;
        return ;
    }
    AfxSetResourceHandle (acedGetAcadResourceInstance ()) ;

    int control =dlg.mnControls ;
    acutPrintf (ACRX_T("\nAbout to call hidden Line calculation")) ;
    acutPrintf (ACRX_T("\nCalling with %d Entities"), collector.getInputEntityIds ().logicalLength ()) ;
    acutPrintf (ACRX_T("\nkProject %s "), control & kProject ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkShowAll %s "), control & kShowAll ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkEntity %s "), control & kEntity  ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkBlock %s "), control & kBlock  ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkSubentity %s "), control & kSubentity  ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkHideTangents %s "), control & kHideTangents  ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkCleanup %s "), control & kCleanup  ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkIsolines %s "), control & kIsolines  ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkUnite %s "), control & kUnite  ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkReuse %s "), control & kReuse  ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkProgress %s "), control & kProgress  ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkHandlePoints %s "), control & kHandlePoints  ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkHonorInternals %s "), control & kHonorInternals ? ACRX_T("On") : ACRX_T("Off")) ;
    acutPrintf (ACRX_T("\nkMeshSilhouettes %s "), control & kMeshSilhouettes ? ACRX_T("On") : ACRX_T("Off")) ;
    
    //----- Ask for virtual viewport settings
    AcDbViewport *pVp =NULL ;
    if ( !pickViewport (pVp) )
        return ;

    //----- Process hidden line removal
    AsdkHlrEngine hlr (pVp, control) ;
    hlr.run (collector) ;
    delete pVp ;

    //----- The following code will collect the color of the originator entity of an edge
    //----- and will assign it to the resulting entity.
    actrTransactionManager->startTransaction () ;

    int nOutput =collector.mOutputData.logicalLength () ;
    acutPrintf (ACRX_T("\nHlr returned %d curves"), nOutput) ;
    for ( int j =0 ; j < nOutput ; j++ ) {
        AsdkHlrData *pResult =collector.mOutputData [j] ;

        AcDbEntity *pResultEntity =pResult->getResultEntity () ;
        AcDbObjectId id ;
        if ( postToDatabase (NULL, pResultEntity, id) != Acad::eOk ) {
            acutPrintf (_T("Failed to add entity to current space.\n")) ;
            break ;
        }

        actrTransactionManager->getObject ((AcDbObject *&)pResultEntity, id, AcDb::kForWrite) ;

        AcDbObjectIdArray ids =pResult->getObjectIds () ;
        int last =ids.logicalLength () - 1 ;
        AcCmColor color ;
        AcDbObjectId layerId ;
        color.setColorIndex (0) ;
        while ( last >= 0 && color.colorIndex () == 0 ) {
            AcDbObjectId innerId =ids.at (last) ;
            AcDbObject *pObj ;
            actrTransactionManager->getObject (pObj, innerId, AcDb::kForRead) ;
            AcDbEntity *pEnt =AcDbEntity::cast (pObj) ;

            color =pEnt->color () ;
            layerId =pEnt->layerId () ;
            last-- ;
        }
        if ( layerId != AcDbObjectId::kNull ) {
            pResultEntity->setColor (color) ;
            pResultEntity->setLayer (layerId) ;
        } else {
            AcDbEntity *pEnt =pResult->getEntity () ;
            if ( pEnt != NULL ) {
                pResultEntity->setColor (pEnt->color ()) ;
                pResultEntity->setLayer (pEnt->layer ()) ;
            }
        }
        pResultEntity->close () ;
    }

    actrTransactionManager->endTransaction();
}
Пример #2
0
void ModifyLayerProp()
{
	CString strLayerName(_T("NewLayer"));

	AcDbLayerTable* pLayerTbl = NULL;
	acdbHostApplicationServices()->workingDatabase()->getLayerTable(pLayerTbl, AcDb::kForRead);

	if (!pLayerTbl->has(strLayerName))
	{
		pLayerTbl->close();
		acutPrintf(_T("\nNo existed layer:\"%s\"."), strLayerName);
		return;
	}

	Acad::ErrorStatus es;
	AcDbLayerTableRecord* pLayerTblRcd = NULL;
	pLayerTbl->getAt(strLayerName, pLayerTblRcd, AcDb::kForWrite);

	AcCmColor oldColor = pLayerTblRcd->color();
	int nCurColor = oldColor.colorIndex();
	int nNewColor = oldColor.colorIndex();

	if (acedSetColorDialog(nNewColor, Adesk::kFalse, nCurColor))
	{
		AcCmColor color;
		color.setColorIndex(nNewColor);
		pLayerTblRcd->setColor(color);
		acutPrintf(_T("\nThe color of  layer:\"%s\" has modified!"), strLayerName);
	}

	pLayerTblRcd->close();
	pLayerTbl->close();
}
Пример #3
0
Acad::ErrorStatus AsdkSmiley::setColor( const AcCmEntityColor& color, Adesk::Boolean doSubents )
{
	assertWriteEnabled();
	AcCmColor tcolor;
	tcolor.setRGB(color.red(),color.green(),color.blue());
	tcolor.setColorMethod(AcCmEntityColor::kByColor);
	return AcDbEntity::setColor(tcolor, doSubents);
}
Пример #4
0
  int ads_MyDialog()
  {
// sample from brxtemplate

//++-- See StdAfx for these types
  StringPairs LayerList;

  AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
    pDb->layerTableId();

  LayerTablePointer pLayerTable(pDb->layerTableId(),AcDb::kForRead);

    if(pLayerTable.openStatus() != eOk)
    {
      ads_retnil();
      return( RSRSLT);
    }

  AcDbLayerTableIterator *pLayerTableIterator;
    pLayerTable->newIterator(pLayerTableIterator);

    //++-- iterate though and get our stuff
    for (pLayerTableIterator->start(); 
        !pLayerTableIterator->done(); 
         pLayerTableIterator->step())
    {
    AcDbObjectId LayerId;
    TCHAR *LayerName;
    CString LayerColor;


      pLayerTableIterator->getRecordId(LayerId);
      LayerTableRecordPointer pLayerTableRecord(LayerId,AcDb::kForRead);
      pLayerTableRecord->getName(LayerName);
    AcCmColor clr = pLayerTableRecord->color();
      LayerColor = clr.bookName();

      LayerColor.Format(_T("Red = %03d   Green = %03d   Blue = %03d "), 
                           clr.red(),    clr.green() ,  clr.blue());

      LayerList.push_back(StringPair(String(LayerName), String(LayerColor)));
    }

    delete pLayerTableIterator;
    {
    // you should always call this before your diaog;
    CAcModuleResourceOverride resOverride;

    //show our dialog
      MyDialog dlg(LayerList,CWnd::FromHandle(adsw_acadMainWnd()));
      dlg.DoModal();
    }
    ads_retnil();
    return( RSRSLT);

 }
Пример #5
0
Adesk::Boolean SphereNitrogenPipeDraw::subWorldDraw( AcGiWorldDraw* mode )
{
    assertReadEnabled () ;

    // 类似绿色
    AcCmColor c;
    c.setRGB( 62, 242, 13 );
    DrawSphereNitrogenPipe( mode, m_pt, m_radius, c );

    // 绘制圆
    DrawCircle( mode, m_pt, m_radius, false );

    return Adesk::kTrue;
}
// This function creates a new AcDbLayerTableRecord, fills
// it in, and adds it to the layer table
// 
// THE FOLLOWING CODE APPEARS IN THE SDK DOCUMENT.
//
void
addLayer()
{
    AcDbLayerTable *pLayerTbl;
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pLayerTbl, AcDb::kForWrite);

    if (!pLayerTbl->has(_T("ASDK_TESTLAYER"))) {
        AcDbLayerTableRecord *pLayerTblRcd
            = new AcDbLayerTableRecord;
        pLayerTblRcd->setName(_T("ASDK_TESTLAYER"));
        pLayerTblRcd->setIsFrozen(0);// layer to THAWED
        pLayerTblRcd->setIsOff(0);   // layer to ON
        pLayerTblRcd->setVPDFLT(0);  // viewport default
        pLayerTblRcd->setIsLocked(0);// un-locked

        AcCmColor color;
        color.setColorIndex(1); // set color to red
        pLayerTblRcd->setColor(color);

        // For linetype, we need to provide the object ID of
        // the linetype record for the linetype we want to
        // use.  First, we need to get the object ID.
	//
        AcDbLinetypeTable *pLinetypeTbl;
        AcDbObjectId ltId;
        acdbHostApplicationServices()->workingDatabase()
            ->getSymbolTable(pLinetypeTbl, AcDb::kForRead);
        if ((pLinetypeTbl->getAt(_T("DASHED"), ltId))
            != Acad::eOk)
        {
            acutPrintf(_T("\nUnable to find DASHED")
                _T(" linetype. Using CONTINUOUS"));
            
            // CONTINUOUS is in every drawing, so use it.
            //
            pLinetypeTbl->getAt(_T("CONTINUOUS"), ltId);
        }
        pLinetypeTbl->close();

        pLayerTblRcd->setLinetypeObjectId(ltId);
        pLayerTbl->add(pLayerTblRcd);
        pLayerTblRcd->close();
        pLayerTbl->close();
    } else {
        pLayerTbl->close();
        acutPrintf(_T("\nlayer already exists"));
    }
}
Пример #7
0
bool insertPoints(std::map<std::wstring,AcGePoint3d>& m_Points, Adesk::Int16 pointStyle, double pointSize, double textHeight)
{
	
	AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
	AcCmColor pointColor;
	AcGePoint3d temp;
	AcDbPoint* tmp_point = nullptr;
	AcDbText* tmp_txt = nullptr;
	AcDbBlockTable* pBT = nullptr;
	AcDbBlockTableRecord* pBTR = nullptr;
	ACHAR* nrPct = nullptr;
	/*****************************************************************/
	pointColor.setColorIndex(7);
	Layer::Create(_T("pctContur"), pointColor, false, false, false);
	Layer::Create(_T("nrPct"), pointColor, false, false, false);
	Acad::ErrorStatus es = Acad::eOk;
	es = acdbHostApplicationServices()->workingDatabase()->setPdmode(pointStyle);
	es = acdbHostApplicationServices()->workingDatabase()->setPdsize(pointSize);

	/*****************************************************************/

	pDb->getSymbolTable(pBT, AcDb::kForRead);
	pBT->getAt(ACDB_MODEL_SPACE, pBTR, AcDb::kForWrite);
	pBT->close();

	std::map<std::wstring, AcGePoint3d>::iterator it;
	for (it = m_Points.begin(); it != m_Points.end();it++)
	{
		const wchar_t* key = it->first.c_str();
		tmp_point = new AcDbPoint;
		tmp_point->setPosition(it->second);
		tmp_point->setLayer(_T("pctContur"));
		
		tmp_txt = new AcDbText(it->second, key, AcDbObjectId::kNull, textHeight, 0);
		tmp_txt->setLayer(_T("nrPct"));
		

		pBTR->appendAcDbEntity(tmp_point);
		pBTR->appendAcDbEntity(tmp_txt);
		tmp_point->close();
		tmp_txt->close();
	}

	pBTR->close();

	return true;
}
Пример #8
0
static void CheakLayerExit(CString layerName,int colorIndx, AcDb::LineWeight lineWeigt)
{
	//int colorIndx = 7;		//默认的颜色为白色
	//AcDb::LineWeight lineWeigt = AcDb::kLnWt000;

	//lineWeigt = AcDb::kLnWt030;
	AcDbLayerTable* pLayerTbl = NULL;
	// 获取当前的数据库
	AcDbDatabase*pDB=acdbHostApplicationServices()->workingDatabase();
	// 因为要创建新的图层,所以先要以写的方式获取图层表
	pDB->getSymbolTable(pLayerTbl,AcDb::kForWrite);
	// 检查图层是否存在
	if (!pLayerTbl->has(layerName)) {
		// 初始化一个新的对象,并且设置它的属性
		AcDbLayerTableRecord *pLayerTblRcd = new AcDbLayerTableRecord;
		pLayerTblRcd->setName(layerName);
		pLayerTblRcd->setIsFrozen(0); // 图层设置为THAWED(解冻的)
		pLayerTblRcd->setIsOff(0); // 图层设置为ON(开着的)
		pLayerTblRcd->setIsLocked(0); // 图层 un-locked(解锁的)
		AcCmColor color;
		color.setColorIndex(colorIndx); // 图层的颜色设置
		pLayerTblRcd->setColor(color);
		pLayerTblRcd->setLineWeight(lineWeigt);
		// 增加一个新的图层到容器(表)中
		pLayerTbl->add(pLayerTblRcd);
		// 把新建的图层关闭(不要删除它)
		pLayerTblRcd->close();
		// 关闭容器(表)
		pLayerTbl->close();
	}
	else {
		// 如果这个图层已经存在,仅仅需要关闭表继续就是
		AcDbLayerTableRecord *pLayerTblRcd;
		pLayerTbl->getAt(layerName, pLayerTblRcd, AcDb::kForWrite);
		AcCmColor color;
		color.setColorIndex(colorIndx); // 图层的颜色设置
		pLayerTblRcd->setColor(color);
		pLayerTblRcd->setLineWeight(lineWeigt);
		pLayerTblRcd->close();
		pLayerTbl->close();
		//acutPrintf(_T("\nMYLAYER already exists"));
	}

}
Пример #9
0
	//-------------------------------------------------------------------------------------------
	// 
	//  功能: 向层表中添加记录(创建新层)
	//                 
	//
	//  作者:Qin H.X.
	//
	// 日期:200709
	//
	//  历史:无
	//
	//----------------------------------------------------------------------------------------------
	// - CGDCH03.AddLayer command (do not rename)
	static void CGDCH03AddLayer(void)
	{
		//先声明一个空的层表指针
		AcDbLayerTable *pLayerTbl;  
		//通过当前图形数据库获取层表对象指针
		//打开层表为写入状态
		acdbHostApplicationServices()->workingDatabase()  ->getSymbolTable(pLayerTbl, AcDb::kForWrite); 

		//判断层是否已经存在
		if(!pLayerTbl->has(_T("MyLayer"))) {   
			//新层表记录
			AcDbLayerTableRecord *pLayerTblRcd=  new AcDbLayerTableRecord;
			pLayerTblRcd->setName(_T("MyLayer"));   //设定图层名
			pLayerTblRcd->setIsFrozen(0);   // 图层解冻
			pLayerTblRcd->setIsOff(0);      // 打开图层
			pLayerTblRcd->setVPDFLT(0);   // 使用默认视口
			pLayerTblRcd->setIsLocked(0);   // 图层解锁
			// AcCmColor是ACAD颜色管理类
			AcCmColor color;    
			color.setColorIndex(1);  
			// 图层颜色为红色    
			pLayerTblRcd->setColor(color);  
			// 为给新图层设置线型,要得到线型表记录的ID。
			//  以下的代码演示如何得到并操作记录ID
			AcDbLinetypeTable *pLinetypeTbl;
			AcDbObjectId ltId;
			acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLinetypeTbl, AcDb::kForRead);
			if ((pLinetypeTbl->getAt(_T("DASHED"), ltId))!= Acad::eOk)	{  
				acutPrintf(_T("\n未发现DASHED线型使用CONTINUOUS线型"));
				// 每一个不完全空的图形数据库的线型表中都有线型名为CONTINUOUS 的默认记录
				pLinetypeTbl->getAt(_T("CONTINUOUS"), ltId);
			}
			pLinetypeTbl->close();
			pLayerTblRcd->setLinetypeObjectId(ltId);
			pLayerTbl->add(pLayerTblRcd);
			pLayerTblRcd->close();
			pLayerTbl->close();
		} else {
			pLayerTbl->close();
			acutPrintf(_T("\n层已经存在"));
		}

	}
Пример #10
0
void
AcRectangle::gripDimensionCbackFuncGuts(AcDbGripData* pGrip, 
                                        const AcDbObjectId& objId,
                                        double dimScale,
                                        AcDbDimDataPtrArray& dimDataArr,
                                        bool isHover)
{
    if (pGrip == NULL)
        return;

    AppData *pAppData = (AppData*)pGrip->appData();
    int gripID = pAppData ? pAppData->index() : -1;
    if ((gripID < 0) || (gripID > 4))
        return;

    AcDbEntity *pEnt = NULL;
	if (acdbOpenAcDbEntity(pEnt, objId, AcDb::kForRead) != Acad::eOk)
        return;

    AcRectangle *pRect = AcRectangle::cast(pEnt);
    if (pRect == NULL) {
        pEnt->close();
        return;
    }

    AcGeVector3d mHorizDir = pRect->horizDir();
    AcGeVector3d mNormal = pRect->normal();
    AcGeVector3d vertDir = mNormal.crossProduct(mHorizDir);
    AcGePoint3d mCenter = pRect->center();
    double mWidth = pRect->width();
    double mHeight = pRect->height();
    double mElevation = pRect->elevation();
    pRect->close();

    int dimIndex1 = 0, dimIndex2 = 0;
    AcGePoint3d pt1, pt2, pt3, pt4, dimPt1, dimPt2;
    double horizRot = userToLocalAngle(mNormal, mHorizDir);
    pt1 = mCenter + 0.5 * mWidth * mHorizDir + 0.5 * mHeight * vertDir;
    pt2 = mCenter - 0.5 * mWidth * mHorizDir + 0.5 * mHeight * vertDir;
    pt3 = mCenter - 0.5 * mWidth * mHorizDir - 0.5 * mHeight * vertDir;
    pt4 = mCenter + 0.5 * mWidth * mHorizDir - 0.5 * mHeight * vertDir;

    AcDbAlignedDimension *pAlnDim1 = new AcDbAlignedDimension();
    pAlnDim1->setDatabaseDefaults();
    pAlnDim1->setNormal(mNormal);
    pAlnDim1->setElevation(mElevation);
    //pAlnDim1->setDimtad(1);
    pAlnDim1->setHorizontalRotation(-horizRot);

    AcDbAlignedDimension *pAlnDim2 = new AcDbAlignedDimension();
    pAlnDim2->setDatabaseDefaults();
    pAlnDim2->setNormal(mNormal);
    pAlnDim2->setElevation(mElevation);
    //pAlnDim2->setDimtad(1);
    pAlnDim2->setHorizontalRotation(-horizRot);

    if (isHover) {
        AcCmColor dimColor;
        dimColor.setColorIndex(8);  // gray    
        pAlnDim1->setDimclrd(dimColor);
        pAlnDim1->setDimclre(dimColor);
        pAlnDim1->setDimclrt(dimColor);
        pAlnDim2->setDimclrd(dimColor);
        pAlnDim2->setDimclre(dimColor);
        pAlnDim2->setDimclrt(dimColor);
	}

    switch (gripID) {
    case 1:
        dimIndex1 = 3;
        dimPt1 = mCenter + (0.5 * mHeight + 0.5 * dimScale) * vertDir;
        pAlnDim1->setXLine1Point(pt1);
        pAlnDim1->setXLine2Point(pt2);
        pAlnDim1->setDimLinePoint(dimPt1);

        dimIndex2 = 4;  
        dimPt2 = mCenter + (0.5 * mWidth + 0.5 * dimScale) * mHorizDir;
        pAlnDim2->setXLine1Point(pt1);
        pAlnDim2->setXLine2Point(pt4);
        pAlnDim2->setDimLinePoint(dimPt2);
        break;

    case 2:
        dimIndex1 = 5;
        dimPt1 = mCenter + (0.5 * mHeight + 0.5 * dimScale) * vertDir;
        pAlnDim1->setXLine1Point(pt1);
        pAlnDim1->setXLine2Point(pt2);
        pAlnDim1->setDimLinePoint(dimPt1);

        dimIndex2 = 6;
        dimPt2 = mCenter - (0.5 * mWidth + 0.5 * dimScale) * mHorizDir;
        pAlnDim2->setXLine1Point(pt2);
        pAlnDim2->setXLine2Point(pt3);
        pAlnDim2->setDimLinePoint(dimPt2);
        break;

    case 3:
        dimIndex1 = 7;
        dimPt1 = mCenter - (0.5 * mWidth + 0.5 * dimScale) * mHorizDir;
        pAlnDim1->setXLine1Point(pt2);
        pAlnDim1->setXLine2Point(pt3);
        pAlnDim1->setDimLinePoint(dimPt1);

        dimIndex2 = 8;
        dimPt2 = mCenter - (0.5 * mHeight + 0.5 * dimScale) * vertDir;
        pAlnDim2->setXLine1Point(pt3);
        pAlnDim2->setXLine2Point(pt4);
        pAlnDim2->setDimLinePoint(dimPt2);
        break;

    case 4:
        dimIndex1 = 9;
        dimPt1 = mCenter - (0.5 * mHeight + 0.5 * dimScale) * vertDir;
        pAlnDim1->setXLine1Point(pt3);
        pAlnDim1->setXLine2Point(pt4);
        pAlnDim1->setDimLinePoint(dimPt1);

        dimIndex2 = 10;
        dimPt2 = mCenter + (0.5 * mWidth + 0.5 * dimScale) * mHorizDir;
        pAlnDim2->setXLine1Point(pt4);
        pAlnDim2->setXLine2Point(pt1);
        pAlnDim2->setDimLinePoint(dimPt2);
        break;
    }
	unsigned int ibitFlags = AcDbDimData::kDimFocal & ~AcDbDimData::kDimEditable ;
    AcDbDimData *dimData1 = new AcDbDimData(pAlnDim1);
    AppData *pDimAppData1 = new AppData(dimIndex1, dimScale);
    dimData1->setAppData(pDimAppData1);
    dimData1->setOwnerId(objId);
    dimData1->setDimFocal(true);
	  //dimData1->setBitFlags(ibitFlags);	
    dimData1->setDimEditable(false);
	dimData1->setDimValueFunc(AcRectangle::setDimValueCbackFunc);

    AcDbDimData *dimData2 = new AcDbDimData(pAlnDim2);
    AppData *pDimAppData2 = new AppData(dimIndex2, dimScale);
    dimData2->setAppData(pDimAppData2);
    dimData2->setOwnerId(objId);
	dimData2->setDimFocal(true);
    dimData2->setDimEditable(false);
	dimData2->setDimHideIfValueIsZero(true);
	dimData2->setDimValueFunc(setDimValueCbackFunc);

    dimDataArr.append(dimData1);
    dimDataArr.append(dimData2);

    if(pAppData) {
        pAppData->resetDimData();
        pAppData->appendDimData(dimData1);
        pAppData->appendDimData(dimData2);
    }
}
Пример #11
0
void CreateLayer()
{
	Acad::ErrorStatus es;
	ACHAR szNewName[255];
	_tcscpy(szNewName, _T("NewLayer"));

	AcDbDatabase* pCurDb = acdbHostApplicationServices()->workingDatabase();
	if (pCurDb == NULL)
	{
		acutPrintf(_T("\nError:Current database is NULL!"));
		return;
	}

	AcDbLayerTableRecord* pNewLayer = new AcDbLayerTableRecord;
	es = pNewLayer->setName(szNewName);
	if (es != Acad::eOk)
	{
		acutPrintf(_T("\nFailed setName of the layer!"));
		delete pNewLayer;
		return;
	}

	AcCmColor cmColor;
	cmColor.setColorIndex(1);
	pNewLayer->setColor(cmColor);

	pNewLayer->setIsFrozen(false);
	pNewLayer->setIsOff(false);
	pNewLayer->setVPDFLT(false);
	pNewLayer->setIsLocked(false);

	bool bStat = false;
	AcDbLayerTable* pLayerTbl = NULL;
	es = pCurDb->getLayerTable(pLayerTbl, AcDb::kForWrite);
	if (es == Acad::eOk)
	{
		if (pLayerTbl->has(szNewName))
		{
			acutPrintf(_T("\nThe Layer \"%s\" has existed!"), szNewName);
			delete pNewLayer;
		}
		else
		{
			es = pLayerTbl->add(pNewLayer);
			if (es == Acad::eOk)
			{
				bStat = true;
				pNewLayer->close();
			}
			else
			{
				acutPrintf(_T("\nFailed to add a new layer in LayerTable!"));
				delete pNewLayer;
			}
		}

		pLayerTbl->close();
	}

	if (bStat)
	{
		acutPrintf(_T("\nCreated the new layer: \"%s\" successfully!"), szNewName);
	}
	else
	{
		acutPrintf(_T("\nFailed to create the layer: \"%s\""), szNewName);
	}
}
Пример #12
0
static void DrawSphereNitrogenPipe( AcGiWorldDraw* mode, const AcGePoint3d& pt, double radius, const AcCmColor& c )
{
    AcCmColor bc;
    bc.setRGB( 0, 0, 0 ); // 使用黑色作为第2种颜色
    DrawCircleGradient( mode, pt, radius, ( "INVSPHERICAL" ), c, bc ); // // 反转球形
}