Giter Club home page Giter Club logo

dxf-builder's Introduction

dxf-builder

A python package to build DXF files from dict input

Usage

from dxf_builder import DxfBuilder

# Export the document into a file

DxfBuilder([
    {
        "type": "lines",
        "xy_data": {
            ...
        },
        "hatch": False
    }    
]).saveas("multiple_shapes.dxf")

# or

DxfBuilder({
        "type": "lines",
        "xy_data": {
            ...
        },
        "hatch": False
    }).saveas("single_shape.dxf")


# Get an access to the document instance

doc: ezdxf.document.Drawing
doc = DxfBuilder({...}).get_doc()

Supported shape samples:

  • Polyline path
{
    "type": "lines",
    "xy_data": {
        "coordinate_1": (10, 0),
        "coordinate_2": (10, 10),
        "coordinate_3": (20, 10),
        "coordinate_4": (30, 10),
    },
    "shape_specific_data": {
        "color": 2,
    },
    "hatch": True or False
}
  • Arc
{
    "type": "arc",
    "xy_data": {
        "xy": (-40, 0),  # Centre of the ellipse
    },
    "shape_specific_data": {
        "radius": 25,
        "angle": 360,  # Rotation of the ellipse in degrees (counterclockwise).
    },
    "hatch": True or False
}
  • Mesh
{
    "type": "mesh",
    "xy_data": {
        "vertex_1": (0, 0, 0),
        "vertex_2": (1, 0, 0),
        "vertex_3": (1, 1, 0),
        "vertex_4": (0, 1, 0),
        "vertex_5": (0, 0, 1),
        "vertex_6": (1, 0, 1),
        "vertex_7": (1, 1, 1),
        "vertex_8": (0, 1, 1),
    },
    "shape_specific_data": {
        "faces": [
            [0, 1, 2, 3],
            [4, 5, 6, 7],
            [0, 1, 5, 4],
            [1, 2, 6, 5],
            [3, 2, 6, 7],
            [0, 3, 7, 4],
        ]
    }
}
  • Rectangle
{
    "type": "rectangle",
    "xy_data": {
        "coordinate_1": (0, 0),
        "coordinate_2": (10, 0),
        "coordinate_3": (10, 10),
        "coordinate_4": (0, 10),
    },
    "shape_specific_data": {
        "is_closed": True,  # default
        "pattern_name": "ANSI31",
        "color": 7  # default
    }
}

dxf-builder's People

Contributors

dvngn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.