Inventor : Change size and thread of a hole in a form

Inventor : Change size and thread of a hole in a form

jgomis.ext
Enthusiast Enthusiast
286 Views
1 Reply
Message 1 of 2

Inventor : Change size and thread of a hole in a form

jgomis.ext
Enthusiast
Enthusiast

Hi,

I have create a part that people can modify in a form. the only problem That I have, it's than I cannot change the size and the thread of a tapped hole. Do you have any idea of how to do it in a form or with a rule ?

Thanks by advance ! I'm totaly lost :'(

 

jgomisext_0-1668778812242.png

 

0 Likes
287 Views
1 Reply
Reply (1)
Message 2 of 2

A.Acheson
Mentor
Mentor

Here is the start point for you taken from the API help. Although this will create the thread hole from scratch it still contains the receipe within to set the thread information.  You will need to change what sketch your targeting, what hole if there are multiple filter them out, add a loop to loop through all hole features unless you specifically target 1.  Like "oCompDef.Features.HoleFeatures.Item(1)"

VBA Code

'Hole Feature - Through holes '(RegularAndTapped) API Sample
'Description
'This sample demonstrates the creation 'of through holes, both regular and 'tapped.
'Code Samples
'VBA
Public Sub HoleSample()
    ' Create a new part document, using the default part template.
    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
                 ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
                    
    ' Set a reference to the component definition.
    Dim oCompDef As PartComponentDefinition
    Set oCompDef = oPartDoc.ComponentDefinition
    
    ' Create a new sketch on the X-Y work plane.
    Dim oSketch As PlanarSketch
    Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(3))

    ' Set a reference to the transient geometry object.
    Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry
    
    ' Create a rectangle on the sketch.
    Call oSketch.SketchLines.AddAsTwoPointRectangle( _
                                        oTransGeom.CreatePoint2d(0, 0), _
                                        oTransGeom.CreatePoint2d(6, 4))
                                        
    ' Create the profile.
    Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSolid
    
    ' Create an extrusion.
    Dim oExtrudeDef As ExtrudeDefinition
    Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kJoinOperation)
    Call oExtrudeDef.SetDistanceExtent("2 cm", kNegativeExtentDirection)
    Dim oExtrude As ExtrudeFeature
    Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
    
    ' Create a new sketch to contain the points that define the hole centers.
    Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(3))
    
    ' Create an object collection for the hole center points.
    Dim oHoleCenters As ObjectCollection
    Set oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection
    
    ' Add two points as hole centers.
    oHoleCenters.Add oSketch.SketchPoints.Add(oTransGeom.CreatePoint2d(1, 1))
    oHoleCenters.Add oSketch.SketchPoints.Add(oTransGeom.CreatePoint2d(5, 1))
    
    ' Create the hole feature.
    Call oCompDef.Features.HoleFeatures.AddDrilledByThroughAllExtent( _
                            oHoleCenters, "1 cm", kPositiveExtentDirection)

    ' Define tap information.

    Dim oHoleTapInfo As HoleTapInfo
    Set oHoleTapInfo = oCompDef.Features.HoleFeatures.CreateTapInfo( _
                            True, "ANSI Unified Screw Threads", _
                            "7/16-14 UNC", "1B", False, "1 cm")
                            
    ' Create a new sketch for the tapped hole centers.
    Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(3))
    
    ' Create a new object collection for the hole center points.
    Set oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection
    
    ' Add two points as hole centers.
    oHoleCenters.Add oSketch.SketchPoints.Add(oTransGeom.CreatePoint2d(1, 3))
    oHoleCenters.Add oSketch.SketchPoints.Add(oTransGeom.CreatePoint2d(5, 3))
    
    ' Create the hole feature.
    Call oCompDef.Features.HoleFeatures.AddDrilledByThroughAllExtent( _
                            oHoleCenters, oHoleTapInfo, kPositiveExtentDirection)
End Sub

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes