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.

 

'----------------------------------------------

'

' Problem:

'       A face and an edge intersect in a series of points.

'

'       This code shows how to use some of the geometry-related and

'       topology-related APIs to get the intersection points.

'

' Preconditions:

'       (1) Part of assembly is open.

'       (2) Assembly is fully resolved.

'       (3) Two items are selected in the graphics window.

'       (4) Face is the first selected item.

'       (5) Edge is the second selected item.

'       (6) Face and the edge intersect.

'

' Postconditions:3D sketch is inserted with sketch points located

'        at the intersection of the face and the edge.

'

'-----------------------------------------------

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

    Debug.Assert bRet

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.GetSelectedObject5(1)

    Set swEdge = swSelMgr.GetSelectedObject5(2)

    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)

    Debug.Assert bRet

    

    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

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Get Intersecting Face and Edge Example (VBA)
*Comment:  
*   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:

x

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
x

Web Help Content Version: API Help (English only) 2012 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.