Skip to content

Howto sideload remote DXF/DWG from URL #131

Answered by gswifort
schoeller asked this question in Q&A
Discussion options

You must be logged in to vote

For now there seems to be no other option than saving to a temporary file. However, you need to use the Db.dxfIn(dxf_file) or Db.readDwgFile(dwg_file) method.

import tempfile
import traceback
from pathlib import Path

import requests
from pyrx_imp import Db


def PyRxCmd_doit():
    try:
        main()
    except Exception:
        traceback.print_exc()


def main():
    target_url = "https://download.autodesk.com/us/samplefiles/acad/architectural_-_annotation_scaling_and_multileaders.dwg"
    data = requests.get(target_url)
    sideDb = Db.Database(False, True)
    with tempfile.NamedTemporaryFile("wb", delete_on_close=False) as f:
        f.write(data.content)
        f.close()
        s…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@schoeller
Comment options

Answer selected by schoeller
Comment options

You must be logged in to vote
1 reply
@CEXT-Dan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants