Hide Table of Contents

Access Data Example (VBA)

View Code

All features have a feature data object that contains specific information about each instance of the feature.  For example, an extrude feature contains an IExtrudeFeatureData2 object that contains the parameters for the extrude’s depth. The IExtrudeFeatureData2::AccessSelections method is called to allow a program to modify a feature data object.  After making the changes, call IFeature::ModifyDefinition to implement the changes to the feature and release control of the feature data object. A call to IExtrudeFeatureData2::ReleaseSelectionAccess also releases control of the feature data object.

This example shows how to access and modify the data specific to a certain feature in a SOLIDWORKS part or assembly. To use this example, open a part with a base extrusion and select the base extrusion.

  1. Attach the program to SOLIDWORKS, get the active model, and access the ISelectionManager.

    Set swApp = CreateObject("sldWorks.application")

    Set Model = swApp.ActiveDoc

    Set SelMgr = Model.SelectionManager

     

  2. Obtain the selected feature, and extract the feature data Object from the feature.

    Set CurFeature = SelMgr.GetSelectedObject5(1)

    Set FeatData = CurFeature.GetDefinition

     

  3. Get the permissions to access the parameters of the feature.

    isGood = FeatData.AccessSelections(Model, Component)

     

  4. Modify the feature data, in this case double the depth of the extrude.

    Depth = FeatData.GetDepth(True)

    FeatData.SetDepth True, Depth * 2

     

  5. Implement the changes in the model.

    isGood = CurFeature.ModifyDefinition(FeatData, Model, Component)

     

  6. If the Feature::ModifyDefinition call fails for any reason, release the access permissions for the feature data.

    FeatData.ReleaseSelectionAccess

     

  7.  



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:   Access Selections 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) 2015 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.