5 Replies Latest reply on Nov 23, 2014 6:11 AM by Daniel Andersson

    swEdrawingSaveAll → Change → swEdrawingSaveSelected

    Yong Ning

      Hope Select Configuration.jpg

       

      Hope Select Configuration1.jpg

       

       

      ****************************************************

      swEdrawingsSaveAsSelectionOption, swEdrawingSaveAll

      swEdrawingSaveAll → Change → swEdrawingSaveSelected

      Help , How to select configuration?

      *****************************************

       

       

      2010 SolidWorks API Help - swEdrawingSaveAsOption_e Enumeration

      http://help.solidworks.com/2010/english/api/swconst/solidworks.interop.swconst~solidworks.interop.swconst.swedrawingsaveasoption_e.html

       

      How to save as eDrawomg with API? | SOLIDWORKS Forums

      https://forum.solidworks.com/thread/83351?fromrss=1

       

      Help with SaveAs in macro | SOLIDWORKS Forums

      https://forum.solidworks.com/message/438548#438548

      ***************

          • Re: swEdrawingSaveAll → Change → swEdrawingSaveSelected
            Yong Ning

            Tanks your linked Web.

             

            Hope result is a1,a3 configuration in b.easm file

            Hope+Select+Configuration1.jpg

            *******************************

            Question, Why  follow code,  Save  Single Configuration in b.easm file

             

            Single Configuration.jpg

             

             

             

                SwApp.SetUserPreferenceIntegerValue swEdrawingsSaveAsSelectionOption, swEdrawingSaveSelected

                Str =  "a1\na3"

                SwApp.SetUserPreferenceStringListValue swUserPreferenceStringListValue_e.swEmodelSelectionList, Str

            ******************

            Hope Save e.easm file → Have a1,a3 configuration

             

            *****************************

            Sub SaveEdrawing()

              ''

              Dim Path, FileName, Str

              Dim sFileName As String, nErrors As Long, nWarnings As Long

              ''

              Dim fileConfig As String, fileDispName As String, fileOptions As Long

              ''

              Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

              ''

                Set SwApp = Application.SldWorks

                Set SwModel = SwApp.ActiveDoc

                ''

                sFileName = Left(SwModel.GetPathName, Len(SwModel.GetPathName) - 6)

             

             

                If SwModel.GetType = swDocPART Then

                   sFileName = sFileName & "eprt"

                ElseIf SwModel.GetType = swDocASSEMBLY Then

                   sFileName = sFileName & "easm"

                ElseIf SwModel.GetType = swDocDRAWING Then

                   sFileName = sFileName & "edrw"

                Else

                   Exit Sub

                End If

             

               SwApp.SetUserPreferenceIntegerValue swEdrawingsSaveAsSelectionOption, swEdrawingSaveSelected

                Str = SelectionList = "a1\na3"

                SwApp.SetUserPreferenceStringListValue swUserPreferenceStringListValue_e.swEmodelSelectionList, Str

             

                SwModel.Extension.SaveAs sFileName, swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, nErrors, nWarnings

             

            End Sub

              • Re: swEdrawingSaveAll → Change → swEdrawingSaveSelected
                Daniel Andersson

                Not at the computer.  But I  see that the string is not correct \n is line separator in Visual C/C++.

                 

                Try this for vba:

                str = "a1" & vbNewLine & "a3"

                 

                Not sure what you mean with the added image of the display states. Display states may or may not be linked to configuration. A configuration may have multiple Display states

                  • Re: swEdrawingSaveAll → Change → swEdrawingSaveSelected
                    Yong Ning

                    Thank you reply

                     

                    Str ="a1" & chr(10) & "a3"

                     

                    **********************

                    Private Sub ll()

                      Dim SwApp As SldWorks.SldWorks, SwModel As ModelDoc2

                         Set SwApp = Application.SldWorks

                         Set SwModel = SwApp.ActiveDoc

                      Dim ConfArr, Str

                         ConfArr = SwModel.GetConfigurationNames

                        

                         For ii = 0 To UBound(ConfArr)

                           If Not UCase(ConfArr(ii)) Like UCase("*Default*") And Not ConfArr(ii) Like "*配置*" Then

                              Str = Trim(ConfArr(ii)) & Chr(10) & Str

                           End If

                         Next ii

                         Debug.Print Str

                         Dim sFileName As String, nErrors As Long, nWarnings As Long

                         ''

                         Dim fileConfig As String, fileDispName As String, fileOptions As Long

                         ''

                        sFileName = Left(SwModel.GetPathName, Len(SwModel.GetPathName) - 6)

                     

                     

                        If SwModel.GetType = swDocPART Then

                           sFileName = sFileName & "Eprt"

                        ElseIf SwModel.GetType = swDocASSEMBLY Then

                           sFileName = sFileName & "Easm"

                        ElseIf SwModel.GetType = swDocDRAWING Then

                           sFileName = sFileName & "Edrw"

                        Else

                           Exit Sub

                        End If

                        ''

                        SwApp.SetUserPreferenceIntegerValue swEdrawingsSaveAsSelectionOption, swEdrawingSaveSelected

                        SwApp.SetUserPreferenceStringListValue swUserPreferenceStringListValue_e.swEmodelSelectionList, Str

                        SwModel.Extension.SaveAs sFileName, swSaveAsCurrentVersion, swSaveAsOptions_Silent, Nothing, nErrors, nWarnings

                          

                    End Sub