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: 

Automation of Inventor with VBA from Excel Hole Feature Thread Designation

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
rfink
1192 Views, 2 Replies

Automation of Inventor with VBA from Excel Hole Feature Thread Designation

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.

 

 

2 REPLIES 2
Message 2 of 3
RodrigoEiras
in reply to: rfink

 

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()

 

 

Message 3 of 3
rfink
in reply to: RodrigoEiras

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

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

Post to forums  

Autodesk Design & Make Report