You could try to write code that patches the hole and then create a new hole. But i think it will become very difficult very fast. i would like to suggest 2 iLogic rules. "M5 -> 2mm" and "2mm -> M5". it would work like this:
- when you want to export then you run the rule "M5 -> 2mm" that will save the threat information in an attribute. (by saving the info in an attribute it will be saved in the part and you can get the info in a later point in time back. also if inventor was closed.) and after that changes the holes to 2 mm.
- Then you can do your exports with holes of 2mm in you flat pattern (and in the normal part)
- when you are ready you run the rule "2mm -> M5" and all holes are set back to there original state.
(ofcource you could automate this steps.)
here are the 2 rules
[iLogic: "M5 -> 2mm"]
Public Sub Main()
Dim doc As PartDocument = ThisApplication.ActiveDocument
Dim holeFeatures As HoleFeatures = doc.ComponentDefinition.Features.HoleFeatures
For Each hole As HoleFeature In holeFeatures
If hole.Tapped Then
' save tape info in attribute
Dim tapInfo As HoleTapInfo = hole.TapInfo
If hole.AttributeSets.NameIsUsed("tapInfo") = False Then
hole.AttributeSets.Add("tapInfo")
End If
Dim attributeSet = hole.AttributeSets.Item("tapInfo")
addAttribute(attributeSet, "RightHanded", tapInfo.RightHanded)
addAttribute(attributeSet, "ThreadType", tapInfo.ThreadType)
addAttribute(attributeSet, "ThreadDesignation", tapInfo.ThreadDesignation)
addAttribute(attributeSet, "Class", tapInfo.Class)
addAttribute(attributeSet, "FullTapDepth", tapInfo.FullTapDepth)
If (tapInfo.FullTapDepth = False) Then
addAttribute(attributeSet, "ThreadDepth", tapInfo.ThreadDepth.Value)
End If
hole.Tapped = False
hole.HoleDiameter.Value = 0.2 'cm
End If
Next
doc.update()
End Sub
Private Sub addAttribute(attSet As AttributeSet, name As String, value As String)
If attSet.NameIsUsed(name) Then
attSet.Item(name).Value = value
Else
attSet.Add(name, ValueTypeEnum.kStringType, value)
End If
End Sub
[iLogic: "2mm -> M5"]
Dim doc As PartDocument = ThisApplication.ActiveDocument
Dim holeFeatures As HoleFeatures = doc.ComponentDefinition.Features.HoleFeatures
For Each hole As HoleFeature In holeFeatures
If (hole.HoleDiameter.Value = 0.2) Then
If (hole.AttributeSets.NameIsUsed("tapInfo")) Then
Dim attributeSet As AttributeSet = hole.AttributeSets.Item("tapInfo")
Dim RightHanded = attributeSet.Item("RightHanded").Value
Dim ThreadType = attributeSet.Item("ThreadType").Value
Dim ThreadDesignation = attributeSet.Item("ThreadDesignation").Value
Dim ThreadClass = attributeSet.Item("Class").Value
Dim FullTapDepth = attributeSet.Item("FullTapDepth").Value
Dim tapInfo = doc.ComponentDefinition.Features.HoleFeatures.CreateTapInfo(
If(RightHanded.Equals("True"), True, False),
ThreadType,
ThreadDesignation,
ThreadClass,
True)
hole.TapInfo = tapInfo
Dim fullTapDepthBool As Boolean = If(FullTapDepth.Equals("True"), True, False)
If fullTapDepthBool = False Then
Dim threadDepthString As String = attributeSet.Item("ThreadDepth").Value
' TODO add code to create ThreadDepth parameter ad set it.
'tapInfo.ThreadDepth = [New Parameter]
'tapInfo.FullTapDepth = False
End If
End If
End If
Next
i did not manage to set the ThreadDepth back to its original state. (you need to create a parameter for the ThreadDepth and i dont know how.) but because you are working with sheetmetal i figured that they probaly are always full depth anyway.
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Blog: hjalte.nl - github.com