Hide Table of Contents

Create Fillet Example (VBA)

This example shows how to create a fillet on a selected edge or on every edge in a selected face:

  • Determine the selected object count

  • Get objects selected by the user

  • Determine object types

  • Create fillets

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

Public Sub GenerateFillet(ByVal FilletRadius As Double)

 

' Define variable used to hold the SldWorks object

Dim swApp As Object  

' Define variable used to hold the ModelDoc object

Dim Model As Object  

' Define variable used to hold the SelectionManager object

Dim SelMgr As Object  

' Number of objects selected by the user

Dim objCount As Long  

' Constant enumerators

Const swSelEDGES = 1 

Const swSelFACES = 2

 

 

' Attach to or open SolidWorks session

Set swApp = CreateObject("SldWorks.Application") 

 

' Grab the current document

Set Model = swApp.ActiveDoc    

 

' Get the selection manager class

Set SelMgr = Model.SelectionManager()  

 

' Convert user mm input to meters

FilletRadius = FilletRadius / 1000   

 

' Determine if anything is selected

objCount = SelMgr.GetSelectedObjectCount  

 

' If nothing selected, return error

If (objCount = 0) Then    

swApp.SendMsgToUser ("Select a face or an edge first...")

 

' Otherwise, create fillet

Else    

 

ValidSelection = 0

' For each object selected

For i = 1 To objCount   

' Determine type of object selected

objType = SelMgr.GetSelectedObjectType(i) 

If (objType <> swSelFACES) And (objType <> swSelEDGES) Then

msg = "Cannot Fillet Item #" & i

' Bad object type selected

swApp.SendMsgToUser (msg)  

Else

' Keep track of valid selections

ValidSelection = ValidSelection + 1 

End If

Next

' If at least 1 face or edge was selected

If (ValidSelection > 0) Then  

' Create the fillet

Model.FeatureFillet FilletRadius, 1, 0, 0, 0  

' End If face or edge selected

End If   

 

' End If items are selected

End If    

 

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:   Fillet Creation 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.