Adding Fields to a Table

AutoCAD Map 3D AutoLISP

Up a level
Adding Fields to a Table
 
 

The following sample adds one field of each data type to an existing table.

; Define new fields
(setq newfields 
    '("columns" 
         ; Define a character field 
         (("colname" . "NEWFIELD1") 
          ("coldesc" . "New Field 1 Description")  
          ("coltype" . "character") 
          ("defaultval" . "Default Value")) 
         ; Define an integer field 
         (("colname" . "NEWFIELD2")
          ("coldesc" . "New Field 2 Description") 
          ("coltype" . "integer") 
          ("defaultval" . 1)) 
         ; Define a point field 
         (("colname" . "NEWFIELD3")
          ("coldesc" . "New Field 3 Description") 
          ("coltype" . "point") 
          ("defaultval" . "4.426217, 7.991379, 1.726213")) 
         ; Define a real field 
         (("colname" . "NEWFIELD4")
          ("coldesc" . "New Field 4 Description") 
          ("coltype" . "real") 
          ("defaultval" . 1.2345)) ) ) 
; Add new fields to existing table
(ade_odaddfield "OLDTABLE" newfields);