Ilogic control Threaded Hole sizes only in Flat Pattern

Ilogic control Threaded Hole sizes only in Flat Pattern

vkulikajevas
Advocate Advocate
1,265 Views
6 Replies
Message 1 of 7

Ilogic control Threaded Hole sizes only in Flat Pattern

vkulikajevas
Advocate
Advocate

I have a flat pattern with M5 holes. I need every Metric Thread Hole in Flat Pattern mode to be made as 2mm diameter holes.

Is it possible to this with Ilogic Rule?

Q_image.PNG

 

0 Likes
Accepted solutions (1)
1,266 Views
6 Replies
Replies (6)
Message 2 of 7

Darkforce_the_ilogic_guy
Advisor
Advisor

you can control your Threaded hole sizes with ilogic. but I am not sure that you want to do … can you tell more ?

0 Likes
Message 3 of 7

vkulikajevas
Advocate
Advocate

I need to override the holes in Flat pattern, so that sheet part  would have different diameter hole than in bended version. This is for laser cutting, holes must be different size than in final part. 

0 Likes
Message 4 of 7

JelteDeJong
Mentor
Mentor
Accepted solution

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:

 

  1. 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.
  2. Then you can do your exports with holes of 2mm in you flat pattern (and in the normal part)
  3. 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.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 5 of 7

vkulikajevas
Advocate
Advocate

 

JelteDeJong Thank you. I would accept your code as solution if you could make the first part of code to convert not only M5 holes to 2 mm in flat pattern but also all the other threaded holes. Because now if I have M5, M6, M10 (sometimes these thread differ too!) threads. And when making Flat pattern, I can only see M5 converted to 2 mm, and other threads are eliminated. Could this be fixed? With all threads to be shown as 2mm holes? 🙂

 

0 Likes
Message 6 of 7

vkulikajevas
Advocate
Advocate

Sorry! My Bad! Code works perfectly!

 

P.s. The Second part has error:
"Error in rule: 2 to M, in document: Exp2.ipt

Object reference not set to an instance of an object."

 

First Part of the code which converts M threads to 2 mm works perfectly.

But I figured out I will use this code on a copied parts and then discard them anyway, so I won't probably even need second part 🙂

 

Thank you!

0 Likes
Message 7 of 7

Darkforce_the_ilogic_guy
Advisor
Advisor
You cant do that ... but you might could make a illogic code that change the holes and then save the files as a dxf and then return the holes back and save the files again.
0 Likes