Change tapped hole with iLogic

Change tapped hole with iLogic

pelzkiwi
Explorer Explorer
466 Views
1 Reply
Message 1 of 2

Change tapped hole with iLogic

pelzkiwi
Explorer
Explorer

Hi,

 

I am trying to change a tapped hole M3x0.5 to a M4x0.7 but I always get errors that I can not solve.

This is my code:

 

Dim part As PartDocument = ThisApplication.ActiveDocument

Dim hole As HoleFeature = part.ComponentDefinition.Features.HoleFeatures("Bohrung2")

Dim newThreadDesignation As String = "M4x0.7"

Dim newThreadClass As String = "6H"

Dim spreadSheetFilePath As String = "C:\Users\Public\Documents\Autodesk\Inventor 2023\Design Data\XLS\de-DE\thread.xls"

Dim spreadSheetSheetName As String = "ISO Metric profile"

Feature.SetThread(hole.Name, spreadSheetSheetName, newThreadDesignation, newThreadClass)

 

 

The error says: "The thread designation ‘M4x0.7’ is not valid." But in the thread.xls it clearly is.

 

If I enter "M3" as newThreadDesignation it works and the code changes the hole although it is not listed in the xls...

If I enter "M4", it throws the error "Incorrect parameter. (Exception of HRESULT: 0x80070057 (E_INVALIDARG))"

 

Thanks in advance for any hints.

 

 

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

Curtis_W
Consultant
Consultant

Hi @pelzkiwi 

You code worked for me just as you have it written, so I'm not sure what the issue would be.

 

But you could probably do this more simply by finding the hole in the the model tree within the editor and then right clicking on it and choosing Capture Current State as shown.

 

This will give you the iLogic code needed ( vs. the API code you're example uses).

 

Hope that helps,

Curtis

Curtis_Waguespack_0-1724678767641.png

 

EESignature

0 Likes