ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to create mline with RealDWG?

1 REPLY 1
Reply
Message 1 of 2
alanchen123
398 Views, 1 Reply

How to create mline with RealDWG?

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!

Tags (2)
1 REPLY 1
Message 2 of 2
Matti72
in reply to: alanchen123

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost