AnsweredAssumed Answered

Opendoc6/7 is not working properly, opened silent in any case

Question asked by Adam Mircea on Nov 26, 2020
Latest reply on Dec 1, 2020 by Alastair Cardwell

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,