Hide Table of Contents

Insert Scale Feature Example (VBA)

This example shows how to insert a scale feature.

 

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

'

' Preconditions: Model document is open.

'

' Postconditiions: Model is scaled by a factor of 3.

'

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

Option Explicit

Public Enum swScaleType_e

    swScaleAboutCentroid = 0

    swScaleAboutOrigin = 1

    swScaleAboutCoordinateSystem = 2

End Enum

Public Enum swFeatureError_e

    swFeatureErrorNone = 0                                  '  No error

    swFeatureErrorUnknown = 1                               '  Unknown error

    swFeatureErrorFilletNoLoop = 10                         '  Loop for fillet/chamfer does not exist

    swFeatureErrorFilletNoFace = 11                         '  face for fillet/chamfer does not exist

    swFeatureErrorFilletInvalidRadius = 12                  '  invalid fillet radius or a face blend fillet recommended

    swFeatureErrorFilletNoEdge = 13                         '  Edge for fillet/chamfer does not exist

    swFeatureErrorFilletModelGeometry = 14                  '  Failed to create fillet due to model geometry

    swFeatureErrorFilletRadiusTooSmall = 15                 '  Radius value is too small

    swFeatureErrorFilletCannotExtend = 16                   '  Selected elements cannot be extended to intersect

    swFeatureErrorFilletRadiusEliminateElement = 17         '  Specified radius would eliminate one of the elements

    swFeatureErrorFilletRadiusTooBig = 18                   '  Radius is too big or the elements are tangent or nearly tangent

    swFeatureErrorFilletRadiusTooBig2 = 19                  '  The radius of the fillet is too large to fit the surrounding geometry. Try adjusting the input geometry and radius values or try using a face blend fillet.

    swFeatureErrorExtrusionDisjoint = 30                    '  This feature would create a disjoint body. The direction may be wrong

    swFeatureErrorExtrusionNoEndFound = 31                  '  Cannot locate end of feature

    swFeatureErrorExtrusionBadGeometricConditions = 32      '  Unable to create this extruded feature due to geometric conditions

    swFeatureErrorExtrusionCutContourOpenAndClosed = 33     '  Extruded cuts cannot have both open and closed contours

    swFeatureErrorExtrusionCutContourInvalid = 34           '  Extruded cuts require at least one closed or open contour which does not self-intersect

    swFeatureErrorExtrusionOpenCutContourInvalid = 35       '  Open extruded cuts require a single open contour which does not self-intersect

    swFeatureErrorExtrusionBossContourOpenAndClosed = 36    '  Bosses cannot have both open and closed contours

    swFeatureErrorExtrusionBossContourInvalid = 37          '  Bosses require one or more closed contours which do not self-intersect

End Enum

Sub main()

    Dim swApp                   As SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Dim swFeatMgr               As SldWorks.FeatureManager

    Dim swScaleFeat             As SldWorks.feature

    Dim swScale                 As SldWorks.ScaleFeatureData

    Dim bRet                    As Boolean

    

    Set swApp = CreateObject("SldWorks.Application")

    Set swModel = swApp.ActiveDoc

    Set swFeatMgr = swModel.FeatureManager

    Set swScaleFeat = swFeatMgr.InsertScale(swScaleAboutOrigin, True, 3, 3, 3)

    

    If swScaleFeat Is Nothing Then Exit Sub

    

    Set swScale = swScaleFeat.GetDefinition

    

    Debug.Print "File = " & swModel.GetPathName

    Debug.Print "  Scale = " & swScaleFeat.Name

    Debug.Print "    Error = " & swScaleFeat.GetErrorCode

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:   Insert Scale Feature 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) 2013 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.