Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:

  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

How to Programmatically Import Image? Using skImage(...)?

brian_guanbrian_guan Member Posts: 10
I am trying to use FeatureScript to programmatically import a logo image into my model but I can't seem to find any example.

Doing so manually in Part Studio by importing the logo in DXF and inspecting the underlying FeatureScript code, it seems to be essentially re-sketching the logo line by line, arc by arc, instead of dealing with the logo image as a logical unit.

Browsing FeatureScript documentation I found https://cad.onshape.com/FsDoc/library.html#module-sketch.fs which mentions skImage(...) but it is unclear to me what the parameter "blobInfo" is supposed to take, and I can't find any example of it. I was able to make skText(...) work as comparison.


I wrote a little FeatureScript code to illustrate my point:

https://cad.onshape.com/documents/2b537144499e9a65a1f29a21/w/25385a13a699a6857a41ecf9/e/62ce786523dc5d93219530c6

Can someone from OnShape comment?  Thanks.

Comments

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 427
    Blob info of an image blob will come from an import of another tab. It will contain the right thing if the tab you import is a png, jpg, svg, etc (More info on imports here)

    Here's a working example of that:
    https://cad.onshape.com/documents/58d571673a8c013188ffde1f/w/fdf7189b13396423709a9dc1/e/d2ffa1eb9ede24d6c4796b49

    If you want to insert your dwg as an image using a custom feature, I'd recommend convert your dwg to an svg and use the method described above to insert the image.


    If you want to use the dwf as geometric entities, that will be more difficult, but possible. Let me know if that's your goal, I can expand more on what the right strategy is.

  • brian_guanbrian_guan Member Posts: 10
    Thanks, I am hoping to extrude the logo so to use it to engrave on a surface of another solid.  I try to expand on your example solution but extruding the image I get only a cube, rather than a solid logo.
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 427
    I believe the right way to approach this task is to import the DXF into another Part Studio named e.g. "Sketch DXF". Then, import that Part Studio into a Feature Studio defining your custom feature.

    This custom feature can then build the underlying DXF, move it around, and use the resulting geometric entities.

    Here's an example of that workflow:
    https://cad.onshape.com/documents/afed475da2608bdfe42f91c5/w/ed18fff425dcd1e580ada7c0/e/c9378a69fd3a6ba3482805c7

Sign In or Register to comment.