I'm using a slightly modified version of Gile's Brute Force AttSync code from here. The reason it's modified is in that post but this is a different issue.
It works a treat in the current drawing but it seems to move the attributes in blocks in XRefs.
The attribute in the block is justified middle centre but after running the AttSync, the attribute seems to "forget" that it's justified and moves the text to the location of the attribute in the definition.
It's weird because if you edit the XRef in place, it snaps back to the correct place but then snaps back to being wrong when the XRef is closed without saving.
I'm attaching a sample project and a couple of drawings to show what's going on.
There are a couple of commands in the project showing the two different approaches I've tried. I've also tried all kinds of other ways to get it to refresh itself but the only thing that seems to correct it is if i programmatically set the value of the attribute to its current value; I can't do that on a drawing with hundreds of blocks though.
This is in ACAD 2018 but I believe it's the same in 17.
Any advice would be greatly appreciated.
Thanks
Paul
Solved! Go to Solution.
Solved by Virupaksha_aithal. Go to Solution.
Hi,
try making the editing database as working database.
private void SyncAttsInDB(Database db) { Database workingDb = HostApplicationServices.WorkingDatabase; try { HostApplicationServices.WorkingDatabase = db; using (Transaction trans = db.TransactionManager.StartTransaction()) { BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead); foreach (ObjectId id in bt.Cast<ObjectId>().ToList()) { BlockTableRecord btr = (BlockTableRecord)trans.GetObject(id, OpenMode.ForRead); if (btr.IsLayout || btr.IsFromExternalReference || btr.GetBlockReferenceIds(true, true).Count == 0) { continue; } using (Transaction innerTrans = db.TransactionManager.StartTransaction()) { btr.UpgradeOpen(); btr.SynchronizeAttributes(); innerTrans.Commit(); } } trans.Commit(); } } catch { } finally { HostApplicationServices.WorkingDatabase = workingDb; } }
Thanks Virupaksha,
That's about the only thing I didn't try.
That's fixed it.
Can't find what you're looking for? Ask the community or share your knowledge.