Update threads in an old part to the current design data (thread.xls)

Update threads in an old part to the current design data (thread.xls)

mr_ensing
Advocate Advocate
491 Views
5 Replies
Message 1 of 6

Update threads in an old part to the current design data (thread.xls)

mr_ensing
Advocate
Advocate

At some point in time we customised thread.xls in the design data. The value we changed is Tap Drill Diameter.

 

Now and then we run into an older part. Changes to thread size of new features in the old part still use tap drill diameter dimensions according old design data. So, it seems the thread information is stored somewhere in the part file.

 

Changing the tap drill diameter for the one hole isn't really that hard:

 

Dim pDoc As PartDocument
Set pDoc = ThisApplication.ActiveDocument
Debug.Print pDoc.ComponentDefinition.Features.HoleFeatures.item(1).TapInfo.TapDrillDiameter

 

 

But I'd like to be able to update these old parts to the new table. Can't for the life of me find where this information is stored.

 

 

 

0 Likes
492 Views
5 Replies
Replies (5)
Message 2 of 6

Michael.Navara
Advisor
Advisor

I solved this few years ago, but I forgot how. It was necessary to create new TapInfo and I don't remember I can update an existing hole feature with new TapInfo, or I need to create new one on the same place (geometry and model history). I hope the first approach is true.

All necessary information is stored in existing TapInfo.

 

Message 3 of 6

mr_ensing
Advocate
Advocate

I'm am indeed able to create a new TapInfo object. I create this object using the properties of the existing hole. This works. The object is created, and with the correct tap drill diameter (so thread.xls is involved in this operation).

 

But I can't assign this new TapInfo object to the existing Hole feature.

 

 

Private Sub ThreadFix()
    Dim pDoc As PartDocument
    Set pDoc = ThisApplication.ActiveDocument
    Dim oCompdef As PartComponentDefinition
    Set oCompdef = pDoc.ComponentDefinition
    Dim oHole As HoleFeature
    Set oHole = oCompdef.Features.HoleFeatures.item(1)
    Dim oTappedHole As HoleTapInfo
    Set oTappedHole = oHole.TapInfo

    Dim newTappedHole As HoleTapInfo
    Set newTappedHole = oCompdef.Features.HoleFeatures.CreateTapInfo( _
                                RightHanded:=oTappedHole.RightHanded, _
                                ThreadType:=oTappedHole.ThreadType, _
                                ThreadDesignation:=oTappedHole.ThreadDesignation, _
                                Class:=oTappedHole.Class, _
                                FullTapDepth:=oTappedHole.FullTapDepth)

    Set oHole.TapInfo = newTappedHole   '<~~ Nope
End Sub

 

 

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor

Usually when it won't accept the new HoleTapInfo you created, it is because it can't find a single entry (row) in the 'thread.xls' file that matches all specifications in that HoleTapInfo.  You mentioned that you have edited the thread.xls file before.  Is that file still in the same location and still named exactly the same as how it was installed by Inventor?  The location of the 'Design Data' folder is specified in 2 main locations (Project settings, & Application Options - File tab), but I don't recall seeing a separate setting that would allow you to specify a different file to use instead of this one.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 6

mr_ensing
Advocate
Advocate

Design data are at a central location. They have been for years. And it works, because all recent parts have the tap diameters we changed in the thread.xls file.

 

Also:

 

Sub ThreadFix()
    Dim pDoc As PartDocument
    Set pDoc = ThisApplication.ActiveDocument
    Dim oCompdef As PartComponentDefinition
    Set oCompdef = pDoc.ComponentDefinition
    Dim oHole As HoleFeature
    Set oHole = oCompdef.Features.HoleFeatures.item(1)
    Dim oTappedHole As HoleTapInfo
    Set oTappedHole = oHole.TapInfo
    
    oTappedHole.TapDrillDiameter = 13.37 '<~~ wrong!
    
    Debug.Print "Before: " & oTappedHole.TapDrillDiameter       'Before: 13,37

    Dim newTappedHole As HoleTapInfo
    If oTappedHole.FullTapDepth Then
        Set newTappedHole = oCompdef.Features.HoleFeatures.CreateTapInfo( _
                                    RightHanded:=oTappedHole.RightHanded, _
                                    ThreadType:=oTappedHole.ThreadType, _
                                    ThreadDesignation:=oTappedHole.ThreadDesignation, _
                                    Class:=oTappedHole.Class, _
                                    FullTapDepth:=oTappedHole.FullTapDepth)
    Else
        Set newTappedHole = oCompdef.Features.HoleFeatures.CreateTapInfo( _
                                    RightHanded:=oTappedHole.RightHanded, _
                                    ThreadType:=oTappedHole.ThreadType, _
                                    ThreadDesignation:=oTappedHole.ThreadDesignation, _
                                    Class:=oTappedHole.Class, _
                                    FullTapDepth:=oTappedHole.FullTapDepth, _
                                    ThreadDepth:=oTappedHole.ThreadDepth)
    End If
                                
    Debug.Print "'After': " & newTappedHole.TapDrillDiameter    ''After': 10,4

    Set oHole.TapInfo = newTappedHole   '<~~ Nope

 

 

The new TapInfo object has the correct tap diameter. I just can't apply it to the existing hole feature.

0 Likes
Message 6 of 6

Michael.Navara
Advisor
Advisor

You are on the right way. But you need to set the TheadDepth correctly.

 

  • oTappedHole.ThreadDepth returns Parameter object
  • CreateTapInfo method accepts string or double

Change the line to

ThreadDepth :=oTappedHole.ThreadDepth.Value 

 

Your code works for me.

0 Likes