C # Operations cad-reading and modifying data

Source: Internet
Author: User

The main purpose of our operation of CAD is to read and modify or delete the data, because the content is more, here we first talk about the basis, follow-up slowly explained.

1, the CAD data read and modify before the locking operation to avoid a document is modified by multiple users conflict.

Database db = Hostapplicationservices.workingdatabase;//Current Databaseusing(Transaction tr = db.) Transactionmanager.starttransaction ())//using, automatically calls the Dispose method            {                 //Processing ProcessTr.commit (); //Transaction Commit}

2, we in the process of entering the code we want to operate normally, otherwise it will be an error.

Then we are going to read the graph data, but because there is too much content, it will be updated later, simply attach a code that selects a single entity on the screen.

 Public StaticEntity Select (stringword) {Document doc=Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Database DB= Doc. Database; Editor ed =Doc.            Editor; Entity entity=NULL; Promptentityresult ent=ed.            GetEntity (word); if(Ent. Status = =Promptstatus.ok) {using(Transaction Transaction =db. Transactionmanager.starttransaction ()) {entity= (Entity) transaction. GetObject (ent. ObjectId, Openmode.forwrite,true);                Transaction.commit (); }            }            returnentity; }

3, we read the data is generally multiple, so we have to do the traversal filtering processing.

using  (Transaction trans = db. Transactionmanager.starttransaction ())              {                foreach  (dbobject ob in texts)                  {                     DBText text =  (dbtext) transaction. GetObject (ob. Objectid, openmode.forwrite, true);                    ....... ..................... Operating content                 }                 trans. Commit ();             }

C # Operations cad-reading and modifying data

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.