这是我第一次尝试
- int MyLine()
- {
- //In the Bricscad SDS od_doc_man.h
- OdApDocManager *pDocMan = odapDocManager();
- OdApDocument* pDoc = pDocMan->curDocument();
- // \/ \/ This is All ODA stuff \/ \/
- //Note: this SDK like to use Smart Pointers
- //Get the Database
- OdDbDatabasePtr pDb = pDoc->database();
-
- //
- if ( pDb.isNull() )
- return (RSERR);
- //make a couple of points
- OdGePoint3d startPt(1.0, 1.0, 0.0);
- OdGePoint3d endPt(10.0, 10.0, 0.0);
- //Get the model space ID
- OdDbObjectId spaceId = pDb->getModelSpaceId();
- //Open the BTR safely :^)
- OdDbBlockTableRecordPtr pBtr = spaceId.safeOpenObject(OdDb::kForWrite);
- //Here we use the static method ::createObject() instead of instantiating the class.
- //I think this will be the norm for creating objects
- OdDbLinePtr pNewLine = OdDbLine::createObject();
- //This sets the defaults such as layer ...
- pNewLine->setDatabaseDefaults(pDb);
- //Make a couple of points
- pNewLine->setStartPoint( startPt );
- pNewLine->setEndPoint( endPt );
- //add the line
- pBtr->appendOdDbEntity(pNewLine);
- //In theory the smart pointers will clean up my mess
- return (RSRSLT);
- }
|