AutoCAD. NET two-time development (IV)

Source: Internet
Author: User

In CAD, the attribute information is usually in the form of annotation, but when the property data content is more, the display becomes a problem. Extended attributes (Xdata) can solve this problem, such as in the South Cass. We often use Lisp to read operation extended properties.

To view Entity Property information:

(Entget (Car (Entsel)) ' ("*"))

But in order to facilitate our interaction with GIS, we have to. NET to read and modify the extended properties of the entities in the CAD file. This article only explains how to read extended properties.

The first step, however, is to open the file, get the document, select the object, and get the entity. The following code is sure to be used frequently in testing.

[Commandmethod ("GA", commandflags.session)]public void GetAttribute () {//document manager DocumentCollection Acdocmgr = Applica tion.    Documentmanager;    Active document Acdoc = Acdocmgr.mdiactivedocument;    Database Accurdb = acdoc.database; using (Acdoc.lockdocument ()) {//Start transaction using (Transaction Actrans = AcCurDb.TransactionManager.StartTrans            Action ()) {//Request to select objects in the graphics area Promptselectionresult acssprompt = AcDoc.Editor.GetSelection (); If the prompt status OK, indicates that the object is selected if (Acssprompt.status = = Promptstatus.ok) {Selectionse                T acsset = Acssprompt.value; Iterates over objects in the selection set foreach (Selectedobject acssobj in Acsset) {//confirms that the returned is a valid Sele                        Ctedobject object if (acssobj! = null) {//Get entity                  Entity acent = Actrans.getobject (Acssobj.objectid, openmode.forwrite) as Entity;      if (acent! = null) {////////The following is the code that gets the extended property                        ...... } else {messageboxex.show ("The entity is empty!                        "," prompt ");            }}}//Save new object to Database Actrans.commit (); }        }    }}

Here's the code to get the extended properties:

if (acent.xdata! = null) {    string result = "";    autodesk.autocad.databaseservices.typedvalue[] ValueArray = AcEnt.XData.AsArray ();    for (int i = 0; i < valuearray.length; i++)    {        result + = i + "-" + valuearray[i]. TypeCode + "-" + valuearray[i]. Value + "\ n";    }    Console.WriteLine (result);    System.Windows.Forms.MessageBox.Show (result);}

In fact, it is also simple to determine whether the obtained instance has an extended attribute (XData), and if there is a call to its Asarray method, the extended property is converted to the Typedvalue array, consistent with the general data usage. You can then iterate through the extended properties to read them. Where TypeCode is the group code, value is the property value.

Of course, for the user to experience better, we need to put the read properties on the form display.

Attached: Cass Extended Properties

( -3 ("South" (1000. "300000") (1000. "513434101209jc00140") (1000. "Rocheshon") (1000. ""))   ;; Parcels ("QHDM" (1000. "")) ;; Area code ("SJZGBM" (1000). ""))  ;; Superior authority ("FRDBXM" (1000). ""))  ;; Name of the legal representative ("Frdbzms" (1000). ""))  ;; Certificate of legal representative ("FRDBDH" (1000). ""))  ;; Legal representative Telephone ("Dlrxm" (1000. ""))  ;; The name of the agent ("Dlrsfz" (1000). ""))  ;; Agent ID Card ("Dlrdh" (1000. ""))  ;; Agent Phone ("Txdz" (1000). ""))  ;; Mailing Address ("Tdzl" (1000. ""))  ;; The land is situated ("Dongzhi" (1000). ""))  ;; Dongzhi ("Nanzhi" (1000. ""))  ;; South to ("Xizhi" (1000. ""))  ;; West to ("Beizhi" (1000. ""))  ;; North to ("Qslyzm" (1000. ""))  ;; Certificate of Ownership origin ("Pztdyt" (1000). ""))  ;; Approved Land use ("Tdsyz" (1000). ""))  ;; Land owner ("Sbjzwqs" (1000. ""))  ;; Declaration of Ownership of buildings ("Ybdjh" (1000). ""))  ;; Pre-programmed cadastral number ("Tdzh" (1000). ""))  ;; Land License Number ("SHRQ" (1000). ""))  ;; Audit date ("Djrq" (1000. ""))  ;; Date of registration ("ZZRQ" (1000. ""))  ;; Termination date ("Dwxz" (1000). ""))  ;; Unit Nature ("Qsxz" (1000. ""))  ;; The nature of ownership ("SYQLX" (1000). ""))  ;; The Use Rights type ("TDDJ" (1000). ""))   ;; Land rank ("MPH" (1000). ""))   ;; Number ("Tufu" (1000. "3163.13-548.63")); Picture of the map ("JZMJ" (1040.177.157));; Area("Bddj" (1040.0.0)); Nominal premium ("SBDJ" (1040.0.0)); Declared premium)

  

AutoCAD. NET two-time development (IV)

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.