跪拜 Guibai
← Back to the summary

Embed CAD Drawings Without Shipping Files to a Third-Party Server

How to use a pure browser-side CAD viewer to display drawings directly via URL — supporting measurement and annotation — while keeping files from ever leaving your own site.

Most 'view CAD in the browser' widgets follow the same pattern: hand your drawings to someone else's server. Files get uploaded or proxied, rendered on infrastructure you don't control, then stuffed into an iframe. Convenient, yes — but for architecture firms, factories, and products that treat drawings as confidential assets, it's also a privacy risk. There's another way.

Point an iframe at your publicly accessible DWG or DXF URL. The drawing is fetched in the visitor's browser, parsed and rendered entirely on the client side, and opened in review mode — users can measure and annotate, but cannot modify the drawing or create new entities. Because this is a fully frontend tech stack, the drawing never passes through any CAD backend. The file stays on your site (or any source you already trust). This is both a simpler integration path and a stronger data-security narrative.

That's exactly what the MLightCAD iframe plugin solves.

medium-iframe-cad-embed-cover.png

The privacy difference in one sentence

Traditional embedded viewers are essentially: your file → their cloud → their viewer. MLightCAD's embedding approach is: your file URL → the visitor's browser → local parsing and rendering.

No CAD conversion cluster, no mandatory upload pipeline, and no piling drawings into a third-party repository just because you 'wanted to show a drawing.' If the DWG already sits on your CDN or static site, and CORS allows the embedding page to fetch it, the byte path is: from your host to the user's browser. That's an architectural guarantee, not a line in a terms-of-service document.

What you get inside the iframe

With just one iframe, you can:

Minimal example:

<iframe 
  src="https://mlightcad.com/embed.html?url=https://example.com/plans/floor.dwg&mode=review&toolbar=1"
  style="width:100%;height:600px;border:0"
  allowfullscreen
>
</iframe>

Replace https://example.com/plans/floor.dwg with any publicly accessible drawing on your own infrastructure.

Why defaulting to 'review' matters

Embedded pages are often shared with clients, contractors, or the public. Defaulting to full write permissions inside a widget is an invitation to accidental edits.

MLightCAD's embed defaults to mode=review:

Mode What the user can do
review (default) View, measure, annotate — cannot modify the drawing or create entities
read View only
write Full editing, when you explicitly enable it

Useful review tools stay available, without turning every embed into an unsupervised editor.

Query parameters worth knowing

Parameter Default Effect
url Absolute HTTPS address of the .dwg / .dxf
mode review review / read / write
view extents extents (zoom to full drawing) or saved (file VPORT)
lang en Viewer UI: en, zh, tr, cs
toolbar 0 Set to 1 to show the toolbar
commandline 0 Set to 1 to show the command line
theme dark dark or light

You can assemble and preview these parameters live on the documentation page: mlightcad.com/iframe-plugin.html.

One practical requirement: CORS

Because the browser fetches the file, the host serving the drawing must allow cross-origin reads if the drawing is not on the same origin as the embedding page. This is the cost of the zero-backend design: you configure response headers on your own file host, rather than handing drawings to a proprietary viewer cloud.

If you already serve static assets with a reasonable CORS policy, that's enough. Point url at the file, embed it, and you're done.

How it fits into the larger MLightCAD stack

MLightCAD's cad-viewer is a browser-native CAD stack: DWG/DXF parsing, WebGL rendering, and editing logic, all designed around 'no CAD server required.' The iframe plugin is the delivery surface for that same philosophy aimed at 'drop into any CMS' — it maintains the same architectural-level privacy as the rest of the product, suitable for product sites, documentation sites, and portals that only need viewing and reviewing.

Conclusion

Embedding CAD used to mean picking one of two options: 'build your own viewer' or 'send your drawings to someone else's server.'

Now there's a third choice: publish files wherever you already host them, pass in a URL, and let the browser do the rest — with measurement and annotation in review mode, and no backend that ever needs to 'see' the drawing.

If your product promises customers that their drawings stay under their control, your embed widget should deliver on the same promise.