General Program Information

Basics - Using Numbers in Code

Variables within this section of basics provide numbers for constants within AutoCAD or specify AutoCAD versions. Additionally, this section includes functions which limit the significant figures for numbers used in AutoCAD programs.

acadversion - a variable that is given as an input by the user specifying the version of AutoCAD being utilized. AguaClara lab is currently using AutoCAD 2006.
acadversion := (AutoCAD version year here)

sp - a variable that provides a space in AutoCAD code
sp := " "

zc - a variable representing the zoom constant distance in AutoCAD code.
zc := .01m

zcpoint - a variable representing the zoom constant dimension in AutoCAD code.
zcpoint :=

  • x = 0m
  • y = .1m
  • z = 0m

stringit - a function which takes in a number with units, makes it non-dimensional, and rounds it to 5 significant digits
stringit( x ) :=

  • num2str(round(x/m,5))

stringitnonunits - a function which takes in a number without units and rounds it to 5 significant digits
stringitnonunits( x ) :=

  • num2str(round(x,5))

point - a variable containing numerical coordinates in an array and the units associated with those coordinates. It then converts the array into one line of code where the coordinates are separated by commas (ie. x,y,z where the coordinates are x,y,z are specified by numbers).
point(pointarray) :=

  • temp <-- ""
  • for i of 0..(rows(pointarray) - 1)
    • temp <-- concat(temp,stringit(pointarrayi))
    • temp <-- concat(temp,",") if i < (rows(pointarray) - 1)
  • temp

pointnonunits - a variable containing numerical coordinates in an array without units. It then converts the array into one line of code where the coordinates are separated by numbers.
pointnonunits(pointarray)

  • temp <-- ""
  • for i of 0..(rows(pointarray) - 1)
    • temp <-- concat(temp,stringitnonunits(pointarrayi))
    • temp <-- concat(temp,",") if i < (rows(pointarray) - 1)
  • temp
  • No labels