Hi,
I'm trying to create a rectangle sketch at a height (Z is variable) and I can't seem to figure out how to do it using the SolidWorks API.
I can get the X and Y coordinates to change. But the rectangles are always created a the Z=0 plane.
My MWE is below:
Option Explicit Sub main() temp End Sub Function temp() ' Get access to document Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swSketchMgr As SldWorks.SketchManager Set swApp = Application.SldWorks Set swModel = swApp.NewPart Set swSketchMgr = swModel.SketchManager ' !!! Warning: Reactangles not being created at the correct height!!!! Dim vSkLines As Variant vSkLines = swSketchMgr.Create3PointCornerRectangle(-0.5, -0.5, -0.5, _ 0.5, 0.5, -0.5, _ 0.5, -0.5, -0.5) vSkLines = swSketchMgr.Create3PointCornerRectangle(-1.5, -1.5, 1.5, _ 1.5, 1.5, 1.5, _ 1.5, -1.5, 1.5) ' Close the sketch and rebuild swSketchMgr.InsertSketch True ' Zoom To Fit swModel.ViewZoomtofit2 End Function
Any help would be appreciated. Thanks!