SolidWorksMakroprogrammierung

Methode · WizardHoleFeatureData2

InitializeHole-Methode (WizardHoleFeatureData2)

Belegt eine neu angelegte Definition für eine Bohrung aus dem Bohrungsassistenten mit Art, Norm, Schraube, Größe und Endbedingung vor.

Syntax

Sub InitializeHole( _
   ByVal GenericHoleType As Long, _
   ByVal StdIndex As Long, _
   ByVal FastnerType As Long, _
   ByVal SSize As String, _
   ByVal EndType As Long _
)
swWzd.InitializeHole swWzdCounterBore, swStandardISO, swStandardISOHexBolt, "M8", swEndCondBlind

Parameter

GenericHoleTypeLongByVal
Die Art der Bohrung als Wert aus swWzdGeneralHoleTypes_e, etwa swWzdCounterBore.
StdIndexLongByVal
Die Norm als Wert aus swWzdHoleStandards_e, etwa swStandardISO.
FastnerTypeLongByVal
Der Schraubentyp als Wert aus swWzdHoleStandardFastenerTypes_e, etwa swStandardISOHexBolt.
SSizeStringByVal
Die Größe, etwa "M8".
EndTypeLongByVal
Die Endbedingung als Wert aus swEndConditions_e, etwa swEndCondBlind.

Beispiel

' Vorbedingung: Ein Teil ist offen, eine ebene Fläche ist ausgewählt.
' Ergebnis:     Auf der Fläche entsteht eine Bohrung mit Flachsenkung für M8, 15 mm tief.
Option Explicit

Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swFeatMgr As SldWorks.FeatureManager
    Dim swWzd As SldWorks.WizardHoleFeatureData2
    Dim swFeat As SldWorks.Feature

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    If swModel Is Nothing Then Exit Sub
    Set swFeatMgr = swModel.FeatureManager

    Set swWzd = swFeatMgr.CreateDefinition(swFmHoleWzd)
    swWzd.InitializeHole swWzdCounterBore, swStandardISO, swStandardISOHexBolt, "M8", swEndCondBlind
    swWzd.HoleDepth = 0.015

    Set swFeat = swFeatMgr.CreateFeature(swWzd)
    If swFeat Is Nothing Then
        Debug.Print "Bohrung nicht erstellt."
    Else
        Debug.Print "Erstellt: " & swFeat.Name
    End If
End Sub

Bemerkungen

Der Ablauf folgt der Hilfe („Hole Wizard Features and WizardHoleFeatureData2 Objects“): Definition mit FeatureManager.CreateDefinition und swFmHoleWzd anlegen, mit InitializeHole vorbelegen, Werte ändern, die Fläche auswählen und die Bohrung mit FeatureManager.CreateFeature erstellen. Das Hilfebeispiel „Create Hole Wizard Feature Data Object and Hole Wizard Feature“ wählt die Fläche erst nach dem Setzen der Werte mit SelectByID2 aus.

Der Parameter heißt in der Hilfe FastnerType, ohne zweites e.

Eine einfache Bohrung mit swWzdHole, swStandardISODrillSizes und der Größe "Ø10.0" entsteht auf diesem Weg nicht: FeatureManager.CreateFeature liefert dann Nothing.

Siehe auch

Verfügbarkeit

SOLIDWORKS 2006

Englisches Original: IWizardHoleFeatureData2::InitializeHole in der SOLIDWORKS API-Hilfe ↗ (dort mit dem .NET-Namen)

Fragen zu diesem Befehl oder ein Befehl fehlt? Frag im Discord.