Hello,
i have the following issue. I created a block. Every instance of this block has a set of data, that is to big for using XData so i decided to make a custom Entity. First I tried extending AcDbBlockReference but since my block has an attribute I had to learn that I can't append attributes to a class deriving from AcDbBlockReference. So my next try was to nest a AcDbBlockReference in a Class deriving from AcDbEntity (I am calling the worldDraw of my nested BlockReference inside of my subworlddraw to draw it). That worked fine until I tried to change the appearance of the attribute.
What I need to do is depending of the angle (rotation) that I am inserting the block with, I need to rotate the attribute. I managed to do that by setting the alignmentPoint to the PositionPoint, chaning the alignment to topright instead of bottomleft and setting the rotation of the TextAttribute to 180 degrees more than the rotation of the inserted block.
That works fine when I am adding just the BlockReference I created to the ModelSpace. But when I try to add my custom object to the ModelSpace, that has the BlockReference nested inside of it, it does'nt work anymore. The rotation of the attribute is updated but not the alignment and changes to the alignementPoint.
I think I may be missing a method override of BlockReference for my custom class, but I can't figure out what it could be. Maybe one of you have already had a simular problem and can help me?
I also tried to extend AcDbBlockReference instead of AcDbEntity and still nest my BlockReference Object inside of this class to support the attributes. And when I am setting the nested BlockReference pointer I tried to set the important values to the deriving class like so:
void setBlockRef(AcDbBlockReference * pBlockRef) {
m_pBlockRef = pBlockRef;
setRotation(m_pBlockRef->rotation());
setBlockTableRecord(m_pBlockRef->blockTableRecord());
setBlockTransform(m_pBlockRef->blockTransform());
setNormal(m_pBlockRef->normal());
setPosition(m_pBlockRef->position());
}
But it still doesn't work.
I'm using Visual Studio 2012, AutoCAD 2016, ObjectARX 2016, Windows 7 64bit.
Solved! Go to Solution.
Solved by christineweiss86. Go to Solution.
Thank you for your reply bernd.
Unfortunately this doesn't work for me because I just want the attribute text to be changed while the blockreference stays as it is.
Also the rotation of the attribute is working fine but so isn't the alignment and the changes to the alignmentPoint.
I attached a picture to make this clear.
1 is what I got
2 is what I want (and get using the AcDbBlockReference)
3 is what I get when using my custom entity
Hello again.
I tried googleing for the 100th time and this time I managed to find the solution to my problem on the site below:
http://adndevblog.typepad.com/autocad/2012/06/updating-text-alignment-.html
You need to call the following method on your AcDbAttribute object (or your TextObject if you have the problem with this one) before inserting it to the database.
adjustAlignment(acdbHostApplicationServices()->workingDatabase());
Or with any other database that you want to add your text to.
That worked for me and finally the Alignment change is shown corretly in my dwg.