ObjectARX

ObjectARX

Reply
New Member
axelgenus
Posts: 2
Registered: ‎01-17-2012
Message 1 of 2 (545 Views)

Syncronizing attribute references with ObjectARX

545 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,

Alessandro.

ADN Support Specialist
philippe.leefsma
Posts: 632
Registered: ‎06-02-2009
Message 2 of 2 (517 Views)

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:

 

[CommandMethod("AttsyncCmd")]

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);

[CommandMethod("acedCommand3")]
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++).

 

Regards,

Philippe.

 

Philippe Leefsma
Developer Consultant
Developer Technical Services
Global Subscription & Support

  

Autodesk EMEA

 

www.autodesk.com/joinadn



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

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 or visit the Installation and Licensing Forum to get help installing your software.