AnsweredAssumed Answered

Delete Picture / OLE in drawing (template)

Question asked by Koen B. on May 10, 2019
Latest reply on May 15, 2019 by Amen Allah Jlili

Hello There,

 

We once had the Idea of adding some pictures as OLE objects of general tolerances (DIN ISO 2768 for example) but  now with implementing PDM we're having problems with  transitions of drawings with OLE objects (this is a known SPR) and exporting to DXF without those images seems not possible.

 

So I deleted the pcitures/OLE objects in the template, but there are a number of drawings still with those pictures in it. I want to delete those using a macro. I found a SolidWorks API help item about this: 2018 SOLIDWORKS API Help - Delete OLE Objects from Drawing Sheet and Template Example (VBA) 

 

but it doesn't work it hangs at "DeleteAllOleItemsInSheet" : compile error wrong number of arguments or invalid property assignment.

 

also I found this simpler version of deleting a sketch picture on a drawing. But I have no name for the OLE objects. So I dont know if it's possible to change it for type in stead of name? 

 

Option Explicit



Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2



Sub main()



Set swApp = Application.SldWorks



Set swModel = swApp.ActiveDoc
swModel.SelectByName 0, "Sketch Picture1"
swModel.EditDelete



End Sub

 

It would be nice if I can run it on a folder, but opening the files and deleting the pictures with a macro is also an option.

 

I'm dabbling a bit with macro's and API but i've still got a long way to go.. I would appreciate help on this subject!

 

#api 

Outcomes