Table of Contents

CadDrawingJson

from OpenCAD2D import CadDrawingJson

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

A drawing written as JSON for a program that learns from drawings or reads them: every entity walked down to its shapes (see CadFlatten) with its handle, kind, layer, colour, linetype, box, words and geometry in world millimetres, beside the tables of layers, styles, linetypes and blocks. The document is described by a JSON Schema, CadDrawingJson.Schema, and carries "schema": "opencad2d.drawing" and "version": 1.

Properties and fields

Version

.NET

Version: ClassVar[int]

The version of the document this class writes; the schema's version is this number.

Schema

.NET

Schema: ClassVar[str]

Gets the JSON Schema (draft 2020-12) of the document CadDrawingJson.Write gives: the common fields of an entity, the fields of each kind, the tables and the report. It is the file docs/schemas/opencad2d-drawing-v1.schema.json of the repository, built into this assembly.

Methods

Write

.NET

@staticmethod
def Write(document: CadDocument, layout: str) -> str

Writes the drawing as a JSON document: schema, version, name, units, layouts, layers, textStyles, dimStyles, linetypes, blocks, report and entities. A drawing of one LINE from (0, 0) to (100, 0) in millimetres gives an entity {"handle":"2A","kind":"LINE","layer":"0",...,"start":[0,0],"end":[100,0]}.

@staticmethod
def Write(flat: CadFlatDrawing, document: CadDocument) -> str

Writes a drawing already walked, as CadDrawingJson.Write does; for a caller that also builds the graph of the same walk (CadDrawingGraph) and walks once.