Hide Table of Contents

Get Intersecting Face and Edge Example (VBA)

This example shows how to get the intersection of a face and an edge.

NOTE: A face and an edge intersect in a series of points. This example shows how to use some of the geometry- and topology-related methods to get the intersection points.

' Preconditions:
' 1. Open a part or a fully resolved assembly.
' 2. Select an intersecting face and edge, in that
'    order, in the graphics area.
' Postconditions:
' 1. Inserts a 3D sketch with sketch points located
'    at the intersection of the face and edge.
' 2. Examine the graphics area and FeatureManager design
'    tree.
Option Explicit
Sub CreatePoints(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, vPtArray As Variant)
    Dim swSketchPt As SldWorks.SketchPoint
    Dim bRet As Boolean
    Dim i As Long
    swModel.SetAddToDB True
    swModel.Insert3DSketch2 False
    For i = 0 To UBound(vPtArray) Step 3
        Set swSketchPt = swModel.CreatePoint2(vPtArray(i + 0), vPtArray(i + 1), vPtArray(i + 2))
    Next i    
    swModel.SetAddToDB False
    swModel.Insert3DSketch2 True
    bRet = swModel.EditRebuild3
End Sub
Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swSelMgr As SldWorks.SelectionMgr
    Dim swFace As SldWorks.Face2
    Dim swSurf As SldWorks.Surface
    Dim swEdge As SldWorks.Edge
    Dim swCurve As SldWorks.Curve
    Dim vPointArray As Variant
    Dim vTArray As Variant
    Dim vUVArray As Variant
    Dim vCurveParam As Variant
    Dim vCurveBounds As Variant
    Dim nCurveBounds(0 To 5) As Double
    Dim i As Long
    Dim bRet As Boolean
    Set swApp = CreateObject("SldWorks.Application")
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swFace = swSelMgr.GetSelectedObject6(1, -1)
    Set swEdge = swSelMgr.GetSelectedObject6(2, -1)
    Set swSurf = swFace.GetSurface
    Set swCurve = swEdge.GetCurve
    vCurveParam = swEdge.GetCurveParams2
    For i = 0 To 5
        nCurveBounds(i) = vCurveParam(i)
    Next i
    vCurveBounds = nCurveBounds
    bRet = swSurf.IntersectCurve(swCurve, (vCurveBounds), vPointArray, vTArray, vUVArray)

    CreatePoints swApp, swModel, vPointArray
End Sub

Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

Subject:   Feedback on Help Topics
Page:   Get Intersecting Face and Edge Example (VBA)
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:


We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again

Web Help Content Version: API Help (English only) 2016 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.