ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
AMAdam Mircea26/11/2020

Hello all,

   I ask you please support to understand what could be the reason that the code below is not working properly, I have an assembly and I'm trying to open model by model to export the DWG file, the problem is that opendoc6 and 7, even if the option is not silent, the component doesn't opens until it reaches the code ExportToDWG2.

Tried this first :

swModel = SwApp.OpenDoc6("C:\Users\test\Desktop\Test.sldprt", swDocumentTypes_e.swDocPART, swOpenDocOptions_e.swOpenDocOptions_ReadOnly, "", longstatus, longwarning)‍‍

No effect

Then I tried this:

 swDocSpecification = SwApp.GetOpenDocSpec("C:\Users\test\Desktop\Test.sldprt")
sName = swDocSpecification.FileName
swDocSpecification.DocumentType = swDocumentTypes_e.swDocPART
swDocSpecification.LoadModel = True
swDocSpecification.UseLightWeightDefault = False
swDocSpecification.ReadOnly = False
swDocSpecification.Silent = False

swModel = SwApp.OpenDoc7(swDocSpecification)

longstatus = swDocSpecification.Error
longwarning = swDocSpecification.Warning‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Also here no effect.

In both cases I got longwarning = 128 that stands to "Document already opened", But I need to open the part and focus it otherwise the code to export DWG will not work.

swModel.ExportToDWG2(DwgPath, swModel.GetTitle, swExportToDWG_e.swExportToDWG_ExportSheetMetal, True, varAlignment, False, False, 1, Nothing)

With clean SolidWorks, the code works perfectly, the problem I think is because I have the assembly opened that uses these models.

Any idea about how can I fix this ?

Thank you in advance,

Adam.