Skip to main content

cad3d-ir-sldprt

cad3d-ir-sldprt imports SOLIDWORKS parts (.SLDPRT) and assemblies (.SLDASM) into cad3d-ir through sldkit. It does not read the Parasolid B-Rep: it takes the triangle meshes that SOLIDWORKS saved for its own display (DisplayLists), which sldkit returns as packed buffers, and writes them as one glTF binary with the same conventions as the STEP adapter. Document metadata (internal version, configuration names, custom properties, units) and the saved preview image come from sldkit's bounded metadata parse.

Assemblies are placed from what the file stores. The display stream keeps one record per component instance, at every nesting level, with the instance's placement in the assembly and the document and configuration it refers to. The face tables follow the first instance of a document and configuration only, so the adapter assigns each table to the record before it, lets the later instances display the tables of the first one, and emits one glTF node per instance with the placement of its record (repeated components share one glTF mesh). The component tree the file carries says which components are hidden or suppressed. On a four-valve FESTO manifold this reproduced the STEP export of the same assembly within a tenth of a millimetre, with every point of the STEP surface covered (see cad3d_ir_sldprt.assembly). Assemblies saved by SOLIDWORKS 2023 and later keep the tables in FaceTessellations sections instead, one per referenced part, with a directory of occurrences; sldkit 0.3.3 returns that directory and the adapter places every occurrence from it, including repeated parts and nested occurrences, whose sub-assembly transforms are composed from the component tree.

The result is what SOLIDWORKS showed on screen when the file was saved: every visible face at the saved image quality, face outlines as edges, saved face colours as materials. Exact surfaces, dimensions and feature history are not available from this path.

The distribution depends on cad3d-ir and sldkit; the core distribution does not depend on this adapter or on sldkit.

Usage

from pathlib import Path

from cad3d_ir import DirectoryResourceWriter
from cad3d_ir.importers import ImportOptions
from cad3d_ir_sldprt import SldprtImporter

result = SldprtImporter().import_file(
    Path("bracket.SLDPRT"),
    options=ImportOptions(include_visualization_mesh=True, include_brep=False),
    resources=DirectoryResourceWriter("converted"),
)
preview = result.package.visualizations[0]  # geometry/<slug>-<key>.glb
print(preview.statistics["triangles"], preview.statistics["parts"])
for diagnostic in result.diagnostics:
    print(diagnostic.code, diagnostic.message)
cad3d-ir-sldprt bracket.SLDPRT converted/                 # manifest + GLB + preview image
cad3d-ir-sldprt bracket.SLDPRT converted/ --no-mesh       # metadata and preview only
cad3d-ir-sldprt frame.SLDASM converted/                   # placed component instances
cad3d-ir-sldprt frame.SLDASM converted/ --no-assemblies   # reject assemblies instead
cad3d-ir-sldprt bracket.SLDPRT converted/ --diagnostics report.json

What the package contains

  • one SourceDocument (format="sldprt", version="SOLIDWORKS <year>" estimated from the internal version) whose properties carry the envelope, document kind, internal version, configuration names, flattened custom properties, the document length unit and the display streams;
  • one part product definition with one configuration named after the document's first configuration (or Default);
  • one body whose mesh representation (role="visualization", fidelity="derived", derivation.relation="tessellated") is the GLB, and a body appearance when the display data carries a saved colour;
  • one package Visualization pointing at the same GLB, with triangles, line_segments, vertices, nodes, meshes and parts statistics;
  • the saved preview image as a resource (preview/<slug>-<key>.png or .bmp, properties.role="preview-image"), referenced from metadata.preview_resource_id.

For an assembly the root product is an assembly, every component instance that the display stream or the FaceTessellations directory records becomes its own part product with a configuration and (when it has geometry) a body, and the root configuration owns one Occurrence per instance with the component transform in package millimetres (visible=False for hidden components; suppressed components are left out). Nested occurrences are named <sub>-<m>/<name>-<n> and carry their placement in the root assembly. Face tables that cannot be joined to a placed instance (a record without a readable placement and without an entry in the component tree, tables ahead of the first record) stay at their stored coordinates in a root body and are reported. metadata.placement_source tells which layout the file used, and the bounds of the visualization are those of the placed assembly.

