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: 

Toggle Hole Types with iLogic

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
STVand
557 Views, 3 Replies

Toggle Hole Types with iLogic

Hello, I am trying to write a snippet of code to do something which I thought would be simple: toggle a hole feature to be either drilled or countersunk based on user input.  However, I am getting a very vague "The parameter is incorrect." error when I try to execute this iLogic rule.  I'm guessing that I am not using the SetCSink method correctly but I have no idea how to fix the problem.  I have checked and all of the variables I am using are already initialized to positive values. Code is posted below, any help would be greatly appreciated!

 

Dim odoc As PartDocument
odoc = ThisApplication.ActiveDocument

Dim oHole As HoleFeature
oHole = odoc.ComponentDefinition.Features.HoleFeatures.Item(1)

Select Case ANCHOR_HOLE_SIZE
    Case = .25
    CSinkDia = .53125
    Case = .3125
    CSinkDia = .65625
    Case = .375
    CSinkDia = .78125
    Case = .4375
    CSinkDia = .84375
    Case = .5
    CSinkDia = .9375
    Case = .625
    CSinkDia = 1.1875
    Case = .75
    CSinkDia = 1.4375
End Select

If HOLE_TYPE = "THRU"
oHole.SetDrilled()
ElseIf HOLE_TYPE = "COUNTERSUNK"
oHole.SetCSink(CSinkDia, CSinkAng)
End If
3 REPLIES 3
Message 2 of 4
Curtis_Waguespack
in reply to: STVand

Hi STVand,

 

I'm not seeing the error when I (quickly) pasted in your code and ran it, but here is a quick iLogic example that I had on hand that sets a hole feature named Hole1 to a countersink or counterbore based on user input.

 

After posting and re-reading  your question, I realize that I've not addressed the right issue. But I'll try to have a look again tomorrow if I can.

 

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 Countersink.", "Make Counterbore", True, “iLogic")

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

If oInput = True Then
oHole.SetCSink(1 mm, 82*(PI/180)) '82 degrees
Else
oHole.SetCBore(2 mm, 1 mm)
End If

 

Message 3 of 4
STVand
in reply to: Curtis_Waguespack

Curtis, thanks for the reply.  I tried making a new part from scratch with just an extrusion and a hole feature named "Hole1" and running your iLogic rule, and I am still getting the same vague "The Parameter is Incorrect" error on running it, regardless of whether I choose countersunk or counterbored.  I have read the help docs on the API and the syntax should be correct for the SetCSink/SetCBore methods, so now I am absolutely puzzled. Smiley Frustrated

Message 4 of 4
STVand
in reply to: STVand

Solved it! After fooling around a bit with your code, I changed your "mm" to "in" (the native units of the part document) and it worked.

 

I thought i remember reading that if the object passed into the SetCSink() method didn't have units it would default to the native units, but it seems that isn't true.  The correct syntax for it is SetCSink( ### in, ###).  Without having in (or mm, or whatever unit) it errors out.  Thanks for the help!

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

Post to forums  

Autodesk Design & Make Report