Skip to content
プロジェクト

概要

Reads SLDPRT/SLDASM/SLDDRW files without SolidWorks

デザイン・メディア

この数値の測り方

計測したスター増加

24時間
履歴を収集中
7日間
履歴を収集中
15日間
履歴を収集中
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

openSW

CodeQL

Convert SolidWorks part files (.SLDPRT) to Parasolid (.x_t) and STEP, without SolidWorks. View parts, assemblies (.SLDASM) and drawings (.SLDDRW) in a web page.

Try it online: https://cehaho.github.io/OpenSW/ — your file is not uploaded to any server: it is read and converted in your browser.

The three examples of the page, as it shows them:

A part — NIST PMI test model FTC 08, its DimXpert PMI shown at their features, and the file's properties.

A NIST part with its DimXpert PMI

An assembly — NIST MTC CRADA box, 36 components from the display mesh the assembly stores, and its bill of materials.

The NIST assembly and its bill of materials

A drawing — a 2×4 LEGO brick: views, dimensions, the title block and a shaded view, with the linked texts the sheet shows.

A LEGO brick drawing

What it reads, and what it doesn't

openSW shows what the file holds, as SolidWorks stored it. It recomputes nothing: no regeneration, no retessellation, no mass computed from geometry. It is a file reader for interoperability, not a CAD kernel or an API.

read not read
Part the exact solid of the saved configuration (Parasolid B-rep → .x_t, STEP), colours, face names the feature tree (features, equations, history): what you get is the final solid, not how it was built
sketches, placed in the model: shown in the 3D view, exported as a STEP of their curves only sketch dimensions and relations; sketches of older saves
DimXpert PMI: dimensions and their tolerances, geometric tolerances, datums and datum reference frames, the features they apply to with their nominal geometry; shown in the 3D view, each at its feature a dimension's nominal value (SolidWorks does not write it, it measures the geometry); where SolidWorks places each annotation on screen; annotations on features stored without geometry (fillets); PMI not made with DimXpert
properties: summary, custom and per-configuration properties, configuration names, material and density, preview image geometry of configurations that were not saved with their geometry (the page says which ones were)
mass, volume, area, centre of mass and inertia at the centre of mass, when SolidWorks stored them (it does when a property links to them) mass properties SolidWorks did not store
Assembly components and a bill of materials by part file (→ CSV), placements, hidden, suppressed and excluded-from-BOM states, the configuration each instance shows, with its part files each part's properties and material in the CSV, mates (name, type, the components they link, a distance's value), the display mesh (→ STL); with its part files, an exact STEP assembly and the parts' sketches and DimXpert PMI, placed per instance angle mate values and the faces mates hold; configurations; the exact geometry, which is in the parts
Drawing sheets, lines (with their line types), arcs, texts (fonts, colours), tables, images, model view edges (projected, detail, broken, cropped, hidden-lines-removed views), shaded views from the display mesh SolidWorks stores, dimensions and their tolerances as drawn (→ SVG, DXF); linked texts ($PRP:"…") with the value they show; dimension values as numbers (lengths, radii, diameters, angles) and length tolerances; the image SolidWorks keeps of each sheet the edges a dimension measures; whether a radial dimension is R or Ø other than in its text; angle tolerances; hatches, centre marks, the sheet format; where an assembly places its parts (it is in the assembly file)

What is not read is counted in the log rather than hidden.

Install

git clone https://github.com/cehaho/OpenSW
cd OpenSW
pip install -e ".[occ]"

Python 3.10+. The occ extra (OpenCASCADE) is only needed for the 3D view of the web app.

Convert

python tools/convert.py part.SLDPRT -o out/    # .x_t and .STEP
python tools/convert.py --help

Web app

python tools/webui.py                          # http://127.0.0.1:8765

Drop a part, download the .x_t or STEP, and view it in 3D: click a face to read its name, F<node>; the view cube turns it to a standard view. The Sketches switch overlays the part's sketches, and a STEP of the sketches alone, without the solid, downloads too. The PMI switch shows its DimXpert annotations, each led from its feature. The page speaks the six most spoken languages: English, Chinese, Hindi, Spanish, French and Arabic. Here the file is sent to this local server; uploads are deleted after conversion, results after 30 minutes. PORT and OPENSW_HOST set the address; on a public server, put an authenticating reverse proxy in front.

In the browser, without a server

This is the page published at https://cehaho.github.io/OpenSW/. To build it yourself:

python tools/pages.py                          # writes _site/

