- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have to work with quite a lot of sheet metal at work and was looking into iLogic to export my sheet metal parts. I managed to adapt some iLogic code I found in here to our needs but I still have one issue and can't figure out how to solve it.
I often have to put 2 folded sheet metal parts together in a 45° angle which causes one problem: I need to export a specific face to get it laser cut.
The iLogic code I have here exports both sides of the flat pattern and all it's features. I would need it to export the face I define as face A.
Here is the code I'm using at the moment:
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
oAsmName = ThisDoc.FileName(False) 'without extension
'Check that the active document is an assembly file
If oDoc.DocumentType <> kAssemblyDocumentObject Then
MessageBox.Show("Please run this rule from the assembly file.", "iLogic")
Exit Sub
End If
'Get user input
RUsure = MessageBox.Show( _
"This will create a DXF file for all of the asembly components that are sheet metal." _
& vbLf & "This rule expects that the part file is saved." _
& vbLf & " " _
& vbLf & "Are you sure you want to create DXF for all of the assembly components?" _
& vbLf & "This could take a while.", "iLogic - Batch Output DXFs ", MessageBoxButtons.YesNo)
If RUsure <> vbYes Then Exit Sub
Dim oPath As String = ThisDoc.Path
'Get the DXF target folder path
Dim oFolder As String = oPath & "\" & oAsmName & " DXF Files"
'Check for the DXF folder and create it if it does not exist
If Not System.IO.Directory.Exists(oFolder) Then
System.IO.Directory.CreateDirectory(oFolder)
End If
'- - - - - - - - - - - - -Component - - - - - - - - - - - -
'MessageBox.Show("Test", "My iLogic Dialog", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
Dim oBOM As BOM
'MessageBox.Show("Test", "My iLogic Dialog", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
oBOM = oDoc.ComponentDefinition.BOM
'MessageBox.Show("Test", "My iLogic Dialog", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
oBOM.StructuredViewEnabled = True
Dim oBOMView As BOMView = oBOM.BOMViews.Item(oBOM.BOMViews.Count)
For Each oRow As BOMRow In oBOMView.BOMRows
Try
Dim oCD As ComponentDefinition = oRow.ComponentDefinitions.Item(1)
Dim iDoc As Document = oCD.Document
'SheetMetal parts only
If iDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For
Dim iName As String = iDoc.FullFileName
'Check that model is saved
If iName = vbNullString Then Continue For
iDoc = ThisApplication.Documents.Open(iName)
oCD = iDoc.ComponentDefinition
Dim oItem As String = oRow.ItemNumber
Try
If Not oCD.HasFlatPattern Then
oCD.Unfold()
Else
oCD.FlatPattern.Edit()
End If
Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=2018" _
+ "&InteriorProfileLayer=IV_INTERIOR_PROFILES" _
+ "&InteriorProfilesLayerColor=255;255;0" _
+ "&OuterProfileLayer=IV_EXTERIOR_PROFILES" _
+ "&InvisibleLayers=IV_TANGENT" _
+ "&SimplifySplines=True" _
+ "&BendLayerLineType=37633" _
+ "&BendLayerColor=255;255;0" _
+ "&BendUpLayerLineType=37633" _
+ "&BendUpLayerColor=255;255;0" _
+ "&BendDownLayerLineType=37633" _
+ "&BendDownLayerColor=255;255;0" _
+ "&FeatureProfilesLayerLineType=37633" _
+ "&FeatureProfilesLayerColor=255;255;0" _
+ "&FeatureProfilesUpLayerLineType=37633" _
+ "&FeatureProfilesUpLayerColor=255;255;0" _
+ "&FeatureProfilesDownLayerLineType=37633" _
+ "&FeatureProfilesDownLayerColor=255;255;0"
Dim Nombre As String = oRow.ItemQuantity
Dim Matiere As String = ""
Dim Mat As String = iProperties.Material(iDoc.DisplayName)
If Mat = "Aluminium 6061"
Matiere = "alu"
ElseIf Mat = "Acier" Then
Matiere = "ac"
ElseIf Mat = "Acier inoxydable"
Matiere = "nx"
ElseIf Mat = "Acier, galvanisé"
Matiere = "galva"
ElseIf Mat = "Acier inoxydable brossé"
Matiere = "nxbrosse"
ElseIf Mat = "Acier inoxydable 316L brossé"
Matiere = "316Lbrosse"
ElseIf Mat = "Acier inoxydable 316L"
Matiere = "316L"
Else
Matiere = InputBox("La matière de cette pièce n'est pas définie, rajouter l'abréviation de la matière svp! ", "Matière manquante", "Indiquer la matière ici")
End If
Dim activepart As PartDocument = ThisApplication.ActiveDocument
Dim Sheetmetal As SheetMetalComponentDefinition = activepart.ComponentDefinition
Dim ThicknessSM As Parameter = Sheetmetal.Thickness
Dim Thickness As String = ThicknessSM.Value()*10
Dim ShortName As String = Left(iDoc.DisplayName, (InStrRev(iDoc.DisplayName, ".", -1, vbTextCompare) -1)) & "-" & Matiere & Thickness & "-" & Nombre & "x -" & ".dxf"
oCD.DataIO.WriteDataToFile(sOut, oFolder & "\" & ShortName)
oCD.FlatPattern.ExitEdit()
Catch ex As Exception
MsgBox(ex.Message)
End Try
iDoc.Close(True)
Catch
End Try
Next
I'll put an example assembly and a few screenshots of what I mean.
For part 220168-10-02 I would need to export this face
but when I export it with the code above I get this:
which has those white lines which should straight up not be there and the yellow line should be in white
Our laser engraves yellows lines and dismisses red ones.
I'm still fairly new to iLogic, so I'm struggling quite a bit.
Thanks in advance to anyone who can help me.
Solved! Go to Solution.