3 Replies Latest reply on May 26, 2016 7:58 AM by Kevin Chisholm

    Feature name in macro

    Jason Reese

      Hi.. I have a macro and when it writes the file... I'm trying to get it to include Bill of Materials1 (FeatureName = "Bill of Materials1") in the file name.. anyone have any idea? Thanks

        • Re: Feature name in macro
          Kevin Chisholm

          Hi Jason,


          This isn't the whole code just something you can use:


          Const Path As String = "C:\Save File\" 'Change Path here

          Dim sBOMName As String

          Dim sFileName As String


          'Code to get sBomName

          Set swFeat = swModel.FirstFeature

          Do While Not swFeat Is Nothing

                 If (swFeat.GetTypeName = "BomFeat") Then

                    sBOMName = swFeat.Name

                    Exit Do


                    Set swFeat = swFeat.GetNextFeature

                 End If



          'Code to get FileName Without Extension

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

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

          sFileName = Path + sFileName


          sFileName = sFileName & "_" & sBomName & ".SLDPRT" 'Change file extension as needed...


          Not sure if it's right since I just wrote this here and haven't tested it out!


          Kevin Chisholm