2 Replies Latest reply on Jun 5, 2014 2:56 AM by Ar K

    Battle of InsertScale and SaveAs3 !!

    Ar K

      Hi :-)

      why in program 2, stl file can not Create but in program 1 stl file create well ? !!!!!!!!

      I need to, first doing scale then doing save as stl format.

      please help me :-)

       

      '1111111111111111111111111111111111111111111111111111111111111111111

       

      Dim swApp As Object

      Dim doc As ModelDoc2

      Dim swFeat As Feature

      Dim strFileName As String

      Dim longstatus As Long, longwarnings As Long

       

      Sub main()

       

      Set swApp = Application.SldWorks

      Set doc = swApp.ActiveDoc

      strFileName = doc.GetTitle

       

      longstatus = doc.SaveAs3("C:\temp\" & strFileName & "StlFormat.STL", 0, 0)

      Set swFeat = doc.FeatureManager.InsertScale(0, False, 1.01, 1.02, 1.03)

       

      End Sub

       

      '2222222222222222222222222222222222222222222222222222222222222222222

       

      Dim swApp As Object

      Dim doc As ModelDoc2

      Dim swFeat As Feature

      Dim strFileName As String

      Dim longstatus As Long, longwarnings As Long

       

      Sub main()

       

      Set swApp = Application.SldWorks

      Set doc = swApp.ActiveDoc

      strFileName = doc.GetTitle

       

      Set swFeat = doc.FeatureManager.InsertScale(0, False, 1.01, 1.02, 1.03)

      longstatus = doc.SaveAs3("C:\temp\" & strFileName & "StlFormat.STL", 0, 0)

       

      End Sub

        • Re: Battle of InsertScale and SaveAs3 !!
          Deepak Gupta

          Try these codes:

           

          Sub main()

              Dim swApp                   As SldWorks.SldWorks

              Dim swModel                 As SldWorks.ModelDoc2

              Dim swFeatMgr               As SldWorks.FeatureManager

              Dim swScaleFeat             As SldWorks.Feature

              Dim swScale                 As SldWorks.ScaleFeatureData

              Dim sFileName               As String

           

              Set swApp = CreateObject("SldWorks.Application")

              Set swModel = swApp.ActiveDoc

              Set swFeatMgr = swModel.FeatureManager

           

              sFileName = Mid(swModel.GetPathName, InStrRev(swModel.GetPathName, "\") + 1)

              sFileName = Left(sFileName, InStrRev(sFileName, ".") - 1)

           

              sFileName = "C:\temp\" & sFileName & " StlFormat.STL"

           

              Set swScaleFeat = swFeatMgr.InsertScale(swScaleAboutCentroid, False, 1.01, 1.02, 1.03)

              swModel.ClearSelection2 True

              swModel.SaveAs3 sFileName, 0, 0

           

          End Sub

           

          The reason program 2 doesn't work for you is because scale feature is still selected and hence STL export fails. Once you clear that STL export works fine.