A component the assembly holds no display data for is an occurrence too: a product and a configuration without a body, at the placement the component tree gives it, and no node in the GLB. An assembly whose file holds no display data at all (no tessellation of any component) maps to its product structure alone: one occurrence per component of the component tree, no bodies and no visualization, metadata.placement_source component_tree, next to the preview image when the file has one.

The GLB has one shared vertex set in millimetres, one TRIANGLES primitive per saved colour whose extras.ranges list [pick_id, first_index, index_count] per face table, and one LINES primitive with the face outlines. The pick id is the 1-based position of the face table in sldkit's mesh.parts. Node 0 converts package units to glTF metres and Y-up exactly as the STEP adapter does; SOLIDWORKS coordinates are passed through unchanged, so a part and the STEP exported from it land in the same place.

Options

ImportOptions (core): include_visualization_mesh writes the GLB (without it the package carries metadata, the preview image and an empty body); mesh_include_edges controls the outline primitive; strict turns a document without any display data into SldprtReadError; validate runs the package graph validation. The tessellation options do not apply: the mesh is the one SOLIDWORKS saved.

SldprtImporter(accept_assemblies=True, read_properties=True, include_preview=True, limit_profile="service"):

  • accept_assemblies=False rejects .SLDASM documents with UnsupportedDocumentKindError. By default they are imported and placed.
  • read_properties=False skips the metadata parse (a part still gets its kind and version from the display stream).
  • include_preview=False leaves the preview image out.
  • limit_profile is sldkit's limit profile (service is bounded for shared servers, desktop allows larger inputs).

Diagnostics

Code Severity Meaning
SLDPRT_DISPLAY_MESH_ONLY info Geometry is the saved display tessellation; the B-Rep is not read.
SLDPRT_APPEARANCE_NOT_SAVED info No colour is saved with the display data; the default face colour is used.
SLDPRT_COLORS_NOT_MAPPED info Several saved colours are kept as GLB materials; the body appearance uses the most common one.
SLDPRT_NORMALS_DERIVED info A table without normals received area-weighted vertex normals.
SLDPRT_CONFIGURATION_UNRESOLVED warning Several display streams hold meshes; configuration ownership is not resolved and all are shown.
SLDPRT_DISPLAY_STREAM_UNREADABLE warning A display stream could not be decoded; the others are kept.
SLDPRT_DISPLAY_ENCODING_UNSUPPORTED warning The display stream uses an encoding sldkit does not decode (older __Zip streams).
SLDPRT_VERTEX_BUDGET_EXCEEDED warning The limit profile stopped packing vertices; the mesh is partial.
SLDASM_PLACEMENT_FROM_COMPONENT_TRANSFORMS info Component instances were placed with the placements the assembly stores: those of the instance records for details.source display_lists, the swTransform values of the component tree for face_tessellations. details.nested counts the placed instances inside sub-assemblies and details.repeated those that display the tables of an earlier instance of the same document.
SLDASM_PLACEMENT_BY_TREE_ORDER warning FaceTessellations occurrences whose saved names match no component (the components were renamed after the display data was saved) were placed by their position in the component tree; only when the directory lists exactly the tree's part occurrences in order.
SLDASM_PLACEMENT_UNRESOLVED warning Some face tables could not be joined to a placed instance (no readable placement, unmatched records); they stay at stored coordinates.
SLDASM_COMPONENTS_SKIPPED info Hidden and suppressed component instances are left out of the visualization.
SLDASM_COMPONENTS_WITHOUT_DISPLAY warning The assembly holds no display data for details.count components that are neither hidden nor suppressed. They are kept in the product structure and are missing from the visualization. details.all is true when the file holds no display data at all (details.source component_tree).
SLDASM_COMPONENTS_WITHOUT_BODIES info details.count components have nothing to display: the component tree has a modification stamp for their model (SOLIDWORKS has had it loaded) and no bounding box, or one without volume (parts of sketches or reference geometry). They are kept in the product structure and are not counted as missing. Only told apart where the tree records bounding boxes for components.
SLDPRT_ASSEMBLY_PLACEMENT_UNVERIFIED warning Only when nothing could be placed: the stored display tables are shown as they are.
SLDPRT_PREVIEW_ONLY warning No display mesh could be read; only the preview image and metadata are available. details.reason is display_not_saved for an assembly whose file holds no display data; its product structure is available too.
SLDPRT_PREVIEW_UNREADABLE warning The saved preview image could not be extracted or decoded.
SLDPRT_PROPERTIES_NOT_READ warning The metadata parse failed; the mesh is still written.
SLDPRT_NO_DISPLAY_DATA error Neither display meshes nor a preview image exist; only metadata was read (and, with details.reason display_not_saved, the product structure of the assembly).