_site/ is the same page, served by any static host (GitHub Pages): the converter runs in the browser under Pyodide, and the 3D view uses occt-import-js (OpenCASCADE in WebAssembly). The file never leaves the browser: nothing is uploaded, only the page and its libraries are downloaded. The STEP is the same as the desktop one except for the last digits (WebAssembly's sin/cos) and LF line endings.

In FreeCAD

freecad/ is an importer for FreeCAD 1.0 or later: SolidWorks parts, assemblies and drawings show up in File > Open.

python tools/freecad_addon.py                  # writes _freecad/OpenSW/

Copy _freecad/OpenSW/ into FreeCAD's Mod directory and restart FreeCAD. A part arrives as its exact bodies, one object each, with its sketches (real Sketcher sketches, without constraints); an assembly is exact when its part files sit next to it, a display mesh otherwise; a drawing arrives as flat geometry. freecad/README.md says what to expect.

Assemblies

The web app shows an assembly (.SLDASM) in 3D from the display mesh SolidWorks stores in it: components, placements, hidden and suppressed states. Not the exact geometry, which stays in the parts. It downloads as STL (binary, millimetres, components placed). The file properties list its components with a count per part file (suppressed and excluded-from-BOM components left out), and its mates; the component list downloads as CSV. Dropped with its part files, each CSV line also carries what the part file says about itself: its material and its custom properties (part number, description, linked mass…), one column per property name, as the part writes them.

from sldprt.assembly import read_assembly, to_stl, to_view

asm = read_assembly("assembly.SLDASM")
open("assembly.stl", "wb").write(to_stl(asm))

Drop the assembly together with its part files (several files at once, or a zip) and it downloads as an exact STEP assembly instead: each part written once from its own geometry, each instance placed as the assembly says. Sub-assemblies are flattened; a part that is not supplied is left out and named in the log. Like SolidWorks, it leaves out suppressed and hidden components. On eight test assemblies, every solid has the same volume and centre of mass as in the STEP SolidWorks exports.

from sldprt.load import load_model
from sldprt.step_assembly import write_step_assembly

parts = {name: load_model(name) for name in ("cube.SLDPRT", "cylinder.SLDPRT")}
report = write_step_assembly(read_assembly("assembly.SLDASM"), parts, "assembly.STEP")
print(report.instances, report.missing)

Drawings

The web app also shows a SolidWorks drawing (.SLDDRW) as SVG, sheet by sheet: lines, arcs, texts (fonts, sizes, bold, colours, Ø ± ° symbols), table cells and model views. Click a stroke to read its name. Nothing is recomputed: the strokes are those SolidWorks wrote in the file. It downloads as DXF R12 in millimetres (a zip of one DXF per sheet when there are several), and each sheet as SVG. In the DXF, colours are rounded to the nearest plain AutoCAD colour and filled arrowheads become outlines.

from sldprt.drawing import read_drawing, to_dxf, to_svg

drawing = read_drawing("plan.SLDDRW")
svg = to_svg(drawing.active)
open("plan.dxf", "w", encoding="cp1252").write(to_dxf(drawing.active))

Drawings from older SolidWorks versions are read too, dimensions included. A shaded view is painted with the display mesh the drawing stores for each part. For an assembly view, the drawing does not say where the assembly places its parts: drop the drawing together with its assembly files (several files at once, or a zip) and the view is shaded; alone, it shows its edges. Not shown yet: centre marks and hatches.

File properties

For any part, assembly or drawing, the web app shows what the file says about itself, read as stored, nothing computed: summary (title, author, keywords…), created and saved dates and by whom, custom properties (with the expression of a linked one), and for a part each configuration with its own properties, its material and density, and whether its geometry was saved. Mass, volume, centre of mass and inertia appear only when SolidWorks wrote them, which it does when a custom property links to them. Each value was checked against what the SolidWorks API reads back, on parts made for that purpose. The previews the file keeps are shown too, at their stored size on a click: the PNG preview and the larger Windows bitmap. A drawing keeps an image of each sheet it has displayed; the preview follows the sheet shown.

from sldprt import open_container
from sldprt.properties import read_properties

info = read_properties(open_container("part.SLDPRT"))
print(info["resume"], [c["nom"] for c in info["configurations"]])

These properties can say more than you think (the folder the file was saved from, who saved it): worth a look before sharing a part.

Parasolid schemas

Not included: they are Siemens files. Built-in facts cover SolidWorks parts. If one is asked for, copy pschema and schema_18 from your SolidWorks installation into schemas/.

Licence

openSW is free software under the GNU Affero General Public License v3.0 only (AGPL-3.0-only), see LICENSE and NOTICE. In short, and the licence text prevails:

  • You may use, study, copy and modify it, for any purpose.
  • If you distribute it, modified or not, you must do so under the same licence, with its source code.
  • If you let people use a modified version over a network (a web service, for instance), you must offer them its complete source code (section 13).
  • It comes with no warranty.

Legal

Interoperability work on files the author owns. This repository contains no SolidWorks or Parasolid code. openSW is not affiliated with Dassault Systèmes or Siemens; SolidWorks and Parasolid are trademarks of their respective owners.

関連プロジェクトを探す

読み込み中…