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.
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