BOOL Additional_Class::Get_LineTypeID( CString linetype, AcDbObjectId &linetypeid ) { AcDbLinetypeTable *pLtpTbl; acdbHostApplicationServices()->workingDatabase()->getLinetypeTable(pLtpTbl,AcDb::kForRead); if (!pLtpTbl->has((linetype ))) { pLtpTbl->close(); return FALSE; } pLtpTbl->getAt(linetype, linetypeid); pLtpTbl->close(); return TRUE; }
static Acad::ErrorStatus GetLinetypeId(const CString& linetype, AcDbObjectId &linetypeId) { AcDbLinetypeTable *pLtpTbl; acdbHostApplicationServices()->workingDatabase()->getLinetypeTable(pLtpTbl, AcDb::kForRead); if (!pLtpTbl->has(linetype)) { pLtpTbl->close(); return Acad::eBadLinetypeName; } pLtpTbl->getAt(linetype, linetypeId); pLtpTbl->close(); return Acad::eOk; }
BOOL Additional_Class::Add_LineType( CString linetype ) { AcDbLinetypeTable *pLtpTbl; acdbHostApplicationServices()->workingDatabase()->getLinetypeTable(pLtpTbl,AcDb::kForRead); if (pLtpTbl->has((linetype ))) { pLtpTbl->close(); return TRUE; } pLtpTbl->close(); Acad::ErrorStatus es; es = acdbHostApplicationServices()->workingDatabase()->loadLineTypeFile(linetype, _T("ZWCADiso.lin")); return TRUE; }
//------------------------------------------------------------------------------------------- // // 功能: 遍历线型表中的所有记录,获得并打印线型名 // // // 作者:Qin H.X. // // 日期:200709 // // 历史:无 // //---------------------------------------------------------------------------------------------- // - CGDCH03.IterateLinetype command (do not rename) static void CGDCH03IterateLinetype(void) { // 获取线型表 AcDbLinetypeTable *pLinetypeTbl; acdbHostApplicationServices()->workingDatabase() ->getSymbolTable(pLinetypeTbl, AcDb::kForRead); // 创建线性表的遍历器 AcDbLinetypeTableIterator *pLtIterator; pLinetypeTbl->newIterator(pLtIterator); // 遍历线性表,输出每个线性表记录的名称 AcDbLinetypeTableRecord *pLtTableRcd; const TCHAR *pLtName; for (; !pLtIterator->done(); pLtIterator->step()) { pLtIterator->getRecord(pLtTableRcd, AcDb::kForRead); pLtTableRcd->getName(pLtName); pLtTableRcd->close(); acutPrintf(_T("\n线型名称: %s"), pLtName); } // 删除线性表遍历器并关闭线性表 delete pLtIterator; pLinetypeTbl->close(); }
// Opens the linetype table and iterates through all the // entries printing the name of each linetype. // // THE FOLLOWING CODE APPEARS IN THE SDK DOCUMENT. // void iterateLinetypes() { AcDbLinetypeTable *pLinetypeTbl; acdbHostApplicationServices()->workingDatabase() ->getSymbolTable(pLinetypeTbl, AcDb::kForRead); // Create a new iterator that starts at table // beginning and skips deleted. // AcDbLinetypeTableIterator *pLtIterator; pLinetypeTbl->newIterator(pLtIterator); // Walk the table, getting every table record and // printing the linetype name. // AcDbLinetypeTableRecord *pLtTableRcd; const char *pLtName; for (; !pLtIterator->done(); pLtIterator->step()) { pLtIterator->getRecord(pLtTableRcd, AcDb::kForRead); pLtTableRcd->getName(pLtName); pLtTableRcd->close(); acutPrintf("\nLinetype name is: %s", pLtName); } delete pLtIterator; pLinetypeTbl->close(); }
// 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")); } }
//------------------------------------------------------------------------------------------- // // 功能: 向层表中添加记录(创建新层) // // // 作者: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层已经存在")); } }