Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HoleFeature.Tapped property

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
mrattray
515 Views, 3 Replies

HoleFeature.Tapped property

I'm trying to programatically toggle a hole between tapped and simple.  I found the Tapped property in the object browser but when I try to use it I get a "Method 'Tapped' of object 'HoleFeature' failed" error. 

 

Public Sub setThd(tap As Boolean, doc As PartDocument)

Dim hole As HoleFeature
Dim holes As HoleFeatures
Set holes = doc.ComponentDefinition.Features.HoleFeatures

For Each hole In holes
    If hole.HealthStatus <> kSuppressedHealth Then
         hole.tapped = tap
    End If
Next

End Sub

 

Any thoughts are appreciated,

Mike

Mike (not Matt) Rattray

3 REPLIES 3
Message 2 of 4
thomaskennedy
in reply to: mrattray

Hi Mike,

 

I think you need to use the TapInfo property (Tapped property just returns a true / false)

 

Create your tap info :

 

Dim oHoleTapInfo As HoleTapInfo
oHoleTapInfo = odoc.ComponentDefinition.Features.HoleFeatures.CreateTapInfo(True, "ANSI Unified Screw Threads", "7/16-14 UNC", "1B", False, "5mm")

 

Then set the property :

 

If hole.HealthStatus <> kSuppressedHealth Then          
hole.TapInfo = oHoleTapInfo
End If

 

Hope this helps!

 

Tom

Message 3 of 4
mrattray
in reply to: thomaskennedy

Thanks, Tom! That was just what I needed. For some reason I thought that method would only change the information associated with a hole that was already set to tapped and not actually make it tapped. What's odd is that the .tapped property is what's needed to switch it back to simple. I suppose Inventor needs to be re-fed the info every time it "taps" the hole?

Here's the code that worked for me if anyone wants it:

 

Public Sub setThd(tap As Boolean, doc As PartDocument, thd As String)

Dim hole As HoleFeature
Dim holes As HoleFeatures
Set holes = doc.ComponentDefinition.Features.HoleFeatures

Dim oHoleTapInfo As HoleTapInfo
If Right(Left(thd, 2), 1) = "/" Or Right(Left(thd, 3), 1) = "/" Then
Set oHoleTapInfo = holes.CreateTapInfo(True, "ANSI Unified Screw Threads", thd, "2B", True)
Else
Set oHoleTapInfo = holes.CreateTapInfo(True, "ANSI Metric M Profile", thd, "2B", True)
End If

For Each hole In holes
    If hole.HealthStatus <> kSuppressedHealth Then
        If tap = True Then
            hole.TapInfo = oHoleTapInfo
        Else
            hole.tapped = False
        End If
    End If
Next

End Sub

 

Mike (not Matt) Rattray

Message 4 of 4
HermJan.Otterman
in reply to: mrattray

Tanks,

I was struggling with this, and with this code it did not seem to work form me.

the problem was that I used a hole in my test part with linear placement, but without the reference dimensions...

in a normal part, you would always enter these reference dimensions, but for my test part I didn't and I could not change the hole with this VB-code. after entering the two dimensions it worked..

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report