Other display.* diagnostics from sldkit are passed through as SLDPRT_DISPLAY_<CODE> with sldkit's severity and the original code in details.sldkit_code.

Current boundary

  • Modern-container parts (SOLIDWORKS 2015 and later) and OLE2 parts whose display stream uses the __ZLB encoding yield meshes. OLE2 parts with the older __Zip encoding yield the preview image and metadata only.
  • Drawings (.SLDDRW) are rejected. DisplayLists assemblies (saved before SOLIDWORKS 2023) are placed at every nesting level from their instance records; without the component tree (some older files carry none) hidden components cannot be told apart and are shown. FaceTessellations assemblies place nested occurrences through swXmlContents/COMPINSTANCETREE; an occurrence whose chain is missing there stays at its stored coordinates.
  • A component the file holds no tables for has no geometry here, whatever its own part file contains: the adapter reads the one assembly file and does not open the files of its components. FaceTessellations sections save no colours, so these assemblies use the default face colour.
  • Configurations are not resolved: the display streams that SOLIDWORKS saved are returned, and a document with several mesh-bearing streams is flagged.
  • Colours follow sldkit's saved precedence (body, feature, face); textures and appearances that SOLIDWORKS did not save with the display data are absent.
  • The adapter is byte-faithful to sldkit: positions, normals and indices go into the GLB without conversion.

Tests

The test suite builds minimal SolidWorks documents in memory (the same frame and table grammar sldkit's own tests use) and ships no CAD file. Set CAD3D_IR_SLDPRT_SAMPLES to a directory of local .SLDPRT files to run the optional sample check.

License

cad3d-ir-sldprt is source-available under the PolyForm Noncommercial License 1.0.0, following sldkit, with separate commercial licenses from UnRobotics Inc. See LICENSE. The cad3d-ir core and cad3d-ir-step in the same repository remain MIT.

Required Notice: cad3d-ir-sldprt is licensed by UnRobotics Inc. (https://www.un-robotics.com/). Required Notice: cad3d-ir-sldprt is offered under PolyForm Noncommercial 1.0.0; separate commercial licenses are available.

Metadata

Release files for cad3d-ir-sldprt 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cad3d-ir-sldprt 0.4.2
File Size Uploaded Provenance Actions
cad3d_ir_sldprt-0.4.2.tar.gz 56.3 kB Without provenance Details for cad3d_ir_sldprt-0.4.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cad3d-ir-sldprt 0.4.2
File Interpreter ABI Platform Actions
cad3d_ir_sldprt-0.4.2-py3-none-any.whl Python 3 none any Details for cad3d_ir_sldprt-0.4.2-py3-none-any.whl

Total release size: 98.5 kB

Release files / cad3d_ir_sldprt-0.4.2.tar.gz

Download URL cad3d_ir_sldprt-0.4.2.tar.gz
Size 56.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8dcc2fb497206a421df6114896fbeba6f22b50a439a50516253d59c742480d8f
BLAKE2b-256 checksum
How to use checksums
aa8cb9a59fba589425ca4741c36c90e49d34dab1bae127111bf00bb0d92c192f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / cad3d_ir_sldprt-0.4.2-py3-none-any.whl

Download URL cad3d_ir_sldprt-0.4.2-py3-none-any.whl
Size 42.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a80b48ffa9ff935858b6e00b59976b7eff54ac334ceb9727e6ceec558385e2f7
BLAKE2b-256 checksum
How to use checksums
d637d0212999b0a7f2b39891b6e85ae70bb32791be9e9cc1b40876445c4664ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for cad3d-ir-sldprt 0.4.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page