Test document Lock: Doc. LockDocument ()

Source: Internet
Author: User

/// <summary>        ///Summary: When using Documentmanager.open (FilePath), lock document Lock is required if it is forwrite. /// </summary>[Commandmethod ("T38")]//Test Document Lock         Public voidT38 () {//Document doc = Application.DocumentManager.MdiActiveDocument; //if it is mdiactivedocument, you do not need to lock lockdocument. Document doc = MyTool.MyTools.OpenDwgFile (@"E:\RES\AUTOCAD\TEST.DWG"); Database DB=Doc.            Database; //Database db = new database (); //db.  Readdwgfile (@ "E:\RES\AUTOCAD\TEST.DWG", FileShare.Read, true, null); //this way open the db, do not want to lock.             using(Doc. LockDocument ())//if not locked here, Forwrite mode will be error, but Forread mode does not error. But if it's mdiactivedocument, it doesn't need a lock.             using(Transaction trans =db. Transactionmanager.starttransaction ()) {blocktable BT= db. Blocktableid.getobject (Openmode.forread) asblocktable; Blocktablerecord Modelspace= Bt[blocktablerecord.modelspace]. GetObject (Openmode.forwrite) asBlocktablerecord; /*ObjectId brefid = objectid.null; foreach (ObjectId ID in modelspace) {if (ID.                    GetObject (Openmode.forread) is blockreference) {brefid = ID;                } break;                } blockreference bref = Brefid.getobject (openmode.forwrite) as blockreference;                 Bref.downgradeopen (); * */            }        }

Personal summary, seemingly wrong, pending further study. ,。。

Test document Lock: Doc. LockDocument ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.