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

MText Leader Display Problems

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Kyudos
507 Views, 7 Replies

MText Leader Display Problems

In Autocad 2016 I'm creating an AcDbMLeader in code, setting the background fill and background colour of the AcDbMText. However the background fill doesn't display until I go through the text editor "Background mask..." dialog and "Ok" it (even though the options are correctly set). It displays correctly once I've done this, but no amount of REGENing will make the background mask show up otherwise.

 

Any idea how to make the fill show up?

 

Also, if I use the text editor, the leader moves when I exit the editor, how do I prevent this?

 

 

 

7 REPLIES 7
Message 2 of 8
tbrammer
in reply to: Kyudos

AcDbMLeader has an own method to post the leader to the Database:

   Acad::ErrorStatus AcDbMLeader::postMLeaderToDb(AcDbDatabase* pDb);

Do you use this method to add the leader to the modelspace?


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

Message 3 of 8
Kyudos
in reply to: tbrammer

I wasn't aware of that - I'm using:

 

es = pApp->GetTableRecord()->appendAcDbEntity(leadId, pLeader);
es = acdbTransactionManager->addNewlyCreatedDBRObject(pLeader);

because I want the AcDbObjectId of the leader (so I can position it correctly).

 

I tried:

 

AcDbDatabase* pDb = pApp->GetCurrentAcDb();
es = pLeader->postMLeaderToDb(pDb);

but that returns es = eWasOpenForWrite. Why would that happen?

Message 4 of 8
tbrammer
in reply to: Kyudos

Was pLeader already added to the database when you called pLeader->postMLeaderToDb(pDb)? It shouldn't.

Do you have the model space blocktable record opened for write at this point? I suppose that pLeader->postMLeaderToDb(pDb) tries to open it for write internally which will fail if you have already opened it for write. It looks like your pApp->GetTableRecord() returns the write enabled model space BTR.

 

By the way: You can get the AcDbObjectId of every AcDbObject *pObj using  pObj->objectId(). So you can simply call  pLeader->objectId()

after pLeader->postMLeaderToDb(pDb).

 


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

Message 5 of 8
Kyudos
in reply to: tbrammer

You are right about the write enabled BTR. My method works in all respects, except for displaying the background mask. It's almost like the API is incomplete - there doesn't appear to be a way to turn on an MText frame in code for example (except when it's part of an MLeader).

 

I haven't added the leader to the database at 'post'time - but I am inside some nested transactions. For convenience, I open my current BTR in my start transaction wrapper and close in in the end transaction wrapper. If it is the transactions causing the 'open for write' I don't know if I could unwind them to try it without transactions.

Message 6 of 8
Kyudos
in reply to: tbrammer

I tried this in a separate piece of test code and postMLeaderToDb doesn't seem to make any difference. I think its just broken.

Message 7 of 8
Kyudos
in reply to: Kyudos

It seems you can do this via AutoLISP:

 

http://www.lee-mac.com/mask.html

 

Is there anyway to replicate that in ObjectARx?

Message 8 of 8
Kyudos
in reply to: Kyudos

I found the answer by accident.

 

You need to set the text of the Mtext (setContents) before you turn on the background (setBackgroundFill).

 

ACAD guys - it would be handy if the documentation pointed this out, or it was in some way indicated by an error status.

Even if it was called 'createBackgroundFill' that would have given me a hint!

 

it also seems that calling setBackgroundFillColor or setBackgroundScaleFactor overrides setBackgroundFill, turning the fill on - again undocumented.

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

Post to forums  

Autodesk Design & Make Report

”Boost