Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCP Image Import #28

Closed
jdegenstein opened this issue Jul 19, 2023 · 2 comments
Closed

OCP Image Import #28

jdegenstein opened this issue Jul 19, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@jdegenstein
Copy link
Contributor

Like many other CAD software it would be great to import a raster image into OCP CAD Viewer. That way you could take a photo of a real-life object, import/rescale in OCP CAD Viewer, and then design/sketch on top of the image in build123d/CQ. Flatbed scanners can be really good sources of reference images as well.

Desired features:

  • Import a variety of raster image formats (PNG/JPG/etc)
  • Have the ability to scale the image uniformly
  • Have the ability to adjust transparency of this image-plane
  • Have the ability to place the image-plane on an arbitrarily defined Plane with appropriate defaults like Plane.XY, Plane.XZ etc

As far as ThreeJS is concerned, here is a working example someone created of loading an image onto a plane as a texture:
https://codepen.io/duhaime/pen/jaYdLg

I suggest looking at the Python Pillow library (there may be lighter weight alternatives). This may be relevant for encoding an image to an IO object in memory.
https://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.Image.tobytes

This SO question may also be relevant:
https://stackoverflow.com/questions/27826422/get-binary-image-data-from-pil-image

@bernhard-42 bernhard-42 added the enhancement New feature or request label Dec 9, 2023
@Yeicor
Copy link

Yeicor commented Jan 13, 2024

I was about to suggest this too, but I would generalize to import textured meshes to use as a reference while designing. This would be interesting for loading 3D scans or other models without losing texture information.

There could be a helper function for loading an image that would create the model described above and load it as a textured mesh.

@bernhard-42
Copy link
Owner

fixed in 2.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants