Community
Hi,
I am trying to create a entity object of mline class with RealDWG, but I can not find how to do this. It seems that the API for AcDbMline is too simple, there are no enough fuctions for me to call. Does anybody knows? Thanks!
It's a long time ago, that I did MLInes... and it was in plain AutoCAD. But Maybe this code will help you:
AcDbObjectId retObjId; // Multilinienstil suchen und zuweisen AcDbDictionary *pDict = NULL; AcDbObjectId DictId; DictId = acdbHostApplicationServices()->workingDatabase()->mLStyleDictionaryId(); if ( acdbOpenObject( ( AcDbObject*& )pDict, DictId, AcDb::kForRead ) == Acad::eOk ) { if ( pDict->getAt( (m_pszStyleName), retObjId ) != Acad::eOk ) { ads_printf( MSGR("475\1-\nMultilinienstil nicht in AutoCAD enthalten!") ); pDict->close(); return FALSE; } pDict->close(); } // Multilinie erzeugen AcDbMline *pMultiline; pMultiline = new AcDbMline(); pMultiline->setStyle( retObjId ); Acad::ErrorStatus err; AcGeVector3d v( 0, 0, 1 ); pMultiline->setNormal( v ); pMultiline->setScale( m_dblFactor ); pMultiline->setJustification( (char)m_nJust ); err = pMultiline->setClosedMline( false ); bool bbb = pMultiline->closedMline(); //TEST // Punkte für MLINE über Polyline holen t_polyline *PL = GetPolyline( idObj, GP_NORMAL ); while ( PL != NULL ) { err = pMultiline->appendSeg( AcGePoint3d( PL->p[0], PL->p[1], PL->p[2] ) ); PL = PL->next; } // Get a pointer to a Block Table object. AcDbBlockTable *pBlockTable; acdbHostApplicationServices()->workingDatabase()->getSymbolTable( pBlockTable, AcDb::kForRead ); // Get a pointer to the MODEL_SPACE BlockTableRecord. AcDbBlockTableRecord *pBlockTableRecord; pBlockTable->getAt( ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite ); pBlockTable->close(); // Append the pline object to the database and obtain its object ID. AcDbObjectId pTestObjId; pBlockTableRecord->appendAcDbEntity( pTestObjId, pMultiline ); pBlockTableRecord->close(); pMultiline->setLayer( (sLayer) ); pMultiline->close(); idGrafics = pMultiline->objectId();
I think, most of the stuff will work in RealDWG. The missing API things for the MLine come all through the MLine Style. I believe there is an Api for the MLine Style also.