SLDDRW to DWG Including Image

Hi, I'm trying to write a macro that exports a dwg from an open slddrw. The slddrw has a title block with an image. When I save the dwg copy, I get an icon in place of the image. What can I do to have the image included in the dwg? I haven't found how to do this manually or programmatically.

Answers 7
JB
JB 2025-02-20

Pretty sure that's not going to be possible.  

JS
JS 2025-02-20

How were the images added to the drawing?  If you insert an image it becomes a Sketch Picture.  Sketch Pictures export to DWG.

KC
KC 2025-02-20

SW2021: Insert>Picture (which does become a Sketch Picture as Mr. Sitek mentioned) or Sketch Tools>Sketch Picture, on the drawing or in sheet format, a PNG writes out to the DWG.
What image format are you using?
Post your code.

DM
DM 2025-02-20

Thanks for the answers. 

I'm no expert, but the macro is doing essentially what I want, aside from the image issue, and seems to be producing the same result as saving the DWG copy manually. So it appears not to be a code issue, unless there is some other method I'm unaware of to produce the desired result. 
Code:

'____________________________________
Dim swApp As SldWorks.SldWorks
Dim swDraw As SldWorks.ModelDoc2
Dim folderPath As String
Dim dwgFolder As String
Dim longstatus As Long
Dim folder As Object
Dim file As Object
Dim fso As Object
Dim fileName As String
Dim filePath As String
Dim fileType As String
Dim outFilePath As String
Dim saveAsOptions As Long

Sub main ()
Set swApp = Application.SldWorks
swApp.Visible = True
' Get the folder
folderPath = InputBox("Path containing Solidworks drawings:" & vbCrLf & "(DWG subfolder will be created for DWG copies)")
If folderPath = "" Then
Exit Sub ' User cancelled the dialog
End If
' Create DWG subfolder
dwgFolder = folderPath & "\DWG"
If Dir(dwgFolder, vbDirectory) = "" Then MkDir dwgFolder
Set fso = CreateObject ("Scripting. FileSystemObject")
Set folder = fso.GetFolder (folderPath)
' Find all .slddrw files in the folder
For Each file In folder.files
fileName = file.Name
filePath = file.Path
fileType = LCase (fso.GetExtensionName (fileName) )
If fileType = "slddrw" Then
Set swDraw = swApp.OpenDocé6é(file.Path, swDocDRAWING, swOpenDocOptions Silent, "", 0, 0)
outFilePath = dwgFolder & "\" & Left(fileName, Len(fileName) - 6) & "dwg"

Set swDraw = swApp.ActiveDoc
saveAsCopy = True
saveAsOptions = swSaveAsOptions Copy + swSaveAsOptions_ Silent
' Save as DWG and close
longstatus = swDraw.Extension.SaveAs3(outFilePath, 0, saveAsOptions, Nothing, Nothing, 0, 0)
End If
Next
MsgBox "All drawings saved to DWG successfully.”
End Sub
'______________________________

I originally had inserted a BMP in the SLDDRW and was getting the embedded OLE icon in the DWG named "dxf<3-4 characters>.BMP". So I tried with a JPG and with a PNG as suggested, and the result continues to be an OLE called "dxf<3-4 characters>.BMP". 

Any ideas based on that?

KC
KC 2025-02-20

"I'm no expert" But Mr. Brady and Mr. Sitek are, so it may help to post your code.
To the right of your post's title is a menu. Select Edit to add your code to the body of your OP.

JS
JS 2025-02-21

There is nothing wrong with your macro or SolidWorks, other than the pasted code has a few white spaces that needed to be removed.  The problem in in AutoCAD or which ever software you use for DWGs.  Check the OLEHIDE setting in AutoCAD.  See if it is set to 3, then try 0.  Watch video.

DM
DM 2025-02-21

Thank you all for the responses and confirmation of my code. It must be on the side of the DWG software. I'm using ZWCAD (not ideal, but generally fine). OLEHIDE changes whether it shows up, but when it does show up it's an embedded OLE icon rather than the image itself. I can erase it and replace the image in the DWG (imageattach) but avoiding that extra step would have been nice. 

I appreciate the help, though. I've learned a little something.