By Jeremy Tammik.
I just published the beginning of a new collection of Forge Python scripts, currently with a count of one:
py_forge_formats.py implements a Python wrapper around two basic RESTful Forge web service calls:
- Authenticate an app – forge_authenticate_app
- Query the file formats currently supported by the translation processes – forge_formats
The result is prettified using the jprettyprint helper function.
The mainline ties it all together and presents the final result, which looks like this at the time of writing:
$ ./py_forge_formats.py 9 Forge output formats: dwg: f2d, f3d, rvt fbx: f3d ifc: rvt iges: f3d, fbx, iam, ipt, wire obj: asm, f3d, fbx, iam, ipt, neu, prt, sldasm, sldprt, step, stp, stpz, wire, x_b, x_t, asm.NNN, neu.NNN, prt.NNN step: f3d, fbx, iam, ipt, wire stl: f3d, fbx, iam, ipt, wire svf: 3dm, 3ds, asm, catpart, catproduct, cgr, collaboration, dae, dgn, dlv3, dwf, dwfx, dwg, dwt, dxf, exp, f3d, fbx, g, gbxml, iam, idw, ifc, ige, iges, igs, ipt, jt, max, model, neu, nwc, nwd, obj, pdf, prt, rcp, rvt, sab, sat, session, skp, sldasm, sldprt, smb, smt, ste, step, stl, stla, stlb, stp, stpz, wire, x_b, x_t, xas, xpr, zip, asm.NNN, neu.NNN, prt.NNN thumbnail: 3dm, 3ds, asm, catpart, catproduct, cgr, collaboration, dae, dgn, dlv3, dwf, dwfx, dwg, dwt, dxf, exp, f3d, fbx, g, gbxml, iam, idw, ifc, ige, iges, igs, ipt, jt, max, model, neu, nwc, nwd, obj, pdf, prt, rcp, rvt, sab, sat, session, skp, sldasm, sldprt, smb, smt, ste, step, stl, stla, stlb, stp, stpz, wire, x_b, x_t, xas, xpr, zip, asm.NNN, neu.NNN, prt.NNN
This script replaces and improves on the
previous forgeauth
and forgeformats Unix
shell cURL scripts documented in the discussion of
the cURL
wrapper scripts to list Forge file formats.
For the sake of completeness, those two scripts have been added to this repository as well.
Setup and Usage
Two aspects need to be prepared: Forge and Python.
Before you can make any use of the Forge web services, you will need to register an app and request the API client id and client secret for it at developer.autodesk.com > my apps.
These scripts assume that you have stored these credentials in the environment variables FORGE_CLIENT_ID
and FORGE_CLIENT_SECRET
.
Regarding the Python components:
- Install Python.
- Install the requests Python library.
Now you should be all set to run as shown above.