Limited bend line - Ilogic

Limited bend line - Ilogic

enrico.silva1
Participant Participant
1,243 Views
7 Replies
Message 1 of 8

Limited bend line - Ilogic

enrico.silva1
Participant
Participant

Hello, thanks for reading this post.

 

I am trying to export my sheet metals to DXF in order to cut on the CNC machine.
But, when export my sheet metal to DXF, the lines of bend are completed and I want to leave the bend line 15 mm apart from the base line of the piece. There is some command in Ilogic for this? Can someone help me?

 

See exemple in anex.

 

Many thanks

 

Picture with bend line completed.jpgpicture with bend line limited.jpg

0 Likes
Accepted solutions (1)
1,244 Views
7 Replies
Replies (7)
Message 2 of 8

johnsonshiue
Community Manager
Community Manager
Accepted solution

Hi! I don't believe there is an out-of-box solution to do that. The request is quite unique. Maybe you can tweak the bend line's linetype to have the similar behavior. But, I am not sure if there is a line type guarantee 15mm offset from the edge.

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 3 of 8

enrico.silva1
Participant
Participant

Okay my friend.

I gonna continue try do this.

Many thanks!

0 Likes
Message 4 of 8

davis.j
Advocate
Advocate

I am also interested if anyone has preformed this in Inventor ilogic. The 3rd party app "DXF Exporter" can do it.

I use the following Ilogic routine but it would be nice to have it trim the bend lines too.

Sub Main()
On Error GoTo ErrorHandler
	oDoc = ThisDoc.Document
	 
	If oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
	 
		Dim oCompDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition
	 
		If oCompDef.HasFlatPattern = False Then
			oCompDef.Unfold
		Else
			oCompDef.FlatPattern.Edit
		End If
			
		Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=2010" _
			+ "&OuterProfileLayer=0" _
			+ "&OuterProfileLayerColor=0 ;0 ;0" _
			+ "&InteriorProfilesLayer=0" _
			+ "&InteriorProfilesLayerColor=0 ;0 ;0" _
			+ "&BendDownLayer=Scribe" _
			+ "&BendDownLayerLineType=37633" _
			+ "&BendDownLayerColor=0 ;0 ;255" _
			+ "&BendUpLayer=Scribe" _
			+ "&BendUpLayerLineType=37633" _
			+ "&BendUpLayerColor=0 ;0 ;255" _
			+ "&InvisibleLayers=IV_FEATURE_PROFILES;IV_FEATURE_PROFILES_DOWN" _
			+ ";IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_ROLL_TANGENT;IV_ROLL;IV_TANGENT" _
			+ ";IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_UNCONSUMED_SKETCHES" _
			+ "&RebaseGeometry=True" _
			+ "&SimplifySplines=True" _
			+ "&SplineTolerance=0.01" _
			+ "&MergeProfilesIntoPolyline=True"
		
		Dim oPath As String = ThisDoc.Path

		If oPath = String.Empty Then
			MsgBox("Please save your document first.", , "iLogic Export Flat Pattern")
			Exit Sub
		End If
			
		Dim sFname As String
		Dim sfd As New SaveFileDialog
		
		dName = ThisDoc.Document.DisplayName
		sName = Left(dName, Len(dName) - 4)
		
		sfd.Filter = "DXF Files (*.dxf)|*dxf"
		sfd.InitialDirectory = oPath
	'	sfd.FileName = iProperties.Value("Project", "Part Number")
		sfd.FileName = sName & ".dxf"
	 
		If sfd.ShowDialog = System.Windows.Forms.DialogResult.OK Then
			sFname = sfd.FileName
			If Not Strings.Right(sFname, 4) = ".dxf" Then sFname = sFname & ".dxf"
		Else
			Exit Sub
		End If
		

	 	oCompDef.DataIO.WriteDataToFile(sOut, sFname)
		oCompDef.FlatPattern.ExitEdit
			
		MessageBox.Show("Your file was saved in the following directory: " + sFname)
	Else
		MessageBox.Show("Only sheet metal parts can be exported as DXF.")
	End If
Exit Sub

