The invention discloses a reflection technology-based CAD model total element scripting method and
system. The method comprises the following steps of: configuring a CAD
secondary development reflection interface; obtaining a CAD type definition, and calling a configured CAD
secondary development reflection interface; determining a target
scripting language according to a
scripting language supported by CAD, and converting the acquired type definition into a code according to grammar of the target
scripting language; the CAD model data are traversed, the generated conversion codes are called according to the
object type, multiple sections of script character strings, head character strings and
tail character strings are combined, and the traversed CAD model data are total element data and comprise geometric features, parameters, rules and attributes; and generating a script file according to the multiple sections of script character strings, the head character string and the
tail character string. According to the method, the CAD
secondary development reflection interface is configured to realize automatic generation of the conversion code based on the reflection technology, so that a large amount of manual coding work is avoided; the generated script file considers non-geometric
feature data and can contain total element information of the CAD model.