AcDbObjectId CArxHelper::CreateMLeader(const CString& strText, const AcGePoint3d& ptArrow, const AcGePoint3d& ptBase, const AcGeVector3d& vectDir) { AcDbObjectId leaderId = AcDbObjectId::kNull; AcDbMText* pMText = new AcDbMText(); pMText->setContents(strText); pMText->setColorIndex(4); AcDbExtents extents; pMText->getGeomExtents(extents); AcDbMLeader *pEnt=new AcDbMLeader(); int i = 0; pEnt->setContentType(AcDbMLeaderStyle::kMTextContent); pEnt->addLeader(i); pEnt->addLeaderLine(ptArrow,i); pEnt->addLastVertex(i,ptBase); pEnt->setDoglegLength(1); pEnt->setDoglegDirection(i,vectDir); pEnt->setArrowSize(0.001); pEnt->setTextAttachmentType(AcDbMLeaderStyle::kAttachmentBottomLine,AcDbMLeaderStyle::kLeftLeader); pEnt->setTextAttachmentType(AcDbMLeaderStyle::kAttachmentBottomLine,AcDbMLeaderStyle::kRightLeader); pEnt->setTextAlignmentType(AcDbMLeaderStyle::kLeftAlignment); pEnt->setMText(pMText); AcGePoint3d pt = ptBase+vectDir*(extents.maxPoint().x-extents.minPoint().x)*1.1+AcGeVector3d::kYAxis*(extents.maxPoint().y-extents.minPoint().y)*1.1; pEnt->setTextLocation(pt); leaderId = AddToCAD(pEnt); return leaderId; }
AcDbObjectId CArxHelper::CreateText(const CString& strText, const AcGePoint3d& pt1, const AcGePoint3d& pt2, double dDist, BOOL bUp /* = TRUE */) { AcDbObjectId textId = AcDbObjectId::kNull; AcGePoint3d pt = (pt1 + pt2.asVector()) / 2.0; AcDbMText* pMText = new AcDbMText(); pMText->setContents(strText); pMText->setLocation(pt); pMText->setDirection(pt2-pt1); textId = AddToCAD(pMText,4); AcDbExtents extents; pMText->getGeomExtents(extents); AcGeVector3d vect = (pt2-pt1).normal() * (extents.maxPoint().x - extents.minPoint().x) / 2.0; AcGeMatrix3d xform = AcGeMatrix3d::translation(-vect); acdbOpenObject(pMText,textId,AcDb::kForWrite); pMText->transformBy(xform); pMText->close(); return textId; }