6 Replies Latest reply on Dec 11, 2012 8:39 AM by Patrick Ohern

    Macros, How To Pause For User Input?

    Jay Andrews

      Back in the day, it was easy in Autocad, in the macro string, the "\" key was pause for user input, so \\ in the macro would pause the macro to accept two selection clicks, say to define a selection window, or draw a line or rectangle, or \\\\\\\ would pause for seven clicks, etc..

       

      So I've recorded a simple macro.  But as I expected, the points I'm clicking are fixed defined in the macro.  I want to modify the text to pause for user input, so I can specify a zoom window, then select the two sketch segments to add the constraint to.

       

      What modifications to the macro text will accomplish this pause for user input, or whatever it would be called in the SW macro world.

       

      Thanks,

       

      Jay

       

      ' ******************************************************************************
      ' C:\DOCUME~1\Darrell\LOCALS~1\Temp\swx2396\Macro1.swb - macro recorded on 12/09/09 by Darrell
      ' ******************************************************************************
      Dim swApp As Object
      Dim Part As Object
      Dim SelMgr As Object
      Dim boolstatus As Boolean
      Dim longstatus As Long, longwarnings As Long
      Dim Feature As Object
      Sub main()

      Set swApp = Application.SldWorks

      Set Part = swApp.ActiveDoc
      Set SelMgr = Part.SelectionManager
      swApp.ActiveDoc.ActiveView.FrameState = 1
      boolstatus = Part.Extension.SelectByID2("Arc6", "SKETCHSEGMENT", 0.02652481507455, 0.03994084776917, 0.02179319999993, False, 0, Nothing, 0)
      boolstatus = Part.Extension.SelectByID2("Line2", "SKETCHSEGMENT", 0.02946594476759, 0.04002935439667, 0.02179319999993, True, 0, Nothing, 0)
      Part.SketchAddConstraints "sgTANGENT"
      Part.SketchAddConstraints "sgTANGENT"
      boolstatus = Part.Extension.SelectByID2("Line6", "SKETCHSEGMENT", 0.02331353921483, 0.02871033676265, 0.009210503515148, False, 0, Nothing, 0)
      boolstatus = Part.Extension.SelectByID2("Arc6", "SKETCHSEGMENT", 0.02666650146287, 0.0396452860887, 0.02179319999993, True, 0, Nothing, 0)
      Part.SketchAddConstraints "sgTANGENT"
      Part.SketchAddConstraints "sgTANGENT"
      Part.ViewZoomTo2 0.101294, -0.17456, -0.322429, 0.114249, -0.188729, -0.322429
      boolstatus = Part.Extension.SelectByID2("Arc4", "SKETCHSEGMENT", 0.02907155242438, -0.0320168014359, 0.03453511173954, False, 0, Nothing, 0)
      boolstatus = Part.Extension.SelectByID2("Line6", "SKETCHSEGMENT", 0.02617601207631, -0.03593785637193, 0.02179319999988, True, 0, Nothing, 0)
      Part.SketchAddConstraints "sgTANGENT"
      Part.SketchAddConstraints "sgTANGENT"
      boolstatus = Part.Extension.SelectByID2("Line4", "SKETCHSEGMENT", 0.0282801621418, -0.03930650000004, 0.02000612576148, False, 0, Nothing, 0)
      boolstatus = Part.Extension.SelectByID2("Arc4", "SKETCHSEGMENT", 0.02992089723541, -0.03257064383606, 0.03458765356008, True, 0, Nothing, 0)
      Part.SketchAddConstraints "sgTANGENT"
      Part.SketchAddConstraints "sgTANGENT"
      Part.ViewZoomtofit2
      Part.ViewZoomTo2 0.152831, -0.171406, -0.320884, 0.186028, -0.204394, -0.320884
      boolstatus = Part.Extension.SelectByID2("Arc2", "SKETCHSEGMENT", 0.09594464164793, -0.03735245406179, 0.02179319999988, False, 0, Nothing, 0)
      boolstatus = Part.Extension.SelectByID2("Line5", "SKETCHSEGMENT", 0.09601560630395, -0.03643848781803, 0.02179319999993, True, 0, Nothing, 0)
      Part.SketchAddConstraints "sgTANGENT"
      Part.SketchAddConstraints "sgTANGENT"
      boolstatus = Part.Extension.SelectByID2("Line4", "SKETCHSEGMENT", 0.09290167977004, -0.03931495245254, 0.01981570432207, False, 0, Nothing, 0)
      boolstatus = Part.Extension.SelectByID2("Arc2", "SKETCHSEGMENT", 0.09589517428111, -0.03734336508822, 0.02179319999988, True, 0, Nothing, 0)
      Part.SketchAddConstraints "sgTANGENT"
      Part.SketchAddConstraints "sgTANGENT"
      Part.ViewZoomtofit2
      Part.ViewZoomTo2 0.16171, -0.110494, -0.320915, 0.18236, -0.122175, -0.320915
      boolstatus = Part.Extension.SelectByID2("Arc8", "SKETCHSEGMENT", 0.09521715256616, 0.03993348825537, 0.02179319999993, False, 0, Nothing, 0)
      boolstatus = Part.Extension.SelectByID2("Line2", "SKETCHSEGMENT", 0.09357133607763, 0.04018711789473, 0.02179319999993, True, 0, Nothing, 0)
      Part.SketchAddConstraints "sgTANGENT"
      Part.SketchAddConstraints "sgTANGENT"
      boolstatus = Part.Extension.SelectByID2("Line5", "SKETCHSEGMENT", 0.09591937984396, 0.03685674819488, 0.02179319999988, False, 0, Nothing, 0)
      boolstatus = Part.Extension.SelectByID2("Arc8", "SKETCHSEGMENT", 0.09578078723219, 0.0393097428323, 0.02179319999993, True, 0, Nothing, 0)
      Part.SketchAddConstraints "sgTANGENT"
      Part.SketchAddConstraints "sgTANGENT"
      Part.ViewZoomtofit2
      Part.ActiveView().RotateAboutCenter -0.0116561, 0
      Part.ActiveView().RotateAboutCenter -0.0116561, 0
      Part.ActiveView().RotateAboutCenter -0.00582804, 0
      Part.ActiveView().RotateAboutCenter -0.0116561, 0
      Part.ActiveView().RotateAboutCenter -0.00582804, 0
      Part.ActiveView().RotateAboutCenter -0.0116561, 0
      Part.ActiveView().RotateAboutCenter -0.0116561, 0
      Part.ActiveView().RotateAboutCenter -0.00582804, 0
      Part.ActiveView().RotateAboutCenter -0.0116561, 0
      Part.ActiveView().RotateAboutCenter -0.00582804, 0
      Part.ActiveView().RotateAboutCenter -0.0116561, 0
      Part.ActiveView().RotateAboutCenter 0.00582804, 0
      Part.ActiveView().RotateAboutCenter 0.180669, 0.0327412
      Part.ClearSelection2 True
      End Sub