-
Dear all, thanks for PyRx. I would start out like: import urllib.request
from pyrx_imp import Rx, Ge, Gi, Db, Ap, Ed, Cv
target_url = "https://github.com/mozman/ezdxf/raw/refs/heads/master/tests/test_01_dxf_entities/houses_of_parliament_georeferenced.dxf"
data = urllib.request.urlopen(target_url) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
When doing import requests
import io
from pyrx_imp import Rx, Ge, Gi, Db, Ap, Ed, Cv
target_url = "https://github.com/CEXT-Dan/PyRx/blob/1370f3b0627e5f45d3eb46506b0580f94b4b5a27/unitTests/testmedia/BCADCIVIL1.dwg"
data = requests.get(target_url)
inmemoryfile = io.BytesIO(data.content)
sideDb = Db.Database(inmemoryfile, True)
sideDb.closeInput(True)
inmemoryfile.close() I receive
|
Beta Was this translation helpful? Give feedback.
-
For now there seems to be no other option than saving to a temporary file. However, you need to use the 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()
sideDb.readDwgFile(f.name)
sideDb.closeInput(True)
filename = Path("test.dwg").absolute()
print(filename)
sideDb.saveAs(str(filename)) |
Beta Was this translation helpful? Give feedback.
-
@CEXT-Dan , maybe it's worth adding a method to load dwg/dxf from a stream? |
Beta Was this translation helpful? Give feedback.
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)
orDb.readDwgFile(dwg_file)
method.