Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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_guan
Member Posts: 13 ✭✭
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.
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.
0
Comments
-
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.
1 -
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.0
-
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
0 -
@kevin_o_toole_1 is this still the most efficient way to programmatically import a part logo and apply to the model in context?
My logo location/size is dependent on variables and features in the FS itself, rather than being user selected. So, both options here seem overly complicated.
But, as with Brian's case, when I brought the skImage into context, I produced a blank rectangle. Any initial thoughts on simplification would be much appreciated!
Note: I just put in a random location to see if it would work. Screenshots of input/outcome below.


0 -
Hi @Stormi_Backus,
It sounds like you want to use the .dxf as geometry to e.g. emboss the logo on the part. Is that right?
If so, you would want to create a feature similar to the sketch DWG example I posted later in this thread, not the skImage example I posted earlier in this thread.
The skImage function simply places a graphical image in your Part Studio, it does not create real geometry that can be referenced in features. If that's what you want, you can convert your .dxf file to a .svg and use skImage. If you want the geometry, you will need to follow the DWG example, importing the .dxf geometry manually into a Part Studio before using that Part Studio in a custom feature.
– Kevin
1 -
Awesome, thanks Kevin!0
-
@kevin_o_toole_1 I've successfully implemented this workflow for my FS generated models and set them up with a boolean for whether or not the user wants a part logo on the model. If the box is checked, the FS will generate a bounding sketch automatically. Then, the user need only grab the FS of the brand logo they want applied and extrude it into the part.
Now I'm wondering if there's a way to work the same boolean option into a configured part. Any suggestions off the top of your head? Link to both the FS's and configured parts below. Thanks!
Logo FS:
https://cad.onshape.com/documents/1c864a0f76cc68fc6a77ba31/w/dff5ee744601abbaacb0232f/e/cbe568b83985970cb9f4a8ac
Part FS:
https://cad.onshape.com/documents/51d4a2a74f19d96e738a7a86/w/0cffaf06f18f5433f9dce56d/e/4122ee75c726579bc9fffe0c?renderMode=0&uiState=652f19a90a933e3638634b3a
Part Configuration:
https://cad.onshape.com/documents/a4d1c9f3b7a0d44474d08e3a/w/bc8c3641dcb96ce97747b8c3/e/8a0dddffcd07b4ebc045940a?configuration=Bore_Diameter=0.03175+meter;List_GadxODcKvYw2yy=_17;List_sUepC7gBBML0fO=W12H&renderMode=0&uiState=652f19d57839ae11875c1cdd
0


