Hide Table of Contents

Get and Set Connection Point Feature Data Example (VB.NET)

This example shows how to get and set data for connection point features.

' Preconditions:
' 1. Ensure that the latest SolidWorks Design Library is loaded.

' 2.
Drag and drop design library > routing > electrical > db9 male.sldprt
'    into the main view.
' 3. Run (F5) this macro.
' Postconditions:
'  1. Inspect the Immediate Window.
'  2. Inspect CPoint1 in the FeatureManager design tree.
' NOTE:  Because this is a Design Library part, close it without saving changes.

Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System
Imports System.Diagnostics

Partial Class SolidWorksMacro

Sub main()

Dim Part As ModelDoc2
Dim selMgr As SelectionMgr
Dim selCount As Long
        Dim selType As Long
        Dim selObj As Object
        Dim selFeat As Feature = Nothing
        Dim vLocation As Object
        Dim xLoc As Double, yLoc As Double, zLoc As Double
        Dim boolstatus As Boolean

        Part = swApp.ActiveDoc
        selMgr = Part.SelectionManager

        boolstatus = Part.Extension.SelectByID2(
"CPoint1", "CONNECTIONPOINT", 0, 0, 0, False, 0, Nothing, 0)

        selCount = selMgr.GetSelectedObjectCount2(-1)
If (selCount > 0) Then
            selType = selMgr.GetSelectedObjectType3(1, -1)
            selObj = selMgr.GetSelectedObject6(1, -1)
If (selType = swSelectType_e.swSelCONNECTIONPOINTS) Then
                selFeat = selObj
End If
        End If


Dim featData As Object = Nothing
        If Not IsNothing(selFeat) Then
            featData = selFeat.GetDefinition()
End If
        Dim cPointData As IConnectionPointFeatureData
        cPointData = featData

If Not cPointData Is Nothing Then
            Debug.Print("Get stublength = " & cPointData.StubLength)
            cPointData.StubLength = 0.009
"Set stublength = " & cPointData.StubLength)

"Get diameter = " & cPointData.RouteDiameter)
            cPointData.RouteDiameter = 0.011
"Set diameter = " & cPointData.RouteDiameter)

"Get route type = " & cPointData.RouteType)
            cPointData.RouteType = 2
"Set route type = " & cPointData.RouteType)

"Get route sub type = " & cPointData.RouteSubType)
            cPointData.RouteSubType = 3
"Set route sub type = " & cPointData.RouteSubType)

"Get electrical Pin ID = " & cPointData.ElectricalPinID)
            cPointData.ElectricalPinID =
            Debug.Print("Set electrical Pin ID = " & cPointData.ElectricalPinID)

"Get port ID = " & cPointData.PortID)
            cPointData.PortID =
            Debug.Print("Set port ID = " & cPointData.PortID)

"Get CPoint name = " & cPointData.Name2)
            cPointData.Name2 =
            Debug.Print("Set CPoint name = " & cPointData.Name2)

            vLocation = cPointData.Location
            xLoc = vLocation(0)
            yLoc = vLocation(1)
            zLoc = vLocation(2)
"Get Location: " & xLoc & " " & yLoc & " " & zLoc)

End If
        cPointData = Nothing
        featData = Nothing
    End Sub

Public swApp As SldWorks

End Class

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 and Set Connection Point Feature Data Example (VB.NET)
*   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) 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.