- Supported DWG, DXF, and BDXF file formats:
- Read support for files of version 2.5 through 2014.
- Write support for files of version 12 through 2014.
- Supported DGN file formats:
- Read support for V7 and V8 DGN (including V8 XM and V8I).
- Write support for V8 DGN.
- Convert from V7 to V8.
- Render drawing files using GDI, OpenGL, or DirectX with select entities.
- Recover and repair damaged .dwg files.
- Edit and manipulate CAD data programmatically, including:
- Explode an entity into a set of simpler entities.
- Apply a transformation to an entity.
- Modify arbitrary properties of database objects.
- Clone a database object.
- Many more.
- Export to SVG, PDF, DWF, BMP, STL, DAE (Collda).
- Import DWF / DAE / DGN files into a .dwg database.
- Support custom objects - you can create custom objects that are usable within any Teigha host application (compatible with .dwg files only).
- Support external files such as font files (TTF / SHX), linetype files (LIN / RSC), and hatch pattern files (PAT).
- Recompute dimension geometry from dimension settings.
- Support transactions and undo / redo capabilities for .dwg file data.
- If you’re on the go?
- Control memory allocation / deallocation.
- Support .dwg file “round-trip” data. For example, when you saved a 2007 datasheet
- Support ACIS / parasolid data internally, including rendering (for wireframe and shaded)
- Implement custom commands.
- Sample source code applications
- Integrate with third-party components.
class MyServices : public ExSystemServices, public ExHostAppServices { protected: ODRX_USING_HEAP_OPERATORS(ExSystemServices); };
OdStaticRxObject<MyServices> svcs; odInitialize( &svcs ); odgsInitialize();
// Loading of all public Teigha Architecture DRX modules. // Note that not all calls are necessary for some of them depend on others // but here we list all of them. // // If a program uses TD doesn't modify or create binary files // it may not load any of DRX modules on start because they will be loaded automatically. // But if a program modifies or creates binary files then it is highly recommended // to load all DRX modules program uses. ::odrxDynamicLinker()->loadApp( OD_T("AecBase") ); ::odrxDynamicLinker()->loadApp( OD_T("AecArchBase") ); ::odrxDynamicLinker()->loadApp( OD_T("AecArchDACHBase") ); ::odrxDynamicLinker()->loadApp( OD_T("AecScheduleData") ); ::odrxDynamicLinker()->loadApp( OD_T("AecSchedule") ); ::odrxDynamicLinker()->loadApp( OD_T("AecStructureBase") );
… AECDbSpaceBoundary::rxInit(); AECDbStair::rxInit(); AECDbWall::rxInit(); AECDbZone::rxInit(); …
OdDbDatabasePtr pDatabase = svcs.createDatabase();
OdWrFileBuf cBuffer( strFilename ); pDatabase->writeFile( &cBuffer, OdDb::kDwg, OdDb::kDHL_CURRENT );
AECArchDACHBaseDatabase( pDatabase ).Init(); AECScheduleDatabase( pDatabase ).Init(); AECStructureBaseDatabase( pDatabase ).Init(); init_display_system( pDatabase );
class MyServices : public ExSystemServices, public ExHostAppServices { protected: ODRX_USING_HEAP_OPERATORS(ExSystemServices); }; int wmain(int argc, wchar_t* argv[]) { // Initialize TD with system services. // And create single instance of hostapp services // for TD database creation. OdStaticRxObject<MyServices> svcs; odInitialize( &svcs ); odgsInitialize(); // Loading of all public Teigha Architecture DRX modules. // Note that not all calls are necessary for some of them depend on others // but here we list all of them. // // If a program uses TD doesn't modify or create binary files // it may not load any of DRX modules on start because they will be loaded automatically. // But if a program modifies or creates binary files then it is highly recommended // to load all DRX modules program uses. ::odrxDynamicLinker()->loadApp( OD_T("AecBase") ); ::odrxDynamicLinker()->loadApp( OD_T("AecArchBase") ); ::odrxDynamicLinker()->loadApp( OD_T("AecArchDACHBase") ); ::odrxDynamicLinker()->loadApp( OD_T("AecScheduleData") ); ::odrxDynamicLinker()->loadApp( OD_T("AecSchedule") ); ::odrxDynamicLinker()->loadApp( OD_T("AecStructureBase") ); // Create empty TD database. OdDbDatabasePtr pDatabase = svcs.createDatabase();; // Initialize database with default Teigha Architecture content. AECArchDACHBaseDatabase( pDatabase ).Init(); AECScheduleDatabase( pDatabase ).Init(); AECStructureBaseDatabase( pDatabase ).Init(); init_display_system( pDatabase ); // do something here with TA objects // Perform "zoom extents" on model space. { OdDbViewportTablePtr pVT = pDatabase->getViewportTableId().openObject( OdDb::kForRead ); OdDbViewportTableRecordPtr pV = pVT->getActiveViewportId().openObject( OdDb::kForWrite ); pV->zoomExtents(); } OdWrFileBuf cBuffer( "H:\\TA_test.dwg" ); pDatabase->writeFile( &cBuffer, OdDb::kDwg, OdDb::kDHL_CURRENT ); odgsUninitialize(); odUninitialize(); return 0; }
OdDbObjectId add_wall_style( OdDbDatabasePtr pDatabase ) { OdDbObjectId idResult = AECDbWallStyle::CreateAECObject( pDatabase, OD_T("Wall Style Created By Teigha(R) Architecture") ); AECDbWallStylePtr pWallStyle = idResult.openObject( OdDb::kForWrite ); pWallStyle->SetDescription( OD_T("Wall Style Description") ); pWallStyle->SetDictRecordDescription( OD_T("Dialog caption") ); pWallStyle->SetWallWidth( 4 ); pWallStyle->SetWallWidthUsed( true ); pWallStyle->SetBaseHeight( 110 ); pWallStyle->SetBaseHeightUsed( true ); pWallStyle->SetJustification( AECDefs::ewjLeft ); pWallStyle->SetJustificationUsed( true ); pWallStyle->SetAutomaticCleanups( true ); pWallStyle->SetAutomaticCleanupsUsed( true ); pWallStyle->SetCleanupRadius( 4 ); pWallStyle->SetCleanupRadiusUsed( true ); pWallStyle->SetFloorLineOffset( 3 ); pWallStyle->SetFloorLineOffsetUsed( false ); pWallStyle->SetRoofLineOffset( -3 ); pWallStyle->SetRoofLineOffsetUsed( false ); AECDisplayManager cDM( pDatabase ); AECDbDispPropsWallModelPtr pOverrideModel = AECDbDispPropsWallModel::cast( pWallStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepWallModel::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverrideModel.isNull() ) { pOverrideModel->SetIsDisplayOpeningEndcaps( false ); pOverrideModel->GetBoundaryCompByIndex( 0 )->SetColor( colorAt( 4 ) ); } AECDbDispPropsWallPtr pOverridePlan = AECDbDispPropsWall::cast( pWallStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepWallPlan::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverridePlan.isNull() ) { pOverridePlan->GetBoundaryCompByIndex( 0 )->SetColor( colorAt( 4 ) ); } return( pWallStyle->objectId() ); }
AECDisplayManager cDM( pDatabase ); AECDbDispPropsWallModelPtr pOverrideModel = AECDbDispPropsWallModel::cast( pWallStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepWallModel::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverrideModel.isNull() ) { pOverrideModel->SetIsDisplayOpeningEndcaps( false ); pOverrideModel->GetBoundaryCompByIndex( 0 )->SetColor( colorAt( 2 ) ); }
AECDbWallStylePtr pWallStyle = idResult.openObject( OdDb::kForWrite );
typedef OdSmartPtr<AECDbWallStyle> AECDbWallStylePtr
OdDbObjectId idWall1 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 0, 0 ), OdGePoint2d( 0, 110 ) );
OdDbObjectId add_wall( OdDbDatabasePtr pDatabase, const OdDbObjectId& idStyle, const OdGePoint2d& ptStart, const OdGePoint2d& ptEnd, double dBulge = 0 ) { AECDbWallPtr pWall = AECDbWall::CreateAECObject( pDatabase->getModelSpaceId(), idStyle ); pWall->Set( ptStart, ptEnd, dBulge ); pWall->SetDescription( OD_T("A Wall") ); return( pWall->objectId() ); }
OdDbObjectId idWall1 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 0, 0 ), OdGePoint2d( 0, 110 ) ); OdDbObjectId idWall2 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 0, 110 ), OdGePoint2d( 110, 110 ) ); OdDbObjectId idWall3 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 110, 110 ), OdGePoint2d( 110, 0 ) ); OdDbObjectId idWall4 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 110, 0 ), OdGePoint2d( 0, 0 ), -1 );
OdDbObjectId add_wall_style( OdDbDatabasePtr pDatabase ) { OdDbObjectId idResult = AECDbWallStyle::CreateAECObject( pDatabase, OD_T("Wall Style Created By Teigha(R) Architecture") ); AECDbWallStylePtr pWallStyle = idResult.openObject( OdDb::kForWrite ); pWallStyle->SetDescription( OD_T("Wall Style Description") ); pWallStyle->SetDictRecordDescription( OD_T("Dialog caption") ); pWallStyle->SetWallWidth( 4 ); pWallStyle->SetWallWidthUsed( true ); pWallStyle->SetBaseHeight( 110 ); pWallStyle->SetBaseHeightUsed( true ); pWallStyle->SetJustification( AECDefs::ewjLeft ); pWallStyle->SetJustificationUsed( true ); pWallStyle->SetAutomaticCleanups( true ); pWallStyle->SetAutomaticCleanupsUsed( true ); pWallStyle->SetCleanupRadius( 4 ); pWallStyle->SetCleanupRadiusUsed( true ); pWallStyle->SetFloorLineOffset( 3 ); pWallStyle->SetFloorLineOffsetUsed( false ); pWallStyle->SetRoofLineOffset( -3 ); pWallStyle->SetRoofLineOffsetUsed( false ); AECDisplayManager cDM( pDatabase ); AECDbDispPropsWallModelPtr pOverrideModel = AECDbDispPropsWallModel::cast( pWallStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepWallModel::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverrideModel.isNull() ) { pOverrideModel->SetIsDisplayOpeningEndcaps( false ); pOverrideModel->GetBoundaryCompByIndex( 0 )->SetColor( colorAt( 4 ) ); } AECDbDispPropsWallPtr pOverridePlan = AECDbDispPropsWall::cast( pWallStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepWallPlan::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverridePlan.isNull() ) { pOverridePlan->GetBoundaryCompByIndex( 0 )->SetColor( colorAt( 4 ) ); } return( pWallStyle->objectId() ); } OdDbObjectId add_wall( OdDbDatabasePtr pDatabase, const OdDbObjectId& idStyle, const OdGePoint2d& ptStart, const OdGePoint2d& ptEnd, double dBulge = 0 ) { AECDbWallPtr pWall = AECDbWall::CreateAECObject( pDatabase->getModelSpaceId(), idStyle ); pWall->Set( ptStart, ptEnd, dBulge ); pWall->SetDescription( OD_T("A Wall") ); return( pWall->objectId() ); } int wmain(int argc, wchar_t* argv[]) { // Initialize TD with system services. // And create single instance of hostapp services // for TD database creation. OdStaticRxObject<MyServices> svcs; odInitialize( &svcs ); odgsInitialize(); // Loading of all public Teigha Architecture DRX modules. // Note that not all calls are necessary for some of them depend on others // but here we list all of them. // // If a program uses TD doesn't modify or create binary files // it may not load any of DRX modules on start because they will be loaded automatically. // But if a program modifies or creates binary files then it is highly recommended // to load all DRX modules program uses. ::odrxDynamicLinker()->loadApp( OD_T("AecBase") ); ::odrxDynamicLinker()->loadApp( OD_T("AecArchBase") ); ::odrxDynamicLinker()->loadApp( OD_T("AecArchDACHBase") ); ::odrxDynamicLinker()->loadApp( OD_T("AecScheduleData") ); ::odrxDynamicLinker()->loadApp( OD_T("AecSchedule") ); ::odrxDynamicLinker()->loadApp( OD_T("AecStructureBase") ); // Create empty TD database. OdDbDatabasePtr pDatabase = svcs.createDatabase();; // Initialize database with default Teigha Architecture content. AECArchDACHBaseDatabase( pDatabase ).Init(); AECScheduleDatabase( pDatabase ).Init(); AECStructureBaseDatabase( pDatabase ).Init(); init_display_system( pDatabase ); OdDbObjectId idWallStyle = add_wall_style( pDatabase ); OdDbObjectId idWall1 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 0, 0 ), OdGePoint2d( 0, 110 ) ); OdDbObjectId idWall2 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 0, 110 ), OdGePoint2d( 110, 110 ) ); OdDbObjectId idWall3 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 110, 110 ), OdGePoint2d( 110, 0 ) ); OdDbObjectId idWall4 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 110, 0 ), OdGePoint2d( 0, 0 ), -1 ); // Perform "zoom extents" on model space. { OdDbViewportTablePtr pVT = pDatabase->getViewportTableId().openObject( OdDb::kForRead ); OdDbViewportTableRecordPtr pV = pVT->getActiveViewportId().openObject( OdDb::kForWrite ); pV->zoomExtents(); } OdWrFileBuf cBuffer( "H:\\TA_test.dwg" ); pDatabase->writeFile( &cBuffer, OdDb::kDwg, OdDb::kDHL_CURRENT ); odgsUninitialize(); odUninitialize(); return 0; }
OdDbObjectId idWindowStyle = add_window_style( pDatabase );
OdDbObjectId add_window_style( OdDbDatabasePtr pDatabase ) { OdDbObjectId idWStyle = AECDbWindowStyle::CreateAECObject( pDatabase, OD_T("Window Style Created By Teigha(R) Architecture") ); AECDbWindowStylePtr pWindowStyle = idWStyle.openObject( OdDb::kForWrite ); pWindowStyle->SetDescription( OD_T("Window Style Description") ); pWindowStyle->SetDictRecordDescription( OD_T("Dialog caption") ); pWindowStyle->SetAutoAdjustToWidthOfWall( true ); pWindowStyle->SetFrameWidth( 2 ); pWindowStyle->SetFrameDepth( 5 ); pWindowStyle->SetSashWidth( 2 ); pWindowStyle->SetSashDepth( 3 ); pWindowStyle->SetGlassThickness( 1 ); pWindowStyle->SetWindowType( AECDefs::ewtGlider ); pWindowStyle->SetWindowShape( AECDefs::esRectangular ); AECDisplayManager cDM( pDatabase ); AECDbDispPropsWindowPtr pOverrideModel = AECDbDispPropsWindow::cast( pWindowStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepWindowModel::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverrideModel.isNull() ) { pOverrideModel->GetFrameComp()->SetColor( colorAt( 1 ) ); pOverrideModel->GetSashComp()->SetColor( colorAt( 2 ) ); pOverrideModel->GetGlassComp()->SetColor( colorAt( 3 ) ); } AECDbDispPropsWindowPtr pOverridePlan = AECDbDispPropsWindow::cast( pWindowStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepWindowPlan::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverridePlan.isNull() ) { pOverridePlan->GetFrameComp()->SetColor( colorAt( 1 ) ); pOverridePlan->GetSashComp()->SetColor( colorAt( 2 ) ); pOverridePlan->GetGlassComp()->SetColor( colorAt( 3 ) ); } return( pWindowStyle->objectId() ); }
OdDbObjectId idWindow01 = add_window( pDatabase, idWindowStyle, idWall1, 10, 10 );
// Inserts a window into a database using the specified window style. // If idWall parameter is not null it also attaches the window to the wall. // Returns Object ID of newly created window. OdDbObjectId add_window( OdDbDatabasePtr pDatabase, const OdDbObjectId& idStyle, const OdDbObjectId& idWall, double dOffsetAlongX, double dOffsetAlongZ ) { AECDbWindowPtr pWindow = AECDbWindow::CreateAECObject( pDatabase->getModelSpaceId(), idStyle ); pWindow->SetRise( 10 ); pWindow->SetWidth( 40 ); pWindow->SetHeight( 40 ); pWindow->SetOpenPercent( 60 ); pWindow->SetMeasureTo( AECDefs::eomtOutsideFrame ); pWindow->SetLeaf( 10 ); if ( !idWall.isNull() ) { pWindow->AttachWallAnchor( idWall ); AECDbAnchorEntToCurvePtr pAnchor = pWindow->GetAnchor().openObject( OdDb::kForWrite ); pAnchor->GetXParams()->SetOffset( dOffsetAlongX ); pAnchor->GetZParams()->SetOffset( dOffsetAlongZ ); } return( pWindow->objectId() ); }
enum WindowType { ewtPicture = 1, ewtSingleHung = 2, ewtDoubleHung = 3, ewtAwningTransom = 4, ewtDoubleCasement = 5, ewtGlider = 6, ewtHopperTransom = 7, ewtPassThrough = 8, ewtSingleCasement = 9, ewtSingleHopper = 10, ewtSingleAwning = 11, ewtVerticalPivot = 12, ewtHorizontalPivot = 13, ewtUnevenSingleHung = 14, ewtUnevenDoubleHung = 15 }; enum Shape { esRectangular = 0, esRound = 1, esHalfRound = 2, esQuarterRound = 3, esOval = 4, esArch = 5, esTrapezoid = 6, esGothic = 7, esIsoscelesTriangle = 8, esRightTriangle = 9, esPeakPentagon = 10, esOctagon = 11, esHexagon = 12, esCustom = 13 };
OdDbObjectId idWindow01 = add_window( pDatabase, idWindowStyle, idWall1, 10, 10 ); OdDbObjectId idWindow02 = add_window( pDatabase, idWindowStyle, idWall1, 60, 10 ); OdDbObjectId idWindow03 = add_window( pDatabase, idWindowStyle, idWall1, 10, 60 ); OdDbObjectId idWindow04 = add_window( pDatabase, idWindowStyle, idWall1, 60, 60 ); OdDbObjectId idWindow05 = add_window( pDatabase, idWindowStyle, idWall2, 10, 10 ); OdDbObjectId idWindow06 = add_window( pDatabase, idWindowStyle, idWall2, 60, 10 ); OdDbObjectId idWindow07 = add_window( pDatabase, idWindowStyle, idWall2, 10, 60 ); OdDbObjectId idWindow08 = add_window( pDatabase, idWindowStyle, idWall2, 60, 60 ); OdDbObjectId idWindow09 = add_window( pDatabase, idWindowStyle, idWall3, 10, 10 ); OdDbObjectId idWindow10 = add_window( pDatabase, idWindowStyle, idWall3, 60, 10 ); OdDbObjectId idWindow11 = add_window( pDatabase, idWindowStyle, idWall3, 10, 60 ); OdDbObjectId idWindow12 = add_window( pDatabase, idWindowStyle, idWall3, 60, 60 );
// Inserts profile definition into a database. // Returns Object ID of newly created profile definition. OdDbObjectId add_profile_def( OdDbDatabasePtr pDatabase ) { OdDbObjectId idProfDef = AECDbProfileDef::CreateAECObject( pDatabase, OD_T("Profile Definition Created By Teigha(R) Architecture") ); AECDbProfileDefPtr pProfileDefinition = idProfDef.openObject( OdDb::kForWrite ); AECGe::Profile2D cProfile; cProfile.resize( 2 ); cProfile[ 0 ].appendVertex( OdGePoint2d( 0, 0 ) ); cProfile[ 0 ].appendVertex( OdGePoint2d( 1, 0 ) ); cProfile[ 0 ].appendVertex( OdGePoint2d( 1, 1 ) ); cProfile[ 0 ].appendVertex( OdGePoint2d( 0, 1 ) ); cProfile[ 0 ].setClosed(); // Forces the contour to be counter-clockwise. // So if the contour is already ccw this call is not needed. cProfile[ 0 ].makeCCW(); cProfile[ 1 ].appendVertex( OdGePoint2d( 0.2, 0.2 ) ); cProfile[ 1 ].appendVertex( OdGePoint2d( 0.2, 0.8 ) ); cProfile[ 1 ].appendVertex( OdGePoint2d( 0.8, 0.8 ) ); cProfile[ 1 ].appendVertex( OdGePoint2d( 0.8, 0.2 ) ); cProfile[ 1 ].setClosed(); cProfile[ 1 ].makeCCW( false ); pProfileDefinition->GetProfile()->Init( cProfile ); return( pProfileDefinition->objectId() ); } // Inserts a door style into a database. // Returns Object ID of newly created door style. OdDbObjectId add_door_style( OdDbDatabasePtr pDatabase, const OdDbObjectId& idProfile ) { OdDbObjectId idDoorStyle = AECDbDoorStyle::CreateAECObject( pDatabase, OD_T("Door Style Created By Teigha(R) Architecture") ); AECDbDoorStylePtr pDoorStyle = idDoorStyle.openObject( OdDb::kForWrite ); pDoorStyle->SetDescription( OD_T("Door Style Description") ); pDoorStyle->SetDictRecordDescription( OD_T("Dialog caption") ); pDoorStyle->SetAutoAdjustToWidthOfWall( true ); pDoorStyle->SetFrameWidth( 2 ); pDoorStyle->SetFrameDepth( 5 ); pDoorStyle->SetStopWidth( 2 ); pDoorStyle->SetStopDepth( 3 ); pDoorStyle->SetShapeAndType( AECDefs::esCustom, AECDefs::edtSingle ); pDoorStyle->SetProfile( idProfile ); pDoorStyle->SetGlassThickness( 1 ); AECDisplayManager cDM( pDatabase ); AECDbDispPropsDoorPtr pOverrideModel = AECDbDispPropsDoor::cast( pDoorStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepDoorModel::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverrideModel.isNull() ) { pOverrideModel->GetPanelComp()->SetColor( colorAt( 1 ) ); pOverrideModel->GetFrameComp()->SetColor( colorAt( 2 ) ); pOverrideModel->GetStopComp()->SetColor( colorAt( 3 ) ); pOverrideModel->GetSwingComp()->SetColor( colorAt( 4 ) ); pOverrideModel->GetGlassComp()->SetColor( colorAt( 5 ) ); } AECDbDispPropsDoorPtr pOverridePlan = AECDbDispPropsDoor::cast( pDoorStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepDoorPlan::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverridePlan.isNull() ) { pOverridePlan->GetPanelComp()->SetColor( colorAt( 1 ) ); pOverridePlan->GetFrameComp()->SetColor( colorAt( 2 ) ); pOverridePlan->GetStopComp()->SetColor( colorAt( 3 ) ); pOverridePlan->GetSwingComp()->SetColor( colorAt( 4 ) ); pOverridePlan->GetDirectionComp()->SetColor( colorAt( 5 ) ); } return( pDoorStyle->objectId() ); } // Inserts a door into a database using the specified door style. // If idWall parameter is not null it also attaches the door to the wall. // Returns Object ID of newly created door. OdDbObjectId add_door( OdDbDatabasePtr pDatabase, const OdDbObjectId& idStyle, const OdDbObjectId& idWall, double dOffsetAlongX, double dOffsetAlongZ ) { AECDbDoorPtr pDoor = AECDbDoor::CreateAECObject( pDatabase->getModelSpaceId(), idStyle ); pDoor->SetRise( 10 ); pDoor->SetWidth( 40 ); pDoor->SetHeight( 50 ); pDoor->SetOpenPercent( 20 ); pDoor->SetMeasureTo( AECDefs::eomtOutsideFrame ); pDoor->SetLeaf( 10 ); if ( !idWall.isNull() ) { pDoor->AttachWallAnchor( idWall ); AECDbAnchorEntToCurvePtr pAnchor = pDoor->GetAnchor().openObject( OdDb::kForWrite ); pAnchor->GetXParams()->SetOffset( dOffsetAlongX ); pAnchor->GetZParams()->SetOffset( dOffsetAlongZ ); } return( pDoor->objectId() ); }
AECDbWallPtr pWall = idWall4.openObject( OdDb::kForRead ); double dLength = pWall->GetLength(); double dOWidth = 40; double dL1 = 10; double dL3 = dLength - dOWidth - 10; double dL2 = dL1 + dOWidth + (dL3 - (dL1 + 2 * dOWidth)) / 2; OdDbObjectId idDoor = add_door ( pDatabase, idDoorStyle, idWall4, dL2, 0 );
OdDbObjectId idWindow13 = add_window ( pDatabase, idWindowStyle, idWall4, dL1, 10 ); OdDbObjectId idWindow14 = add_window ( pDatabase, idWindowStyle, idWall4, dL3, 10 ); OdDbObjectId idWindow15 = add_window ( pDatabase, idWindowStyle, idWall4, dL1, 60 ); OdDbObjectId idWindow16 = add_window ( pDatabase, idWindowStyle, idWall4, dL2, 60 ); OdDbObjectId idOpening = add_window ( pDatabase, idWindowStyle, idWall4, dL3, 60 );
void add_roof( OdDbDatabasePtr pDatabase ) { AECGe::Profile2D cProfile; cProfile.resize( 1 ); cProfile.front().appendVertex( OdGePoint2d( 0, 0 ) ); cProfile.front().appendVertex( OdGePoint2d( 0, 110 ) ); cProfile.front().appendVertex( OdGePoint2d( 110, 110 ) ); cProfile.front().appendVertex( OdGePoint2d( 110, 0 ), -1 ); cProfile.front().setClosed(); cProfile.front().makeCCW(); AECDbRoofPtr pRoof = AECDbRoof::CreateAECObject( pDatabase->getModelSpaceId() ); // Initialize roof profile. // By default all edges of Roof Profile have single slope of 45 degrees. pRoof->GetProfile()->Init( cProfile ); pRoof->SetThickness( 2 ); //// Manually modify Roof Segments. AECGeRingSubPtr pRoofLoop = pRoof->GetProfile()->GetRingByIndex( 0 ); if ( !pRoofLoop.isNull() ) { OdUInt32 i, iSize = pRoofLoop->GetSegmentCount(); for ( i = 0; i < iSize; i++ ) { AECGeRoofSegmentSubPtr pSeg = pRoofLoop->GetSegments()->GetAt( i ); pSeg->SetFaceCount(1); pSeg->SetFaceHeightByIndex(0, 110); pSeg->SetBaseHeight(0); pSeg->SetOverhang(10.0); pSeg->SetFaceSlopeByIndex(0, OdaPI4); pSeg->SetSegmentCount(10); } } pRoof->setColorIndex( 3 ); }
void add_slab( OdDbDatabasePtr pDatabase ) { OdDbObjectId idStyle = AECDbSlabStyle::GetAECObject( pDatabase, OD_T("Slab Style") ); if ( idStyle.isNull() ) { idStyle = AECDbSlabStyle::CreateAECObject( pDatabase, OD_T("Slab Style") ); } AECDbSlabStylePtr pStyle = idStyle.openObject( OdDb::kForWrite ); if ( !pStyle.isNull() ) { pStyle->GetComponents()->Clear(); AECSlabStyleCompPtr pCmp = AECSlabStyleComp::createObject(); pCmp->SetName( OD_T("Base") ); pCmp->GetPosition()->GetThickness()->SetUseBaseValue( false ); pCmp->GetPosition()->GetThickness()->SetBaseValue( 6 ); pCmp->GetPosition()->GetThicknessOffset()->SetUseBaseValue( false ); pCmp->GetPosition()->GetThicknessOffset()->SetBaseValue( - 6 ); pStyle->GetComponents()->Insert( pCmp ); } AECDbSlabPtr pSlab = AECDbSlab::CreateAECObject( pDatabase->getModelSpaceId(), idStyle ); { AECGe::Profile2D cBase; cBase.resize( 1 ); cBase.front().appendVertex( OdGePoint2d( -5, -5 ), 1 ); cBase.front().appendVertex( OdGePoint2d( 115, -5 ) ); cBase.front().appendVertex( OdGePoint2d( 115, 115 ) ); cBase.front().appendVertex( OdGePoint2d( -5, 115 ) ); cBase.front().setClosed(); cBase.front().makeCCW(); pSlab->GetSlabFace()->Init( cBase ); } pSlab->SetThickness( 5 ); pSlab->SetVerticalOffset( 0 ); pSlab->SetHorizontalOffset( 0 ); pSlab->SetPivotPoint( OdGePoint3d::kOrigin ); AECDisplayManager cDM( pDatabase ); AECDbDispPropsSlabPtr pOverrideModel = AECDbDispPropsSlab::cast( pSlab->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepSlabModel::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverrideModel.isNull() ) { pOverrideModel->GetBoundaryCompByIndex( 0 )->SetColor( colorAt( 1 ) ); pOverrideModel->GetBaselineComp()->SetColor( colorAt( 4 ) ); pOverrideModel->GetPivotPointComp()->SetColor( colorAt( 5 ) ); pOverrideModel->GetFasciaComp()->SetColor( colorAt( 6 ) ); pOverrideModel->GetSoffitComp()->SetColor( colorAt( 7 ) ); pOverrideModel->GetShrinkWrapBodyComp()->SetColor( colorAt( 8 ) ); } AECDbDispPropsSlabPlanPtr pOverridePlan = AECDbDispPropsSlabPlan::cast( pSlab->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepSlabPlan::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverridePlan.isNull() ) { pOverridePlan->SetIsOverrideCutPlane( false ); pOverridePlan->GetHatchComp()->SetColor( colorAt( 1 ) ); pOverridePlan->GetBelowCutPlaneBodyComp()->SetColor( colorAt( 2 ) ); pOverridePlan->GetAboveCutPlaneBodyComp()->SetColor( colorAt( 3 ) ); pOverridePlan->GetBelowCutPlaneOutlineComp()->SetColor( colorAt( 4 ) ); pOverridePlan->GetAboveCutPlaneOutlineComp()->SetColor( colorAt( 5 ) ); } }
OdDbObjectId add_wall_style( OdDbDatabasePtr pDatabase ) { OdDbObjectId idResult = AECDbWallStyle::CreateAECObject( pDatabase, OD_T("Wall Style Created By Teigha(R) Architecture") ); AECDbWallStylePtr pWallStyle = idResult.openObject( OdDb::kForWrite ); pWallStyle->SetDescription( OD_T("Wall Style Description") ); pWallStyle->SetDictRecordDescription( OD_T("Dialog caption") ); pWallStyle->SetWallWidth( 4 ); pWallStyle->SetWallWidthUsed( true ); pWallStyle->SetBaseHeight( 110 ); pWallStyle->SetBaseHeightUsed( true ); pWallStyle->SetJustification( AECDefs::ewjLeft ); pWallStyle->SetJustificationUsed( true ); pWallStyle->SetAutomaticCleanups( true ); pWallStyle->SetAutomaticCleanupsUsed( true ); pWallStyle->SetCleanupRadius( 4 ); pWallStyle->SetCleanupRadiusUsed( true ); pWallStyle->SetFloorLineOffset( 3 ); pWallStyle->SetFloorLineOffsetUsed( false ); pWallStyle->SetRoofLineOffset( -3 ); pWallStyle->SetRoofLineOffsetUsed( false ); AECDisplayManager cDM( pDatabase ); AECDbDispPropsWallModelPtr pOverrideModel = AECDbDispPropsWallModel::cast( pWallStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepWallModel::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverrideModel.isNull() ) { pOverrideModel->SetIsDisplayOpeningEndcaps( false ); pOverrideModel->GetBoundaryCompByIndex( 0 )->SetColor( colorAt( 4 ) ); } AECDbDispPropsWallPtr pOverridePlan = AECDbDispPropsWall::cast( pWallStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepWallPlan::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverridePlan.isNull() ) { pOverridePlan->GetBoundaryCompByIndex( 0 )->SetColor( colorAt( 4 ) ); } return( pWallStyle->objectId() ); } OdDbObjectId add_wall( OdDbDatabasePtr pDatabase, const OdDbObjectId& idStyle, const OdGePoint2d& ptStart, const OdGePoint2d& ptEnd, double dBulge = 0 ) { AECDbWallPtr pWall = AECDbWall::CreateAECObject( pDatabase->getModelSpaceId(), idStyle ); pWall->Set( ptStart, ptEnd, dBulge ); pWall->SetDescription( OD_T("A Wall") ); /*AECGe::Contour2D cContour; cContour.appendVertex( OdGePoint2d( 0, pWall->GetHeight() ) ); cContour.appendVertex( OdGePoint2d( pWall->GetLength() / 2, pWall->GetHeight() * 1.5 ) ); cContour.appendVertex( OdGePoint2d( pWall->GetLength(), pWall->GetHeight() ) ); AECWallCutLineSubPtr pTop = pWall->CreateTopCutLine(); pTop->SetRawCutLine( cContour );*/ return( pWall->objectId() ); } OdDbObjectId add_window_style( OdDbDatabasePtr pDatabase ) { OdDbObjectId idWStyle = AECDbWindowStyle::CreateAECObject( pDatabase, OD_T("Window Style Created By Teigha(R) Architecture") ); AECDbWindowStylePtr pWindowStyle = idWStyle.openObject( OdDb::kForWrite ); pWindowStyle->SetDescription( OD_T("Window Style Description") ); pWindowStyle->SetDictRecordDescription( OD_T("Dialog caption") ); pWindowStyle->SetAutoAdjustToWidthOfWall( true ); pWindowStyle->SetFrameWidth( 2 ); pWindowStyle->SetFrameDepth( 5 ); pWindowStyle->SetSashWidth( 2 ); pWindowStyle->SetSashDepth( 3 ); pWindowStyle->SetGlassThickness( 1 ); pWindowStyle->SetWindowType( AECDefs::ewtGlider ); pWindowStyle->SetWindowShape( AECDefs::esRectangular ); AECDisplayManager cDM( pDatabase ); AECDbDispPropsWindowPtr pOverrideModel = AECDbDispPropsWindow::cast( pWindowStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepWindowModel::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverrideModel.isNull() ) { pOverrideModel->GetFrameComp()->SetColor( colorAt( 1 ) ); pOverrideModel->GetSashComp()->SetColor( colorAt( 2 ) ); pOverrideModel->GetGlassComp()->SetColor( colorAt( 3 ) ); } AECDbDispPropsWindowPtr pOverridePlan = AECDbDispPropsWindow::cast( pWindowStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepWindowPlan::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverridePlan.isNull() ) { pOverridePlan->GetFrameComp()->SetColor( colorAt( 1 ) ); pOverridePlan->GetSashComp()->SetColor( colorAt( 2 ) ); pOverridePlan->GetGlassComp()->SetColor( colorAt( 3 ) ); } return( pWindowStyle->objectId() ); } // Inserts a window into a database using the specified window style. // If idWall parameter is not null it also attaches the window to the wall. // Returns Object ID of newly created window. OdDbObjectId add_window( OdDbDatabasePtr pDatabase, const OdDbObjectId& idStyle, const OdDbObjectId& idWall, double dOffsetAlongX, double dOffsetAlongZ ) { AECDbWindowPtr pWindow = AECDbWindow::CreateAECObject( pDatabase->getModelSpaceId(), idStyle ); pWindow->SetRise( 10 ); pWindow->SetWidth( 40 ); pWindow->SetHeight( 40 ); pWindow->SetOpenPercent( 60 ); pWindow->SetMeasureTo( AECDefs::eomtOutsideFrame ); pWindow->SetLeaf( 10 ); if ( !idWall.isNull() ) { pWindow->AttachWallAnchor( idWall ); AECDbAnchorEntToCurvePtr pAnchor = pWindow->GetAnchor().openObject( OdDb::kForWrite ); pAnchor->GetXParams()->SetOffset( dOffsetAlongX ); pAnchor->GetZParams()->SetOffset( dOffsetAlongZ ); } return( pWindow->objectId() ); } // Inserts profile definition into a database. // Returns Object ID of newly created profile definition. OdDbObjectId add_profile_def( OdDbDatabasePtr pDatabase ) { OdDbObjectId idProfDef = AECDbProfileDef::CreateAECObject( pDatabase, OD_T("Profile Definition Created By Teigha(R) Architecture") ); AECDbProfileDefPtr pProfileDefinition = idProfDef.openObject( OdDb::kForWrite ); AECGe::Profile2D cProfile; cProfile.resize( 2 ); cProfile[ 0 ].appendVertex( OdGePoint2d( 0, 0 ) ); cProfile[ 0 ].appendVertex( OdGePoint2d( 1, 0 ) ); cProfile[ 0 ].appendVertex( OdGePoint2d( 1, 1 ) ); cProfile[ 0 ].appendVertex( OdGePoint2d( 0, 1 ) ); cProfile[ 0 ].setClosed(); // Forces the contour to be counter-clockwise. // So if the contour is already ccw this call is not needed. cProfile[ 0 ].makeCCW(); cProfile[ 1 ].appendVertex( OdGePoint2d( 0.2, 0.2 ) ); cProfile[ 1 ].appendVertex( OdGePoint2d( 0.2, 0.8 ) ); cProfile[ 1 ].appendVertex( OdGePoint2d( 0.8, 0.8 ) ); cProfile[ 1 ].appendVertex( OdGePoint2d( 0.8, 0.2 ) ); cProfile[ 1 ].setClosed(); cProfile[ 1 ].makeCCW( false ); pProfileDefinition->GetProfile()->Init( cProfile ); return( pProfileDefinition->objectId() ); } // Inserts a door style into a database. // Returns Object ID of newly created door style. OdDbObjectId add_door_style( OdDbDatabasePtr pDatabase, const OdDbObjectId& idProfile ) { OdDbObjectId idDoorStyle = AECDbDoorStyle::CreateAECObject( pDatabase, OD_T("Door Style Created By Teigha(R) Architecture") ); AECDbDoorStylePtr pDoorStyle = idDoorStyle.openObject( OdDb::kForWrite ); pDoorStyle->SetDescription( OD_T("Door Style Description") ); pDoorStyle->SetDictRecordDescription( OD_T("Dialog caption") ); pDoorStyle->SetAutoAdjustToWidthOfWall( true ); pDoorStyle->SetFrameWidth( 2 ); pDoorStyle->SetFrameDepth( 5 ); pDoorStyle->SetStopWidth( 2 ); pDoorStyle->SetStopDepth( 3 ); pDoorStyle->SetShapeAndType( AECDefs::esCustom, AECDefs::edtSingle ); pDoorStyle->SetProfile( idProfile ); pDoorStyle->SetGlassThickness( 1 ); AECDisplayManager cDM( pDatabase ); AECDbDispPropsDoorPtr pOverrideModel = AECDbDispPropsDoor::cast( pDoorStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepDoorModel::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverrideModel.isNull() ) { pOverrideModel->GetPanelComp()->SetColor( colorAt( 1 ) ); pOverrideModel->GetFrameComp()->SetColor( colorAt( 2 ) ); pOverrideModel->GetStopComp()->SetColor( colorAt( 3 ) ); pOverrideModel->GetSwingComp()->SetColor( colorAt( 4 ) ); pOverrideModel->GetGlassComp()->SetColor( colorAt( 5 ) ); } AECDbDispPropsDoorPtr pOverridePlan = AECDbDispPropsDoor::cast( pDoorStyle->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepDoorPlan::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverridePlan.isNull() ) { pOverridePlan->GetPanelComp()->SetColor( colorAt( 1 ) ); pOverridePlan->GetFrameComp()->SetColor( colorAt( 2 ) ); pOverridePlan->GetStopComp()->SetColor( colorAt( 3 ) ); pOverridePlan->GetSwingComp()->SetColor( colorAt( 4 ) ); pOverridePlan->GetDirectionComp()->SetColor( colorAt( 5 ) ); } return( pDoorStyle->objectId() ); } // Inserts a door into a database using the specified door style. // If idWall parameter is not null it also attaches the door to the wall. // Returns Object ID of newly created door. OdDbObjectId add_door( OdDbDatabasePtr pDatabase, const OdDbObjectId& idStyle, const OdDbObjectId& idWall, double dOffsetAlongX, double dOffsetAlongZ ) { AECDbDoorPtr pDoor = AECDbDoor::CreateAECObject( pDatabase->getModelSpaceId(), idStyle ); pDoor->SetRise( 10 ); pDoor->SetWidth( 40 ); pDoor->SetHeight( 50 ); pDoor->SetOpenPercent( 20 ); pDoor->SetMeasureTo( AECDefs::eomtOutsideFrame ); pDoor->SetLeaf( 10 ); if ( !idWall.isNull() ) { pDoor->AttachWallAnchor( idWall ); AECDbAnchorEntToCurvePtr pAnchor = pDoor->GetAnchor().openObject( OdDb::kForWrite ); pAnchor->GetXParams()->SetOffset( dOffsetAlongX ); pAnchor->GetZParams()->SetOffset( dOffsetAlongZ ); } return( pDoor->objectId() ); } void add_roof( OdDbDatabasePtr pDatabase ) { AECGe::Profile2D cProfile; cProfile.resize( 1 ); cProfile.front().appendVertex( OdGePoint2d( 0, 0 ) ); cProfile.front().appendVertex( OdGePoint2d( 0, 110 ) ); cProfile.front().appendVertex( OdGePoint2d( 110, 110 ) ); cProfile.front().appendVertex( OdGePoint2d( 110, 0 ), -1 ); cProfile.front().setClosed(); cProfile.front().makeCCW(); AECDbRoofPtr pRoof = AECDbRoof::CreateAECObject( pDatabase->getModelSpaceId() ); // Initialize roof profile. // By default all edges of Roof Profile have single slope of 45 degrees. pRoof->GetProfile()->Init( cProfile ); pRoof->SetThickness( 2 ); //// Manually modify Roof Segments. AECGeRingSubPtr pRoofLoop = pRoof->GetProfile()->GetRingByIndex( 0 ); if ( !pRoofLoop.isNull() ) { OdUInt32 i, iSize = pRoofLoop->GetSegmentCount(); for ( i = 0; i < iSize; i++ ) { AECGeRoofSegmentSubPtr pSeg = pRoofLoop->GetSegments()->GetAt( i ); pSeg->SetFaceCount(1); pSeg->SetFaceHeightByIndex(0, 110); pSeg->SetBaseHeight(0); pSeg->SetOverhang(10.0); pSeg->SetFaceSlopeByIndex(0, OdaPI4); pSeg->SetSegmentCount(10); } } pRoof->setColorIndex( 3 ); } void add_slab( OdDbDatabasePtr pDatabase ) { OdDbObjectId idStyle = AECDbSlabStyle::GetAECObject( pDatabase, OD_T("Slab Style") ); if ( idStyle.isNull() ) { idStyle = AECDbSlabStyle::CreateAECObject( pDatabase, OD_T("Slab Style") ); } AECDbSlabStylePtr pStyle = idStyle.openObject( OdDb::kForWrite ); if ( !pStyle.isNull() ) { pStyle->GetComponents()->Clear(); AECSlabStyleCompPtr pCmp = AECSlabStyleComp::createObject(); pCmp->SetName( OD_T("Base") ); pCmp->GetPosition()->GetThickness()->SetUseBaseValue( false ); pCmp->GetPosition()->GetThickness()->SetBaseValue( 6 ); pCmp->GetPosition()->GetThicknessOffset()->SetUseBaseValue( false ); pCmp->GetPosition()->GetThicknessOffset()->SetBaseValue( - 6 ); pStyle->GetComponents()->Insert( pCmp ); } AECDbSlabPtr pSlab = AECDbSlab::CreateAECObject( pDatabase->getModelSpaceId(), idStyle ); { AECGe::Profile2D cBase; cBase.resize( 1 ); cBase.front().appendVertex( OdGePoint2d( -5, -5 ), 1 ); cBase.front().appendVertex( OdGePoint2d( 115, -5 ) ); cBase.front().appendVertex( OdGePoint2d( 115, 115 ) ); cBase.front().appendVertex( OdGePoint2d( -5, 115 ) ); cBase.front().setClosed(); cBase.front().makeCCW(); pSlab->GetSlabFace()->Init( cBase ); } pSlab->SetThickness( 5 ); pSlab->SetVerticalOffset( 0 ); pSlab->SetHorizontalOffset( 0 ); pSlab->SetPivotPoint( OdGePoint3d::kOrigin ); AECDisplayManager cDM( pDatabase ); AECDbDispPropsSlabPtr pOverrideModel = AECDbDispPropsSlab::cast( pSlab->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepSlabModel::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverrideModel.isNull() ) { pOverrideModel->GetBoundaryCompByIndex( 0 )->SetColor( colorAt( 1 ) ); pOverrideModel->GetBaselineComp()->SetColor( colorAt( 4 ) ); pOverrideModel->GetPivotPointComp()->SetColor( colorAt( 5 ) ); pOverrideModel->GetFasciaComp()->SetColor( colorAt( 6 ) ); pOverrideModel->GetSoffitComp()->SetColor( colorAt( 7 ) ); pOverrideModel->GetShrinkWrapBodyComp()->SetColor( colorAt( 8 ) ); } AECDbDispPropsSlabPlanPtr pOverridePlan = AECDbDispPropsSlabPlan::cast( pSlab->OverrideDispProps( cDM.UpdateDisplayRepresentation( AECDbDispRepSlabPlan::desc() ) ).openObject( OdDb::kForWrite ) ); if ( !pOverridePlan.isNull() ) { pOverridePlan->SetIsOverrideCutPlane( false ); pOverridePlan->GetHatchComp()->SetColor( colorAt( 1 ) ); pOverridePlan->GetBelowCutPlaneBodyComp()->SetColor( colorAt( 2 ) ); pOverridePlan->GetAboveCutPlaneBodyComp()->SetColor( colorAt( 3 ) ); pOverridePlan->GetBelowCutPlaneOutlineComp()->SetColor( colorAt( 4 ) ); pOverridePlan->GetAboveCutPlaneOutlineComp()->SetColor( colorAt( 5 ) ); } } class MyServices : public ExSystemServices, public ExHostAppServices { protected: ODRX_USING_HEAP_OPERATORS(ExSystemServices); }; int wmain(int argc, wchar_t* argv[]) { // Initialize TD with system services. // And create single instance of hostapp services // for TD database creation. OdStaticRxObject<MyServices> svcs; odInitialize( &svcs ); odgsInitialize(); // Loading of all public Teigha Architecture DRX modules. // Note that not all calls are necessary for some of them depend on others // but here we list all of them. // // If a program uses TD doesn't modify or create binary files // it may not load any of DRX modules on start because they will be loaded automatically. // But if a program modifies or creates binary files then it is highly recommended // to load all DRX modules program uses. ::odrxDynamicLinker()->loadApp( OD_T("AecBase") ); ::odrxDynamicLinker()->loadApp( OD_T("AecArchBase") ); ::odrxDynamicLinker()->loadApp( OD_T("AecArchDACHBase") ); ::odrxDynamicLinker()->loadApp( OD_T("AecScheduleData") ); ::odrxDynamicLinker()->loadApp( OD_T("AecSchedule") ); ::odrxDynamicLinker()->loadApp( OD_T("AecStructureBase") ); // Create empty TD database. OdDbDatabasePtr pDatabase = svcs.createDatabase();; // Initialize database with default Teigha Architecture content. AECArchDACHBaseDatabase( pDatabase ).Init(); AECScheduleDatabase( pDatabase ).Init(); AECStructureBaseDatabase( pDatabase ).Init(); init_display_system( pDatabase ); OdDbObjectId idWallStyle = add_wall_style( pDatabase ); OdDbObjectId idWall1 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 0, 0 ), OdGePoint2d( 0, 110 ) ); OdDbObjectId idWall2 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 0, 110 ), OdGePoint2d( 110, 110 ) ); OdDbObjectId idWall3 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 110, 110 ), OdGePoint2d( 110, 0 ) ); OdDbObjectId idWall4 = add_wall( pDatabase, idWallStyle, OdGePoint2d( 110, 0 ), OdGePoint2d( 0, 0 ), -1 ); AECDbWallPtr ptWall = AECDbWall::cast( idWall1.openObject( OdDb::kForRead ) ); OdDbObjectId idWindowStyle = add_window_style( pDatabase ); OdDbObjectId idWindow01 = add_window( pDatabase, idWindowStyle, idWall1, 10, 10 ); OdDbObjectId idWindow02 = add_window( pDatabase, idWindowStyle, idWall1, 60, 10 ); OdDbObjectId idWindow03 = add_window( pDatabase, idWindowStyle, idWall1, 10, 60 ); OdDbObjectId idWindow04 = add_window( pDatabase, idWindowStyle, idWall1, 60, 60 ); OdDbObjectId idWindow05 = add_window( pDatabase, idWindowStyle, idWall2, 10, 10 ); OdDbObjectId idWindow06 = add_window( pDatabase, idWindowStyle, idWall2, 60, 10 ); OdDbObjectId idWindow07 = add_window( pDatabase, idWindowStyle, idWall2, 10, 60 ); OdDbObjectId idWindow08 = add_window( pDatabase, idWindowStyle, idWall2, 60, 60 ); OdDbObjectId idWindow09 = add_window( pDatabase, idWindowStyle, idWall3, 10, 10 ); OdDbObjectId idWindow10 = add_window( pDatabase, idWindowStyle, idWall3, 60, 10 ); OdDbObjectId idWindow11 = add_window( pDatabase, idWindowStyle, idWall3, 10, 60 ); OdDbObjectId idWindow12 = add_window( pDatabase, idWindowStyle, idWall3, 60, 60 ); OdDbObjectId idProfile = add_profile_def( pDatabase ); OdDbObjectId idDoorStyle = add_door_style( pDatabase, idProfile ); AECDbWallPtr pWall = idWall4.openObject( OdDb::kForRead ); double dLength = pWall->GetLength(); double dOWidth = 40; double dL1 = 10; double dL3 = dLength - dOWidth - 10; double dL2 = dL1 + dOWidth + (dL3 - (dL1 + 2 * dOWidth)) / 2; OdDbObjectId idDoor = add_door ( pDatabase, idDoorStyle, idWall4, dL2, 0 ); OdDbObjectId idWindow13 = add_window ( pDatabase, idWindowStyle, idWall4, dL1, 10 ); OdDbObjectId idWindow14 = add_window ( pDatabase, idWindowStyle, idWall4, dL3, 10 ); OdDbObjectId idWindow15 = add_window ( pDatabase, idWindowStyle, idWall4, dL1, 60 ); OdDbObjectId idWindow16 = add_window ( pDatabase, idWindowStyle, idWall4, dL2, 60 ); OdDbObjectId idOpening = add_window ( pDatabase, idWindowStyle, idWall4, dL3, 60 ); add_roof(pDatabase); add_slab(pDatabase); // Perform "zoom extents" on model space. { OdDbViewportTablePtr pVT = pDatabase->getViewportTableId().openObject( OdDb::kForRead ); OdDbViewportTableRecordPtr pV = pVT->getActiveViewportId().openObject( OdDb::kForWrite ); pV->zoomExtents(); } OdWrFileBuf cBuffer( "H:\\TA_test.dwg" ); pDatabase->writeFile( &cBuffer, OdDb::kDwg, OdDb::kDHL_CURRENT ); odgsUninitialize(); odUninitialize(); return 0; }
Source: https://habr.com/ru/post/280284/
All Articles