admin 发表于 2024-3-14 20:17:15

[每日一码] 用ARX创建线型

// Creates a new linetype and adds in to the linetype table
//-----------------------------------------------------------
static void createLinetype()
{
    AcDbLinetypeTable *pLtypeTable = NULL ;
    // Get the linetype table from the drawing
    if( acdbHostApplicationServices()->workingDatabase()->getLinetypeTable(
                                    pLtypeTable, AcDb::kForWrite) ==Acad::eOk )
    {
      AcDbLinetypeTableRecord *pLtypeTableRecord = new AcDbLinetypeTableRecord;
      // Set all of the properties of the linetype table record
      pLtypeTableRecord->setAsciiDescription(采用T("T E S T -"));
      pLtypeTableRecord->setPatternLength(0.75);
      pLtypeTableRecord->setNumDashes(2);
      pLtypeTableRecord->setDashLengthAt(0, 0.5);
      pLtypeTableRecord->setDashLengthAt(1,-0.25);
      pLtypeTableRecord->setName(采用T("T采用E采用S采用T"));
      AcDbObjectId tmpId;
      // Add the new linetype to the linetype table
      if(pLtypeTable->add(tmpId, pLtypeTableRecord)==Acad::eOk)
      {
      pLtypeTableRecord->close();
      acutPrintf(采用T("\nNew linetype successfully created."));
      }
      else
      {
      delete pLtypeTableRecord;
      acutPrintf(采用T("\nCannot add new linetype to the drawing."));
      }
      pLtypeTable->close();
    }

} // end of createLinetype()
页: [1]
查看完整版本: [每日一码] 用ARX创建线型