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

The MLeader object I created does not have an arrow

2 REPLIES 2
Reply
Message 1 of 3
zhengyunyang2019
230 Views, 2 Replies

The MLeader object I created does not have an arrow

I created a block reference, established a AcDbMLeaderStyle, and then created an MLeader based on this style with the content being a block. However, it doesn't display an arrow.

 

This is the code for creating an AcDbMLeaderStyle.

void InitMleaderStyle()
{
  AcDbMLeaderStyle* pMleaderStyle = new AcDbMLeaderStyle();
  pMleaderStyle->setName(mLeaderStyleName);
  pMleaderStyle->setContentType(AcDbMLeaderStyle::ContentType::kBlockContent);
  pMleaderStyle->setBlockConnectionType(AcDbMLeaderStyle::BlockConnectionType::kConnectBase);
  pMleaderStyle->setArrowSize(2.0);
  pMleaderStyle->setAnnotative(false);
  pMleaderStyle->setLeaderLineType(AcDbMLeaderStyle::LeaderType::kStraightLeader);
  AcDbObjectId mNWHMLeaderStyleId;
  Acad::ErrorStatus es = pMleaderStyle->postMLeaderStyleToDb(acdbCurDwg(), mLeaderStyleName, mNWHMLeaderStyleId);
  if (es != ErrorStatus::eOk && es != ErrorStatus::eDuplicateKey)
    acedAlert(L"\nERROR。"); 

  pMleaderStyle->close();
}

 

 

This is the code for creating an MLeader.

AcDbObjectId oBlock;
CreateTextTriangle(oBlock);

AcDbObjectId oTextStyleId;
GetMleaderStyle(oTextStyleId);

opEntity = new AcDbMLeader();
opEntity->setMLeaderStyle(textStyleId);
opEntity->setBlockContentId(oBlock);

int leaderIndex;
opEntity->addLeader(leaderIndex);
opEntity->addLeaderLine(iPoint, leaderIndex);
opEntity->addFirstVertex(leaderIndex, iPoint); 
opEntity->setFirstVertex(leaderIndex, iPoint); 

AcGePoint3d ENDPoint(iPoint);
secPoint.x += 5;
secPoint.y -= 2;
opEntity->setLastVertex(leaderIndex, ENDPoint); 

AcDbBlockTable *pBlockTable;
Acad::ErrorStatus resBlockT = acdbCurDwg()->getSymbolTable(pBlockTable, AcDb::kForWrite);
if ( Acad::eOk != resBlockT)
{
  acedAlert(L"\nERROR");
  return ;
}

AcDbBlockTableRecord* pModelSpace;
Acad::ErrorStatus resGetAt = pBlockTable->getAt(ACDB_MODEL_SPACE,pModelSpace, AcDb::kForWrite);
if (Acad::eOk != resGetAt)
{
  pBlockTable->close();
  acedAlert(L"\nERROR");
  return ;
}

if (pModelSpace->appendAcDbEntity(oEntityId, opEntity) != Acad::eOk)
  acedAlert(L"\nERROR");

opEntity->close();
pModelSpace->close();
pBlockTable->close();
2 REPLIES 2
Message 2 of 3
ynapeu
in reply to: zhengyunyang2019

Hello

i think you should use

 opEntity->addLeader(&leaderIndex); 

Message 3 of 3
tbrammer
in reply to: zhengyunyang2019

I think it should be like this:

//opEntity->addFirstVertex(leaderIndex, iPoint);
opEntity->setFirstVertex(leaderIndex, iPoint); 
opEntity->addLastVertex(leaderIndex, ENDPoint); 

Also you should use the method

es = pMLeader->postMLeaderToDb(pDB);

to post the leader to the database.

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

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

Post to forums  

Autodesk Design & Make Report

”Boost