.NET

Reply
Mentor
bsee1
Posts: 211
Registered: ‎11-14-2011
Message 1 of 5 (191 Views)

Attribute alignment never updates

191 Views, 4 Replies
09-10-2013 09:00 AM

In Autocad I'm programmatically settign the alignment of an attribute to MiddleCenter.  Looking at the attribute I can see that the alignment is set properly.  However, the alignment does visually update itself.  

 

I'm able to manually update the allignment if I open the Enhanced Attribute Editor and make any change.  If any property is updated, the attribute "realizes" it needs to update the alignment.

 

How can I make AutoCAD automatically update the alignment?  Here is a current snippet of my code.  In this particular instance "result" will contain 004 as a string:

 

attribute.TextString = result 

attribute.Alignment = AcAlignment.acAlignmentMiddleCenter
attribute.Update()

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 5 (186 Views)

Re: Attribute alignment never updates

09-10-2013 09:16 AM in reply to: bsee1
After setting an alignment try this way:
attref.AdjustAlignment(db)
attref.RecordGraphicsModified(true)
bref.RecordGraphicsModified(true)
where 'bref' is block reference, 'db' is Database
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Mentor
bsee1
Posts: 211
Registered: ‎11-14-2011
Message 3 of 5 (161 Views)

Re: Attribute alignment never updates

09-10-2013 12:25 PM in reply to: Hallex

Which attribute object has the RecordGraphicsModified function?  Currently I'm using the Autodesk.AutoCAD.Interop.Common.AcadAttributeReference object, but it doesn't seem to contain the function RecordGraphicsModified().

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1
Valued Mentor
gasty1001
Posts: 450
Registered: ‎04-11-2010
Message 4 of 5 (153 Views)

Re: Attribute alignment never updates

09-10-2013 01:04 PM in reply to: bsee1

Hi,

 

There is no RecordGraphicsModified in Interop. As for the problem, may be a call to Attsync do the trick.

 

Gaston Nunez

Mentor
bsee1
Posts: 211
Registered: ‎11-14-2011
Message 5 of 5 (123 Views)

Re: Attribute alignment never updates

09-11-2013 10:15 AM in reply to: gasty1001

Found a solution for interop.  I had programmatically just opened another sheet in the background, retrieved info, then closed it before adding text to this attribute.  That seems to have caused my issue.  By setting the current sheet to active again the text was inserted with the proper alignment.

*****************************
Win7 x64 - 16gb ram
i7 3610qm
FirePro M4000

Inventor 2013
ETO 6.1

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community