How dont export hole with thread?

How dont export hole with thread?

Leonardo_Czuy
Advocate Advocate
567 Views
4 Replies
Message 1 of 5

How dont export hole with thread?

Leonardo_Czuy
Advocate
Advocate

Hello Everyone,

I am trying to make a code to automatize export to DXF Flat Sheet Metal. 
When i export a Sheet with thread hole.
This holes have M12, when i export with DN 12mm.

In this case, if hole have thread I would like these holes not to be exported.

Leonardo_Czuy_0-1702554208706.png

Leonardo_Czuy_1-1702554269414.png

 

For Each oRefDoc In oRefDocs
	iptPathName = Left(oRefDoc.FullDocumentName, Len(oRefDoc.FullDocumentName) - 3) & "ipt"
	If (Not System.IO.File.Exists(iptPathName)) Then Continue For
		
	Dim oDrawDoc As PartDocument
	oDrawDoc = ThisApplication.Documents.Open(iptPathName, True)
	oFileName = Left(oRefDoc.DisplayName, Len(oRefDoc.DisplayName))
	
	Dim quantidadeDePecas As String = "QTDE: " & oAsmDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(oRefDoc).Count
	
	'Set the DXF target file name
	Try
		Dim CustomName As String
		Try
			CustomName = iProperties.Value(oFileName, "Project", "Part number")
			CustomName = CustomName.replace("/", "-")
		Catch
			CustomName = oFileName
		End Try
		
		oDataMedium.FileName = oFolder & "\" & CustomName & ".dxf"
		
		Dim oCompDef As SheetMetalComponentDefinition
		oCompDef = oDrawDoc.ComponentDefinition
	

		If oCompDef.HasFlatPattern = False Then
			oCompDef.Unfold
		Else
			oCompDef.FlatPattern.Edit
		End If
		
		For Each oFeature As PartFeature In oCompDef.Features
			If oFeature.Type = kThreadFeatureObject Then
				
			End If
		Next
		
		Dim sOut As String
		sOut = "FLAT PATTERN DXF?AcadVersion=2004&" & _
		"OuterProfileLayer=CONTORNI&OuterProfileLayerColor=255;255;0&" & _
		"InteriorProfilesLayer=CONTORNI&InteriorProfilesLayerColor=255;255;0&" & _
		"TangentLayer=SOTTILI&TangentLayerColor=255;0;0&" & _
		"BendLayer=SOTTILI&BendLayerColor=255;0;0&" & _
		"BendUpLayerColor=255;0;0&BendDownLayerColor=255;0;0&" & _
		"InvisibleLayers=IV_ARC_CENTERS;IV_FEATURE_PROFILES;IV_FEATURE_PROFILES_DOWN"
		oCompDef.DataIO.WriteDataToFile(sOut, oDataMedium.FileName)
		AddDXFProperties(oDrawDoc, oDataMedium.FileName, quantidadeDePecas ,False)
		oCompDef.FlatPattern.ExitEdit
	Catch
	End Try
	oDrawDoc.Close
Next

 

0 Likes
Accepted solutions (2)
568 Views
4 Replies
Replies (4)
Message 2 of 5

yuzeaa
Advocate
Advocate
Accepted solution

This method may not look good, but it may be feasible. You can try it out

Dim threadHoles As New List(Of HoleFeature)
For Each Hole As HoleFeature In refdoc.ComponentDefinition.Features.HoleFeatures
	If Hole.HealthStatus = HealthStatusEnum.kSuppressedHealth Then Continue For
	If  Hole.TapInfo IsNot Nothing Then 
		threadHoles.Add(Hole)
		Hole.Suppressed = True
	End If
Next
'start
'export dxf
'end
For Each hole As HoleFeature In threadHoles
	hole.Suppressed = False
Next
Message 3 of 5

JelteDeJong
Mentor
Mentor
Accepted solution

It's possible to add attributes to edges. With those attributes, you can control the layer that the edge will get during export. So if assign an attribute to the edges of holes with thread, then you control the layer of those edges. If you hide those layers during export then you get what you want. 

The following iLogic rule will add attributes to edges that belong to holes with thread. You should see that they get exported to the layer "HideFromExport"

Dim setName As String = "FlatPatternAttributes"
Dim attName As String = "LayerName"
Dim attValue As String = "HideFromExport"

Dim doc As PartDocument = ThisDoc.Document
Dim def As SheetMetalComponentDefinition = doc.ComponentDefinition

Dim flatPattern = def.FlatPattern
Dim topFace = flatPattern.TopFace
Dim circuarEdges = topFace.Edges.Cast(Of Edge).Where(Function(e) e.GeometryType = CurveTypeEnum.kCircleCurve)
Dim foundEdges = ThisApplication.TransientObjects.CreateObjectCollection

For Each edge As Edge In circuarEdges

    For Each face As Face In edge.Faces
        Dim feature As PartFeature = face.CreatedByFeature
        If (TypeOf feature Is HoleFeature) Then
            Dim hole As HoleFeature = feature

            If (hole.HoleType = HoleTypeEnum.kDrilledHole) Then
                foundEdges.Add(edge)

                Dim attSet As AttributeSet = Nothing
                If (edge.AttributeSets.NameIsUsed(setName)) Then
                    attSet = edge.AttributeSets.Item(setName)
                Else
                    attSet = edge.AttributeSets.Add(setName)
                End If
                If (attSet.NameIsUsed(attName)) Then
                    Dim attribute = attSet.Item(attName).Value = attValue
                Else
                    attSet.Add(attName, ValueTypeEnum.kStringType, attValue)
                End If
            End If
        End If
    Next
Next

doc.SelectSet.Clear()
doc.SelectSet.SelectMultiple(foundEdges)
MsgBox("Found edges: " & foundEdges.Count)

There are some disadvantages to using attributes.

  • There is no way of viewing attributes with the Inventor. You need an addin to view them (like 'Nifty Attributes') or you can use my iLogic rule to change layer names. "Setting Extra Layers In DXF Exports
  • This rule will add attributes to edges but will never remove them. So I'm not sure what would happen if you change your hole type from a hole with thread and then remove the thread. It's possible that the attribute stays and your hole without thread is still removed from export.

 

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

Message 4 of 5

Leonardo_Czuy
Advocate
Advocate

Hello @JelteDeJong and @JelteDeJong, thanks a lot for helping, but have one problem

What can i do when hole is draw in sketch?

Leonardo_Czuy_0-1702567527541.png

Leonardo_Czuy_1-1702567593860.png

 

 

0 Likes
Message 5 of 5

jeremy.goenen
Advocate
Advocate

Hi, if you can commit to make the holes with a feature, be it hole, cut, extrusion or else, you could add a tag to the featurename, like "suppress" or "nodxf" and then suppress all features that include this tag like @yuzeaa proposed

 

Maybe you could use a punchtool for these holes, in this case you can define how the holes are shown in the flatpattern

https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-1A5F9CD1-80A8-4462-894A-4D8C9DFCDB51

Fanden Sie diesen Beitrag hilfreich? Fühlen Sie sich frei, diesen Beitrag zu liken.
Wurde Ihre Frage erfolgreich beantwortet? Klicken Sie dann auf die Schaltfläche LÖSUNG AKZEPTIEREN

Inventor Versionen:
2025.2