ObjectARX

ObjectARX

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

Syncronizing attribute references with ObjectARX

581 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: 662
Registered: ‎06-02-2009
Message 2 of 2 (553 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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.