I am trying to change the Tread Designation of a Hole Feature using VBA from withing Excel.
I cannot find any documentation that indicates how this can be done directly with code.
If anyone has any ideas, I would much appreciate any suggestions.
Solved! Go to Solution.
Solved by rfink. Go to Solution.
Solved by RodrigoEiras. Go to Solution.
Hi rfink,
You can find below the code I use to do this. You may have to customize it for your own use, but I think it can be what you need as a base.
SyntaxEditor Code Snippet
'This routine assignes the thread size to the holes used in a hole feature from an imported parameter Dim ThreadSize As DoubleForEquals Dim CurrentThreadFeature As String ThreadSize=ThrSize9 'Make it equal to applicable parameter CurrentThreadFeature="GunThreadedHole" 'make it equal to applicable thread feature name 'MessageBox.Show("Thread size is "&ThreadSize,"Debugging") Select Case ThreadSize Case 0.250 '0.250 1/4" 'MessageBox.Show("ThreadSize is recognized as 0.250","Debugging") Feature.ThreadDesignation(CurrentThreadFeature) = "1/4-20 UNC" Case 0.375 '0.375 3/8" 'MessageBox.Show("ThreadSize is recognized as 0.375","Debugging") Feature.ThreadDesignation(CurrentThreadFeature) = "3/8-16 UNC" Case 0.500 '0.500 1/2" 'MessageBox.Show("ThreadSize is recognized as 0.500","Debugging") Feature.ThreadDesignation(CurrentThreadFeature) = "1/2-13 UNC" Case 0.625 '0.625 5/8" 'MessageBox.Show("ThreadSize is recognized as 0.625","Debugging") Feature.ThreadDesignation(CurrentThreadFeature) = "5/8-11 UNC" Case 0.750 '0.750 3/4" 'MessageBox.Show("ThreadSize is recognized as 0.750","Debugging") Feature.ThreadDesignation(CurrentThreadFeature) = "3/4-10 UNC" Case 0.875 '0.875 7/8" 'MessageBox.Show("ThreadSize is recognized as 0.875","Debugging") Feature.ThreadDesignation(CurrentThreadFeature) = "7/8-9 UNC" Case 1.000 '1.000 1" 'MessageBox.Show("ThreadSize is recognized as 1.000","Debugging") Feature.ThreadDesignation(CurrentThreadFeature) = "1-8 UNC" Case 1.125 '1.125 1 1/8" 'MessageBox.Show("ThreadSize is recognized as 1.125","Debugging") Feature.ThreadDesignation(CurrentThreadFeature) = "1 1/8-7 UNC" Case 1.250 '1.250 1 1/4" 'MessageBox.Show("ThreadSize is recognized as 1.250","Debugging") Feature.ThreadDesignation(CurrentThreadFeature) = "1 1/4-7 UNC" Case 1.375 '1.375 1 3/8" 'MessageBox.Show("ThreadSize is recognized as 1.375","Debugging") Feature.ThreadDesignation(CurrentThreadFeature) = "1 3/8-6 UNC" Case 1.500 '1.500 1 1/2" 'MessageBox.Show("ThreadSize is recognized as 1.500","Debugging") Feature.ThreadDesignation(CurrentThreadFeature) = "1 1/2-6 UNC" Case Else MessageBox.Show("ThreadSize not recognized","Debugging") End Select InventorVb.DocumentUpdate()
Rodrigo,
Thanks for the reply. I need to change the thread designation for a hole feature which is a different object than a thread feature. However, I figured-out how to do this as follows:
oFeature.TapInfo = oHoleFeatures.CreateTapInfo(True, oThreadType, oThreadDesignation, oThreadClass, True)
Thanks for you reply. I can use the code for thread features when they are applied as a seperate object.
Ross