3 Replies Latest reply on Feb 16, 2017 3:47 PM by Tony Bravetti

    autosize planes macro

    Tony Bravetti

      I have been trying to make a macro that will click through the default planes and turn on autosizeing, however i can't seem to get it to work for the life of me. I would think this would be a very simple macro. Here are steps i have done to make the macro:

      1. Start recording
      2. Right click each default plane and select autosize
      3. stop recording

      After doing this, the macro does nothing when run. I still have to manually go in and autosize each plane. What am i missing here?

        • Re: autosize planes macro
          Viktor Bovzdarenko

          Hi Tony,
          recorder does not capture an API for autosizing planes.
          Try looking into: IRefPlaneFeatureData.AutoSize = True
          First select your planes then get a  IRefPlaneFeatureData (can be done using IFeature:GetDefinition). IRefPlaneFeatureData has an AutoSize property.


          • Re: autosize planes macro
            Raghvendra Bhargava

            Try this: It will change all Ref plane to AutoSize


            Option Explicit


            Sub main()

                Dim swApp                   As SldWorks.SldWorks

                Dim swModel                 As SldWorks.ModelDoc2

                Dim swFeat                  As SldWorks.Feature

                Dim PlaneCount              As Long

                Dim bRet                    As Boolean


                Set swApp = Application.SldWorks

                Set swModel = swApp.ActiveDoc

                Set swFeat = swModel.FirstFeature


                Do While Not swFeat Is Nothing

                    If "RefPlane" = swFeat.GetTypeName Then

                            bRet = swFeat.Select2(False, 0)

                            swApp.RunCommand swCommands_Auto_Size, ""

                    End If

                    Set swFeat = swFeat.GetNextFeature



            End Sub