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
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.