3 Replies Latest reply on Mar 10, 2015 2:12 PM by Jared Conway

    Solidworks Motion study

    Sinisa Tucev

      I'm actually sutudiing in a High School  www.heig-vd.ch in mechanics.

       

      I have a question about, how to get a point on a curve (Simulation plot) when we make a simulation on a motion sutdy. (sorry for my English)

       

      Solidworks motion study.jpg

       

      I want to make a macro which take the graph and make a curve in the original part.

       

      Here is the VBA code of this Macro:

       

      Dim swApp As SldWorks.SldWorks

      Dim Part As Object

      Dim boolstatus As Boolean

      Dim longstatus As Long, longwarnings As Long

       

      Sub main()

       

         Set swApp = Application.SldWorks

        

         Set Part = swApp.ActiveDoc

       

      'Here I select the Graph

        boolstatus = Part.Extension.SelectByID2("Graphe2", "SIMULATION_PLOT", 0, 0, 0, False, 0, Nothing, 0)

       

      'Insertion of points in the original part

        Part.InsertCurveFileBegin

       

      'But here I don't know how to get all those X,Y,Z points ???? from the curve.......

        boolstatus = Part.InsertCurveFilePoint(8.49277535766729E-04, -9.58758450970633E-02, -3.81913693374684E-03)

        boolstatus = Part.InsertCurveFilePoint(-1.03664557898128E-02, -9.52258286678357E-02, -1.05637297278833E-02)

        boolstatus = Part.InsertCurveFilePoint(-2.09308265729608E-02, -9.49583771440244E-02, -1.88608808268481E-02)

        boolstatus = Part.InsertCurveFilePoint(-3.01800365443344E-02, -9.34951910097529E-02, -2.95012226702582E-02)

        boolstatus = Part.InsertCurveFilePoint(-3.75329238252171E-02, -8.88983591281608E-02, -0.042197426671536)

        boolstatus = Part.InsertCurveFilePoint(-4.25274794657235E-02, -7.94942822259338E-02, -5.55079426495783E-02)

        boolstatus = Part.InsertCurveFilePoint(-4.48498771662697E-02, -6.44643115226795E-02, -6.70868444920563E-02)

        boolstatus = Part.InsertCurveFilePoint(-4.43541921381491E-02, -4.42448891845181E-02, -7.42046826115261E-02)

        boolstatus = Part.InsertCurveFilePoint(-4.10715700946806E-02, -2.06257841537992E-02, -7.44152297537542E-02)

        boolstatus = Part.InsertCurveFilePoint(-3.52082702514947E-02, 3.49083554508814E-03, -6.62037092059518E-02)

        boolstatus = Part.InsertCurveFilePoint(-2.71327053014471E-02, 2.46235739065967E-02, -4.94534365202919E-02)

        boolstatus = Part.InsertCurveFilePoint(-1.73522926901998E-02, 3.94169328595304E-02, -2.56096590199844E-02)

        boolstatus = Part.InsertCurveFilePoint(-6.48157171195879E-03, 4.53537641706839E-02, 2.50841948786716E-03)

        boolstatus = Part.InsertCurveFilePoint(4.79641025449794E-03, 4.13061888555082E-02, 3.12115802707154E-02)

        boolstatus = Part.InsertCurveFilePoint(1.57730161247016E-02, 0.027793204788031, 5.66479868927881E-02)

        boolstatus = Part.InsertCurveFilePoint(2.57585453826948E-02, 6.88259938595797E-03, 7.55519351096995E-02)

        boolstatus = Part.InsertCurveFilePoint(0.03412557050099, -1.82404713642512E-02, 8.58615517690267E-02)

        boolstatus = Part.InsertCurveFilePoint(4.03483605196388E-02, -4.39365441172893E-02, 8.70645827681459E-02)

        boolstatus = Part.InsertCurveFilePoint(0.044035914655949, -6.68503652959424E-02, 0.080197049813449)

        boolstatus = Part.InsertCurveFilePoint(4.49565303216605E-02, -8.45523337086454E-02, 6.75031552681029E-02)

        boolstatus = Part.InsertCurveFilePoint(4.30523618487093E-02, -9.59360348993781E-02, 5.18458353730469E-02)

        boolstatus = Part.InsertCurveFilePoint(3.84430551452924E-02, -0.101286310234585, 3.60159358500266E-02)

        boolstatus = Part.InsertCurveFilePoint(3.14182299034301E-02, -0.102013942654673, 2.21098155614904E-02)

        boolstatus = Part.InsertCurveFilePoint(2.24192817285682E-02, -0.100134837325834, 1.11250767189772E-02)

        boolstatus = Part.InsertCurveFilePoint(1.20116476303499E-02, -9.76333364261334E-02, 2.86724809572605E-03)

        boolstatus = Part.InsertCurveFilePoint(8.49277535767089E-04, -9.58758450970633E-02, -3.81913693374662E-03)

        boolstatus = Part.InsertCurveFileEnd()

        

      End Sub

       

      I Hope that I have clearly explaind my problem and what I want to do.

       

      Thanks for your help.