I was wondering if anyone could help me in finishing this macro. I have built a set of line segments I wish to connect with the boundary surface tool. I have a midpoint of each line in Excel A1-A31, B, and C. A is the x coordinate, B is the y coordinate, and C is the z coordinate for picking the edge for Surface Boundary Connections.

Here is a picture of the Excel with midpoints in the first three columns, and the lines in the SolidWorks Part File.

I feel like I need to do a boolstatus = swModelDocExt.SelectByID2("", EDGE", x31, y31, z31, True, 2, Nothing, 0) at the end of the macro before it reaches the final line segment which is row 31 in my Excel Document. Does anyone see what I could improve or how to finish this?

Here is the macro that I have tried to build.

Option Explicit

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swSketchMgr As SldWorks.SketchManager

Dim swExcel As Excel.Application

Dim exSheet As Excel.Worksheet

Dim swSelMgr As SldWorks.SelectionMgr

Dim SwModelDocExt As SldWorks.ModelDocExtension

Dim swFeatMgr As SldWorks.FeatureManager

Dim i As Integer

Dim xpt As Double

Dim ypt As Double

Dim zpt As Double

Dim boolstatus As Boolean

Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set swExcel = GetObject(, "Excel.Application")

Set exSheet = swExcel.ActiveSheet

swModel.ClearSelection2 True

Set swSelMgr = swModel.SelectionManager

Set SwModelDocExt = swModel.Extension

i = 1

Do While exSheet.Cells(i, 1).Value <> ""

xpt = exSheet.Cells(i, 1).Value / 1000

ypt = exSheet.Cells(i, 2).Value / 1000

zpt = exSheet.Cells(i, 3).Value / 1000

boolstatus = SwModelDocExt.SelectByID2("", "EDGE", xpt, ypt, zpt, False, 1, Nothing, 0)

i = i + 1

Loop

Set swFeatMgr = swModel.FeatureManager

swFeatMgr.SetNetBlendCurveData 0, 0, 0, 0, 1, True

swFeatMgr.SetNetBlendDirectionData 0, 32, 0, False, False

swFeatMgr.SetNetBlendCurveData 1, 0, 0, 0, 1, True

swFeatMgr.SetNetBlendDirectionData 1, 32, 0, False, False

swFeatMgr.InsertNetBlend 2, 1, 1, False, 0.0001, False, True, True, True, False, -1, -1, False, -1, False, False, -1, False, False, True

End Sub

Alex,

Interesting project. It is doubtful, however, that anyone here has the time necessary to understand your project at the depth required to help you complete it in such a general sense. My recommendation is that you break down your problem into sub-problems and then post each problem individually.

For example, if your problem is that you aren't able to create a boundary surface from a given sketch, simply post that sketch, note what entities need to be selected, and ask how a boundary surface could be created from it. If you go this route, I would recommend that you edit your original question and change the title rather than simply posting a new question.

See How to ask a good question in the API forum

Hope this helps.

Keith

SolidWorks API Training