Table of Contents

CadUnits

from OpenCAD2D import CadUnits

class CadUnits(System.Object) ยท CadUnits in the .NET reference

Lengths and angles written and read as AutoCAD writes and reads them in a drawing's units: LUNITS 1 scientific, 2 decimal, 3 engineering, 4 architectural, 5 fractional, to LUPREC places (a denominator of 2 to the LUPREC in 4 and 5); AUNITS 0 decimal degrees, 1 degrees, minutes and seconds, 2 grads, 3 radians, 4 surveyor's units, to AUPREC places. 15.5 is 1.55E+01, 15.50, 1'-3.50", 1'-3 1/2" and 15 1/2; 45 degrees is 45.0000, 45d0'0", 50.0000g, 0.7854r and N 45d0'0" E, as the examples of -UNITS give them.

Methods

Angle

.NET

@staticmethod
def Angle(radians: float, aunits: int, auprec: int) -> str

Writes an angle in a drawing's units, as AutoCAD's ANGTOS: measured from east, counter-clockwise.

FromDirection

.NET

@staticmethod
def FromDirection(direction: float, angbase: float, clockwise: bool) -> float

Turns a direction into the angle the drawing counts for it, the reverse of CadUnits.ToDirection, as AutoCAD's ANGTOS: from ANGBASE, clockwise where ANGDIR is 1, from nought up to a whole turn. With ANGBASE at north and ANGDIR clockwise, east is 90 degrees and north is nought.

Length

.NET

@staticmethod
def Length(value: float, lunits: int, luprec: int) -> str

Writes a length in a drawing's units, as AutoCAD's RTOS.

ToDirection

.NET

@staticmethod
def ToDirection(counted: float, angbase: float, clockwise: bool) -> float

Turns an angle typed, counted as the drawing counts angles, into the direction it names: from the base direction ANGBASE, clockwise where ANGDIR is 1. With ANGBASE at north and ANGDIR clockwise, as a surveyor counts, 30 is the direction 60 degrees counter-clockwise from east.

TryAngle

.NET

@staticmethod
def TryAngle(text: str, aunits: int) -> tuple[bool, float]

Reads an angle typed in a drawing's units, as AutoCAD reads one: a number in the units of AUNITS (degrees, grads or radians), or with its own mark, 45d30'15", 50g, 0.7854r, or a bearing, N 45d E.

TryAngles

.NET

@staticmethod
def TryAngles(text: str, aunits: int) -> tuple[bool, System.Array[float]]

Reads a list of angles as AutoCAD's POLARADDANG takes one: up to ten angles parted by semicolons, each read as CadUnits.TryAngle reads one and turned into a direction from nought up to a whole turn, in the order typed; empty for none. A part left empty or with a space about it, an eleventh angle, or a comma between two is refused: "-10;400;45d" reads as 350, 40 and 45 degrees, and "10;;20", "10,20" and "15 ; 25" do not read.

TryLength

.NET

@staticmethod
def TryLength(text: str, lunits: int) -> tuple[bool, float]

Reads a length typed in a drawing's units: a number as ever, and in engineering and architectural units feet and inches as AutoCAD reads them, 1'3", 1'-3-1/2" or 3-1/2"; in architectural and fractional units a fraction, 15-1/2.