CAD write about global dictionary extended recording operation (com Interface Web version)

User-defined global data, by extending the recording mode is written in FIG DWG

Code below, to a sheet take global dictionary, then put a user's own dictionary in the dictionary, write an extended data recorded in the dictionary

Js code as follows:

function wirteGlobalVer (sName, sVal) { 
 
    // get the CAD database 
    var Database = mxOcx.GetDatabase ();
     // get a global dictionary 
    var dict = database.GetNamedObjectsDictionary ();
     // get a user-defined dictionary, MyExDataDictName a dictionary name 
    var myDict dict.GetAt = ( "MyExDataDictName" );
     IF (myDict == null ) 
    { 
        // if not, add a dictionary. 
        = dict.AddObject myDict ( "MyExDataDictName", "McDbDictionary" ); 
    } 
    // expanded recording data dictionary. 
 
 
    var REC = myDict.GetAt (sName);
     IF (REC ==null ) 
    { 
        // . if not, add an extension record 
        REC = myDict.AddXRecord (sName); 
    } 
    // Create a data list. 
    var RES = mxOcx.NewResbuf ();
     // set value. 
    res.AddString (sVal);
     // set extended recording data. 
    rec.SetXRecordData (RES); 
     
}

carried out

wirteGlobalVer ( "MyData", "aaaa" ); 
 Alert ( "successfully written");

DWG data contents as follows:

dict2.png

Guess you like

Origin www.cnblogs.com/yzy0224/p/12010933.html