Пример #1
0
def get_dxf_doc_from_upload_data(data: bytes) -> 'Drawing':
    """
    This function turns the DXF data provided by Dash Plotly upload component into an `ezdxf` DXF document.
    Dash plotly upload component only provides base 64 encoded data.

    Args:
        data: DXF document uploaded as base64 encoded data

    Returns:
        DXF document as Drawing() object

    """
    # Remove the mime-type and encoding info from data
    # example: data:application/octet-stream;base64,OTk5DQpkeGZydyAwLjYuMw0KICAwDQpTRUNUSU9ODQogIDINCkhFQURFUg0KICA...
    _, data = data.split(b',')
    return ezdxf.decode_base64(data)
Пример #2
0
def test_base64_encoding_r2000(dwg_r2000):
    data = dwg_r2000.encode_base64()
    doc = decode_base64(data)
    assert doc.acad_release == "R2000"
Пример #3
0
def test_base64_encoding_r12(dwg_r12):
    data = dwg_r12.encode_base64()
    doc = decode_base64(data)
    assert doc.acad_release == "R12"
Пример #4
0
def open_camo_file(camo_file):
    with open(camo_file, 'rb') as file:
        camo_file = pickle.load(file)
        camo_file.dxf_doc = ezdxf.decode_base64(camo_file.dxf_doc_encoded)
        del camo_file.dxf_doc_encoded
        return camo_file