在ARX中如何加载线型?
在acadiso.lin 中定义有mylinetype,在层中设定线型,使用AcDb2dPolyline()绘制二维多义线,但线型并没有按照指定的线型绘制线条,是否是在绘制前没有加载线型所致?线型又怎样加载呢?
先用createnewlayer() 并高定当前层,再画线:pNewPline = new AcDb2dPolyline(<BR> AcDb::k2dSimplePoly,parr,0,Adesk::kFalse,0.2*kk,0.2*kk,NULL);
在层中高定线型:
void createNewlayer(char *layer,Adesk::UInt16 colorIndex,char* linetype)<BR>{<BR> AcDbLayerTable *pLayerTable;<BR> AcDbObjectId layerId;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pLayerTable,AcDb::kForWrite); <BR> if(!pLayerTable->has(layer)){<BR> AcDbLayerTableRecord *pLayerTableRecord=new AcDbLayerTableRecord;<BR> pLayerTableRecord->setName(layer);<BR> pLayerTableRecord->setIsFrozen(0);//解冻层<BR> pLayerTableRecord->setIsOff(0);//打开层<BR> pLayerTableRecord->setVPDFLT(0);//视区为可见<BR> pLayerTableRecord->setIsLocked(0);//解锁层<BR> /////////////////////////////////<BR> AcCmColor color;<BR> color.setColorIndex(colorIndex);<BR> pLayerTableRecord->setColor(color);<BR> ///////////////////////////////////////////<BR> AcDbLinetypeTable *pLineTypeTbl;<BR> AcDbObjectId ltId;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pLineTypeTbl,AcDb::kForRead);<BR> if((pLineTypeTbl->getAt(linetype,ltId))!=Acad::eOk)<BR> {<BR> pLineTypeTbl->getAt("CONTINUOUS",ltId);<BR> }<BR> pLineTypeTbl->close();
pLayerTableRecord->setLinetypeObjectId(ltId);<BR> pLayerTable->add(pLayerTableRecord); <BR> pLayerTable->close();<BR> pLayerTableRecord->close(); <BR> }<BR> else{ <BR> pLayerTable->close(); <BR> } <BR>}<BR> BOOL CTableHanlder::LoadLinetypeToDatabase(const char *ltn, AcDbObjectId &ltypeId)<BR>{ AcDbDatabase *pCurDb;<BR> AcDbLinetypeTable *pltypeTb;<BR> Acad::ErrorStatus es;<BR> pCurDb=acdbHostApplicationServices()->workingDatabase();<BR> es=pCurDb->getSymbolTable(pltypeTb,AcDb::kForRead);<BR> if(es!=Acad::eOk)return FALSE;<BR> BOOL bFindFlag=pltypeTb->has(ltn);<BR> pltypeTb->close();//close table<BR> /////////////////<BR> //没有则从文件中加载线型<BR> if(!bFindFlag)<BR> {<BR> CString strPath;<BR> CCommonHanlder cmnHanlder;<BR> if(!cmnHanlder.getLinetypePathStr (strPath))//这是我的线型库路径,如果要符合你的,自己搞定!<BR> return FALSE;<BR> strPath+="linetype.lin";<BR> if((es=pCurDb->loadLineTypeFile(ltn,strPath))!=Acad::eOk)<BR> return FALSE;<BR> }<BR> <BR> /////////<BR> es=pCurDb->getSymbolTable(pltypeTb,AcDb::kForRead);<BR> if(es!=Acad::eOk)return FALSE;<BR> es=pltypeTb->getAt(ltn,ltypeId);<BR> pltypeTb->close();<BR> if(es!=Acad::eOk)<BR> return FALSE;<BR> else<BR> return TRUE;<BR>}
//////////////////////////////
看着改改可通用,我就不改了
页:
[1]