Hide Table of Contents

Create and Modify Distance Chain Pattern Feature Example (VB.NET)

This example shows how to create and modify a distance chain pattern feature.

'--------------------------------------------------------
' Preconditions:
' 1. Verify that the assembly to open exists.
' 2. Open the Immediate window.
'
' Postconditions:
' 1. Opens the specified assembly.
' 2. Selects entities to create a distance chain pattern feature.
' 3. Creates the distance chain pattern feature.
' 4. After examining the graphics area and FeatureManager design
'    tree, press F5.
' 5. Modifies the distance chain pattern feature.
' 6. Examine the graphics area to verify step 5.
' 7. Examine the Immediate window.
'
' NOTE: Because the assembly is used elsewhere, do not save
' changes.
'--------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics
 
Partial Class SolidWorksMacro
 
    Public Sub main()
        Dim swModel As ModelDoc2
        Dim swModelDocExt As ModelDocExtension
        Dim swFeatureManager As FeatureManager
        Dim swFeature As Feature
        Dim swChainPatternFeatureData As ChainPatternFeatureData
        Dim status As Boolean
        Dim errors As Integer
        Dim warnings As Integer
        Dim fileName As String
 
        fileName = "C:\Program Files\SolidWorks Corp\SOLIDWORKS\samples\tutorial\api\distance linkage.sldasm"
        swModel = swApp.OpenDoc6(fileName, swDocumentTypes_e.swDocASSEMBLY, swOpenDocOptions_e.swOpenDocOptions_Silent, "", errors, warnings)
 
        'Select entities to create distance chain pattern feature
        swModelDocExt = swModel.Extension
        status = swModelDocExt.SelectByID2("Belt Drive Path""SKETCH", 0, 0, 0, True, 0, Nothing, 0)
        status = swModelDocExt.SelectByID2("Mount Base-1@distance linkage""COMPONENT", 0, 0, 0, True, 0, Nothing, 0)
        swModel.ViewZoomTo2(1.03935160466665, -0.0995602294424154, 0.846177052265487, 1.16810340243326, -0.261325308687639, 0.846177052265488)
        status = swModelDocExt.SelectByID2("""FACE", 0.187298652259415, -0.193039676915248, 0.113419833821467, True, 0, Nothing, 0)
        status = swModelDocExt.SelectByID2("Right Plane@Mount Base-1@distance linkage""PLANE", 0, 0, 0, True, 0, Nothing, 0)
        swModel.ClearSelection2(True)
        status = swModelDocExt.SelectByID2("Belt Drive Path""SKETCH", 0, 0, 0, False, 2, Nothing, 0)
        status = swModelDocExt.SelectByID2("Mount Base-1@distance linkage""COMPONENT", 0, 0, 0, True, 1, Nothing, 0)
        status = swModelDocExt.SelectByID2("""FACE", 0.187298652259415, -0.193039676915248, 0.113419833821467, True, 256, Nothing, 0)
        status = swModelDocExt.SelectByID2("Right Plane@Mount Base-1@distance linkage""PLANE", 0, 0, 0, True, 16384, Nothing, 0)
 
        'Create distance chain pattern feature
        swFeatureManager = swModel.FeatureManager
        swFeature = swFeatureManager.FeatureChainPattern(swChainPatternPitchMethod_e.swChainPatternDistance, FalseFalse, 4, 0.427720330394804, TrueFalseTrue, swChainPatternAlignment_e.swChainPatternAlignToSeed, swChainPatternOptions_e.swChainPatternDynamic)

        swModel.ClearSelection2(True)
        swModel.ViewZoomtofit2()
 
        Stop
        'Examine the graphics area and FeatureManager design tree
        'Press F5    
 
        'Modify distance chain pattern feature
        swChainPatternFeatureData = swFeature.GetDefinition
        status = swChainPatternFeatureData.AccessSelections(swModel, Nothing)
        swChainPatternFeatureData.Spacing = 0.078
        swChainPatternFeatureData.FillPath = True
        Debug.Print("Number of instances calculated by SOLIDWORKS to fill the path: " & swChainPatternFeatureData.InstanceCount)
        swFeature.ModifyDefinition(swChainPatternFeatureData, swModel, Nothing)
 
        'Examine the graphics area    
 
    End Sub
 
    ''' <summary>
    ''' The SldWorks swApp variable is pre-assigned for you.
    ''' </summary>
    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

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Create and Modify Distance Chain Pattern Feature Example (VB.NET)
*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) 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.