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: 

Change a tapped hole from through to blind using iLogic?

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
958 Views, 8 Replies

Change a tapped hole from through to blind using iLogic?

Does anyone know how to change a tapped hole from being tapped through (tapped through hole) to being a tapped blind hole with dimensions for the tap drill depth and thread depth using iLogic or A.P.I.?

 

I would like to be able to switch back and forth between the two different types of tapped holes (through & blind), per whatever is required by the iLogic .ipt that is generated by user inputs.

 

Does this make sense to anyone?

8 REPLIES 8
Message 2 of 9
Curtis_Waguespack
in reply to: Anonymous

Hi LOONYLEN,

 

Here is an iLogic example that will make an hole feature named Hole1 through or blind hole depending upon user input.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

oInput = InputRadioBox _
("Select one:", "Make Hole1 a through hole.", "Make Hole1 a blind hole", True, “iLogic")

Dim oHoleFeat As HoleFeature
oHoleFeat = ThisDoc.Document.ComponentDefinition.Features.Item("Hole1")

If oInput = True Then
‘SetThroughAllExtent(ExtentDirection)
oHoleFeat.SetThroughAllExtent(kPositiveExtentDirection)
Else
‘ SetDistanceExtent(Depth, ExtentDirection, FlatBottom, BottomTipAngle )
oHoleFeat.SetDistanceExtent (“10 cm”, kPositiveExtentDirection, False, “118 deg”)
End If

 

Message 3 of 9
cwhetten
in reply to: Anonymous

I came up with a similar solution to Curtis, with slight differences in the method of user input.  In addition to changing the hole extent type (Through All <--> Distance), the code below also controls the thread depth.

 

'Get the hole feature
oHole1 = ThisDoc.Document.ComponentDefinition.Features.HoleFeatures.Item("Name_of_hole_feature_here")

'Set drill depth and thread depth
sDrillDepth = "0.099 in"
sThreadDepth = "0.075 in"

'I created a user parameter called 'HoleType' whose value
'	could be either "THRU" or "BLIND". Your usage will vary.
Select Case HoleType Case "THRU" oHole1.SetThroughAllExtent(PartFeatureExtentDirectionEnum.kPositiveExtentDirection) oHole1.TapInfo.FullTapDepth = True Case "BLIND" oHole1.TapInfo.FullTapDepth = False oHole1.TapInfo.ThreadDepth.Expression = sThreadDepth oHole1.SetDistanceExtent( sDrillDepth, PartFeatureExtentDirectionEnum.kPositiveExtentDirection, True) End Select

 

Give it a try and post back with any further questions.

 

Cameron Whetten
Inventor 2014

 

Message 4 of 9
philippe.leefsma
in reply to: cwhetten

The two previous responses are correct. In any case you will have to use some of the SetXXX methods available on the HoleFeature object. That will allow you to change the feature definition and access the properties if needed. We don't have a specific example illustrating exactly what you are looking for unfortunately, but it may help to use the UI to make the changes and observe the feature properties before and after using the API.

 

Hope that helps.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 5 of 9
Anonymous
in reply to: cwhetten

Sorry that it took me so long to get back to you guys on this.
I was working on another part of the same project and was unable to break away to try this code.

So, I tried the code that you provided and I'm receiving the following error:

System.Runtime.InteropServices.COMException (0x80020003): Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

I did correctly replace the "Your hole name here." with the hole name as it appears in my browser.

I have stabalized this hole's name, would that return this error?


Any ideas?

Message 6 of 9
Anonymous
in reply to: cwhetten

Ok guys so, I got the code working for what I need by modifying the code.

 

This is what I used:

 

Dim Holetype As HoleFeature
HoleType = ThisDoc.Document.ComponentDefinition.Features.Item("ANTI_ROTATION_KEY_SCREW_THREAD")

If ANTI_ROTATION_SCREW_HOLE_TYPE = "THRU" Then

	HoleType.SetThroughAllExtent(PartFeatureExtentDirectionEnum.kPositiveExtentDirection)
	HoleType.TapInfo.FullTapDepth = True
	
ElseIf ANTI_ROTATION_SCREW_HOLE_TYPE = "BLIND" Then

	HoleType.TapInfo.FullTapDepth = False
	Holetype.SetDistanceExtent("1.0", PartFeatureExtentDirectionEnum.kPositiveExtentDirection, True)
	
End If
RuleParametersOutput()
InventorVb.DocumentUpdate()

 The issue that I'm having now is that the hole is "Thru" my entire model. I guess what I needed was the "Thru To" (surface?) option, rather than the "Thru All" option.

 

My model is basically a donut.

It has an o.d. and i.d. and a circumferential groove approximately 3/4 of the thickness deep.

My hole is drilled from the o.d. and I wish the hole to only go thru the o.d. to the track on one side.

This code is sending the hole "thru" the entire part.

 

Please see below:

 

Thru_Hole.png

 

Is there a way to stop the hole as if I picked a "To" surface or feature?

 

Thanks,

 

Len

Message 7 of 9
philippe.leefsma
in reply to: Anonymous

HoleFeature.SetToFaceExtent

 

Read the help for more details and to check all available methods on your hole object.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 8 of 9
Anonymous
in reply to: philippe.leefsma

Ok so, I found the help file.

How do I input the required values into the following line:

Sub SetToFaceExtent(ToFace As IDispatch, ExtendToFace As VARIANT_BOOL)

What does iDispatch mean? Do I need to enter some value for the VARIANT_BOOL as well.

I apologize but, I'm just not that familiar with these two terms.
Little help?

Message 9 of 9
philippe.leefsma
in reply to: Anonymous

IDispatch is a general interface, meaning the argument can be of multiple types. Read the doc, it is mentioned which types are accepted.

 

Yes you also need to provide the boolean argument as it doesn't seem to be optional.

 

HoleFeature.SetToFaceExtent Method

 

Parent Object: HoleFeature

 

Description

 

Method that specifies the termination type for the hole feature. Hole features can be specified to terminate at a particular distance or object, or can be specified as "through all," which means it extends through all faces of the feature. This method defines the hole's termination at a particular face.

 

Syntax

HoleFeature.SetToFaceExtent( ToFace As Object, ExtendToFace As Boolean )

 

Parameters

Name Description
ToFace Input Object that defines the 'to face.' This can be either a Face or WorkPlane object.
ExtendToFace Input Boolean that specifies whether to extend to the face.

 

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report