ErrorHandler:
	MessageBox.Show("The file is in use!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1)
    Exit Sub
End Sub

 

0 Likes
Message 5 of 8

gabrielhPD9HK
Community Visitor
Community Visitor

Hi Enrico, did you find a solution? I have the same problem

0 Likes
Message 6 of 8

aurel_e
Collaborator
Collaborator

I have created an ilogic rule few weeks ago for an Italian forum.
I have just tested it a simple assembly and didn't have any feedback from OP.
Try it and let me know. There is some custom file name setting but it can be removed.
It was designed to distinguish between up and down bends as well:

Sub Main
    Dim oAsmDoc As AssemblyDocument
    If ThisApplication.ActiveDocument.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
        MessageBox.Show("Esegui questa regola da un file di assieme.", "iLogic")
        Exit Sub
    End If

    oAsmDoc = ThisApplication.ActiveDocument
    Dim oAsmName As String = Left(oAsmDoc.DisplayName, Len(oAsmDoc.DisplayName) - 4)

    Dim RUsure As MsgBoxResult
    RUsure = MessageBox.Show(
        "Questo crea un file DXF per tutti i componenti dell’assieme che sono in lamiera." & vbLf &
        "Sei sicuro di voler creare i DXF di tutti i componenti dell’assieme?" & vbLf &
        "Potrebbe volerci del tempo, sii paziente.",
        "iLogic - Esportazione DXF in batch", MessageBoxButtons.YesNo)

    If RUsure = vbNo Then Return

    Dim oPath As String = ThisDoc.Path
    Dim oFolder As String = oPath & "\" & oAsmName & " DXF Files"
    If Not System.IO.Directory.Exists(oFolder) Then
        System.IO.Directory.CreateDirectory(oFolder)
    End If

    Dim dxfCount As Integer = 0
    Dim errReport As New List(Of String)

    Dim oDoc As Document
    Dim oPartDoc As PartDocument
    Dim oFlatPart As PartDocument
    Dim oCompDef As SheetMetalComponentDefinition

    For Each occ As ComponentOccurrence In oAsmDoc.ComponentDefinition.Occurrences.AllLeafOccurrences
        oDoc = occ.Definition.Document
        If oDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then Continue For

        oPartDoc = CType(oDoc, PartDocument)
        If Not oPartDoc.ComponentDefinition.Type = ObjectTypeEnum.kSheetMetalComponentDefinitionObject Then Continue For

        oFlatPart = ThisApplication.Documents.Open(oPartDoc.FullFileName, False)
        oCompDef = oFlatPart.ComponentDefinition

        ' Elimina il flat pattern esistente, se presente
        If oCompDef.HasFlatPattern Then
            Try
                oCompDef.FlatPattern.Delete()
            Catch ex As Exception
                errReport.Add(oPartDoc.DisplayName & " - Errore nell'eliminazione del flat pattern esistente.")
                oFlatPart.Close(False)
                Continue For
            End Try
        End If

        ' Crea un nuovo flat pattern
        Try
            oCompDef.Unfold()
            oCompDef.FlatPattern.ExitEdit()
        Catch ex As Exception
            errReport.Add(oPartDoc.DisplayName & " - Errore nella creazione del flat pattern.")
            oFlatPart.Close(False)
            Continue For
        End Try

        ' Rimuove eventuali schizzi vecchi
        For Each sk In oCompDef.FlatPattern.Sketches
            If sk.Name = "BendMarkers" Then sk.Delete()
        Next

        ' Crea nuovo schizzo per marcatori piega
        Dim oSketch As PlanarSketch = oCompDef.FlatPattern.Sketches.Add(oCompDef.FlatPattern.TopFace, False)
        oSketch.Name = "BendMarkers"

        Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
        Dim segLength As Double = 0.2
        Dim offset As Double = 0.5
        Dim stubLength As Double = 0.2

        ' Piega verso l'alto
        For Each oEdge As Edge In oCompDef.FlatPattern.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True)
            Try
                Dim edgeGeom As LineSegment = TryCast(oEdge.Geometry, LineSegment)
                If edgeGeom Is Nothing Then Continue For
                Dim p1 As Point2d = oSketch.ModelToSketchSpace(edgeGeom.StartPoint)
                Dim p2 As Point2d = oSketch.ModelToSketchSpace(edgeGeom.EndPoint)

                Dim dx As Double = p2.X - p1.X
                Dim dy As Double = p2.Y - p1.Y
                Dim length As Double = Math.Sqrt(dx ^ 2 + dy ^ 2)
                dx /= length
                dy /= length

                Dim off1 As Point2d = oTG.CreatePoint2d(p1.X + dx * offset, p1.Y + dy * offset)
                Dim off2 As Point2d = oTG.CreatePoint2d(p2.X - dx * offset, p2.Y - dy * offset)
                Dim pt1 As Point2d = oTG.CreatePoint2d(off1.X + dx * stubLength, off1.Y + dy * stubLength)
                Dim pt2 As Point2d = oTG.CreatePoint2d(off2.X - dx * stubLength, off2.Y - dy * stubLength)

                oSketch.SketchLines.AddByTwoPoints(off1, pt1)
                oSketch.SketchLines.AddByTwoPoints(off2, pt2)
            Catch
            End Try
        Next

        ' Piega verso il basso
        For Each oEdge As Edge In oCompDef.FlatPattern.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True)
            Try
                Dim edgeGeom As LineSegment = TryCast(oEdge.Geometry, LineSegment)
                If edgeGeom Is Nothing Then Continue For
                Dim p1 As Point2d = oSketch.ModelToSketchSpace(edgeGeom.StartPoint)
                Dim p2 As Point2d = oSketch.ModelToSketchSpace(edgeGeom.EndPoint)

                Dim dx As Double = p2.X - p1.X
                Dim dy As Double = p2.Y - p1.Y
                Dim length As Double = Math.Sqrt(dx ^ 2 + dy ^ 2)
                dx /= length
                dy /= length

                Dim pt1 As Point2d = oTG.CreatePoint2d(p1.X + dx * stubLength, p1.Y + dy * stubLength)
                Dim pt2 As Point2d = oTG.CreatePoint2d(p2.X - dx * stubLength, p2.Y - dy * stubLength)

                oSketch.SketchLines.AddByTwoPoints(p1, pt1)
                oSketch.SketchLines.AddByTwoPoints(p2, pt2)
            Catch
            End Try
        Next

        ' Esporta il file DXF
        Dim oFileName As String = oDoc.DisplayName
        Dim oThickness As String = Round(oCompDef.Thickness.Value * 10, 1)

        Dim CustomName As String
        Try
            CustomName = iProperties.Value(oFileName, "Custom", "PF_PRT_ZNR")
        Catch
            CustomName = "AST Srl -"
        End Try

        Dim fullFileName As String = oFolder & "\" & CustomName & " " & oFileName & " - " & oThickness & "mm.dxf"

        Dim sOut As String
        sOut = "FLAT PATTERN DXF?AcadVersion=2000" _
            & "&InvisibleLayers=IV_TANGENT;IV_FEATURE_PROFILES;IV_ARC_CENTERS;IV_BEND;IV_BEND_DOWN;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_FEATURE_PROFILES_DOWN" _
            & "&OuterProfileLayer=0" _
            & "&InteriorProfilesLayer=0" _
            & "&UnconsumedSketchesLayer=MARKERS" _
            & "&UnconsumedSketchesLayerColor=255;0;0"

        oCompDef.DataIO.WriteDataToFile(sOut, fullFileName)
        dxfCount += 1

        oCompDef.FlatPattern.ExitEdit()
        oFlatPart.Close(True)
    Next

    ' Messaggio finale di riepilogo
    Dim summary As String = dxfCount & " file DXF generati."
    If errReport.Count > 0 Then
        summary &= vbLf & vbLf & "I seguenti componenti non sono stati processati correttamente:" & vbLf & String.Join(vbLf, errReport.ToArray())
    End If
    MessageBox.Show(summary, "iLogic - Riepilogo esportazione DXF")
End Sub
0 Likes
Message 7 of 8

gabrielhPD9HK
Community Visitor
Community Visitor

Hello aurel_e, can you share me a video of this Ilogic working?, I will be very greatful to you.

0 Likes
Message 8 of 8

aurel_e
Collaborator
Collaborator

No problem.
Video below:

0 Likes