• Welcome to engineeringclicks.com
  • SW API Help!!!

    Discussion in 'SolidWorks' started by RIMACH, Apr 7, 2012.

    1. RIMACH

      RIMACH Member

      Joined:
      Apr 2010
      Posts:
      7
      Likes Received:
      0
      I need ur help with the solidworks application programming interface. I hope you can help me. I'm a SW user but i'm a novice programming here. The following code should sketch a line with 77mm long. So far this is ok but this line should be located at 1 mm from origin. This latter is no longer fulfilled. Line is sketched in the origin.

      I have a doubt, why does the line not appears like it should? If we change the highlighted value by 3, all the program performs well. Here is the code:

      Dim swApp As Object
      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

      boolstatus = Part.Extension.SelectByID2("Planta", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
      Part.SketchManager.InsertSketch True
      Part.ClearSelection2 True

      Dim skSegment As Object
      Set skSegment = Part.SketchManager.CreateLine(0#, 0.001, 0#, 0.077, 0.001, 0#)
      Part.SetPickMode
      Part.ClearSelection2 True
      Part.SketchManager.InsertSketch True

      End Sub
       
    2.  
    3. Roboeng99

      Roboeng99 New Member

      Joined:
      Apr 2012
      Posts:
      1
      Likes Received:
      0
      I have had this problem before also. For me it turned out that I had automatic relations turned on. The feature when you are sketching that makes sure when you draw two lines that the ends you want to connect actually are merged. If you turn this off it should work fine. That is why when you increase the value it seems to work.

       
    4. RIMACH

      RIMACH Member

      Joined:
      Apr 2010
      Posts:
      7
      Likes Received:
      0
      You are right, it worked well. So far i've added some code to do this automatically. Thanks!
       

    Share This Page

    1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies.
      Dismiss Notice