|
How to create an Mline using ObjectARX?
问题:
How do I create an MLINE entity in AutoCAD using ObjectARX? When I try this, an
MLINE is not created and an error message does not occur indicating this was
unsuccessful.
解答:
The most likely cause for this is that you did not set the MLINE style to the
MLINE entity as it was created.
If an MLINE style is not set, AutoCAD does not know how to visually represent
the MLINE despite the fact that the MLine entity is valid and is appended to the
DWG database.
The following code creates an MLINE using the "Standard" MLINE style that is
always present in any DWG database.
NOTE: You can also create another MLINE style using the AcDbMlineStyle ARX
class.
普通浏览复制代码
AcDbMline *l =new AcDbMline ;
l->setNormal (AcGeVector3d (0, 0, 1)) ;
l->setScale (1.5) ;
AcDbDictionary *d ;
acdbHostApplicationServices ()->workingDatabase ()
->getNamedObjectsDictionary (d, AcDb::kForRead) ;
AcDbDictionary *ls ;
d->getAt ("ACAD_MLINESTYLE", (AcDbObject*&)ls, AcDb::kForRead) ;
d->close () ;
AcDbObjectId id ;
ls->getAt ("Standard", id) ;
ls->close () ;
l->setStyle (id) ;
l->appendSeg (AcGePoint3d (0, 0, 0)) ;
l->appendSeg (AcGePoint3d (10, 0, 0)) ;
l->appendSeg (AcGePoint3d (10, 10, 0)) ;
l->appendSeg (AcGePoint3d (20, 20, 0)) ;
l->appendSeg (AcGePoint3d (20, 100, 0)) ;
// Now, the AcDbMline entity is ready to be appended to the DWG database |
|