Change hole type with iLogic

Change hole type with iLogic

Anonymous
Not applicable
1,173 Views
3 Replies
Message 1 of 4

Change hole type with iLogic

Anonymous
Not applicable

I have an iLogic form to modify some features of a part. See the attached image. I want to program the HoleType drop down to change the hole type from CSink to CBore. I can not figure out how to do this. Can someone show me an example please? Thanks!

 

iLogicForm.jpg

0 Likes
Accepted solutions (1)
1,174 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Here is the code I have so far. I am getting a parameter is incorrect error. I think the issue is if the original hole is set to CSink then the CboreDepth Parameter does not exist yet. That parameter will only exist if the hole was a CBore. If i set the orinignasl hole to CBore then I have the same issue with ChamferAngle not being a parameter as ChamferAngle is a parameter of the CSink.

 

Dim partDoc As PartDocument
partDoc = ThisApplication.ActiveDocument
Dim partDef As PartComponentDefinition
partDef = partDoc.ComponentDefinition
Dim hole As HoleFeature
hole = ThisDoc.Document.ComponentDefinition.Features.Item("Hole2")

    If HoleType = "CBore" Then
        hole.SetCBore(ScrewHeadDiameter, CBoreDepth)
	Else If HoleType = "CSink" Then
        hole.SetCSink(ScrewHeadDiameter, ChamferAngle)
	Else If HoleType = "SpotFace" Then
        hole.SetSpotFace(ScrewHeadDiameter, CBoreDepth)
	Else If HoleType = "Drilled" Then
        hole.SetDrilled()
    End If
0 Likes
Message 3 of 4

Anonymous
Not applicable

I have also tried replacing the parameter names with actual numbers and I still get the same error.

hole.SetCBore(0.2 in, 0.0625 in)

 

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

I figured out my problem. I had to use strings instead of actual numbers.

 

the documentation says: (See Red Text)

CBoreDiameter Input Variant that defines the diameter of the counterbore. This can be either a numeric value or a string. A parameter for this value will be created and the supplied string or value is assigned to the parameter. If a value is input, the units are centimeters. If a string is input, the units can be specified as part of the string or it will default to the current length units. 

 

The code I'm using that works:

Trigger = HoleType

Dim partDoc As PartDocument
partDoc = ThisApplication.ActiveDocument
Dim partDef As PartComponentDefinition
partDef = partDoc.ComponentDefinition
Dim hole As HoleFeature
hole = partDef.Features.Item("Hole2")


    If HoleType = "CBore" Then
        hole.SetCBore("0.2 in", "0.0625 in")
	Else If HoleType = "CSink" Then
        hole.SetCSink("0.2 in", "82 deg")
	Else If HoleType = "SpotFace" Then
        hole.SetSpotFace("0.2 in", "0.0625 in")
	Else If HoleType = "Drilled" Then
        hole.SetDrilled()
    End If
0 Likes