New Member
2 Posts
0 Kudos
Registered: ‎01-17-2012
Post 1 of 2

Syncronizing attribute references with ObjectARX

586 Views, 1 Replies
01-17-2012 09:09 AM

Hi guys,

I wrote a C# program with ObjectARX which modifies some attribute definition inside two static blocks (height and position). How can I now sync the block/attribute references according to the new definitions (as issuing "ATTSYNC N *") ?


I tried using SendStringToExecute but it's an async method: the program saves and closes the document before the command could be completed.


Thank you,


ADN Support Specialist
687 Posts
80 Kudos
Registered: ‎06-02-2009
Post 2 of 2

Re: Syncronizing attribute references with ObjectARX

01-31-2012 02:49 AM in reply to: axelgenus

Hi Alessandro,


Unfortunately there is no direct method do repeat ATTSYNC command. To achieve the same result, you can try the following steps: (1) open the block definition and block reference, (2) iterate though attribute references on block reference and find the appropriate attribute definition (using TAG as a search criteria), (3) use the setAttributeFromBlock to copy the new attribute.

Another option is to send ATTSYNC command:



static public void AttsyncCmd()


    Document doc = Application.DocumentManager.MdiActiveDocument;

    Database db = doc.Database;

    Editor ed = doc.Editor;


    string bName = "blk1";


    string command = "_ATTSYNC Name " + bName + "\n";


    doc.SendStringToExecute(command, true, false, false);



If you are doing that inside a save & close operation, then yes it will not work. You need to P/Invoke a synchronous method such as "acedCommand". Here is an example:


[DllImport("acad.exe", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl, EntryPoint = "acedCommand")]
private static extern int acedCommand(int type, __arglist);

public void acedCommand3()
    double rad = 2.5;

    double[] center = new double[3] { 0, 0, 0 };

    acedCommand(5005, __arglist("_.CIRCLE", 5009, center, 5001, rad, 5000));



Note for next time: you may want to post C#/VB.Net questions to the .Net section rather than ObjectARX (reserved for C++).





Philippe Leefsma
Developer Consultant
Developer Technical Services
Global Subscription & Support


Autodesk EMEA



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!