Hello, I created ilogic to create dxf from the assembly. Unfortunately, the rack only works for parts, while when the assembly is in the next assembly it does not create dxf. Please help. Below the script
Sub Main Blacha() Dim oDoc As AssemblyDocument ' oDoc = ThisApplication.ActiveDocument Folder = ThisDoc.Path & "\DXF\" Sciezka = InputBox("Folder docelowy", "DXF", Folder)
If Not System.IO.Directory.Exists(Sciezka) Then System.IO.Directory.CreateDirectory(Sciezka) End If
' Set a reference to the BOM Dim oBOM As BOM oBOM = oDoc.ComponentDefinition.BOM
' Make sure that the PartOnly view is enabled. oBOM.PartsOnlyViewEnabled = True
Dim oDef As AssemblyComponentDefinition oDef = oDoc.ComponentDefinition Dim oOcc As ComponentOccurrence For Each oOcc In oDef.Occurrences If oOcc.SubOccurrences.Count = 0 Then If oOcc.DefinitionReference.ReferencedDefinition.Type = 150995200 Then Dim oCompDefSM As SheetMetalComponentDefinition oCompDefSM = oOcc.Definition Dim oDataIO As DataIO ' oDataIO = oCompDefSM.DataIO Dim sOut As String sOut = "FLAT PATTERN DXF?AcadVersion=2000&RebaseGeometry=True&SimplifySpline=True&InteriorProfilesLayer=IV_INTERIOR_PROFILES&InvisibleLayers=IV_TANGENT;IV_BEND;IV_BEND_DOWN;IV_ARC_CENTERS;IV_FEATURE_PROFILES;IV_FEATURE_PROFILES_DOWN;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_ANGENT;IV_ROLL&SplineToleranceDouble=0.01" Dim sFname As String sFname = oCompDefSM.Document.FullFilename el = oCompDefSM.FlatPattern.Length * 10 ew = oCompDefSM.FlatPattern.Width * 10
Pozycja=InStrRev(sFname,"\", -1) NazwaPliku=Right(sFname,Len(sFname)-Pozycja) NazwaPliku = Left$(NazwaPliku, Len(NazwaPliku) -4) Gr = oCompDefSM.Thickness.Value * 10 Dim MTOBJ As Material MTOBJ = oCompDefSM.Material Dim MT As String MT=MTOBJ.Name PN = iProperties.Value(oOcc.Name, "Project", "Part Number") quantity = ThisBOM.CalculateQuantity("Parts Only", PN) tytul = iProperties.Value(oOcc.Name, "Summary", "Title") ''''''''''''''''' TU ZMIEŃ '''''''''''''''''''''''''''' sFname = Sciezka & PN & " " & tytul & " " & Round(el) & "x" & Round(ew) & "x"& Gr & " " & MT & " sztuk " & quantity & ".dxf"
If oCompDefSM.HasFlatPattern = False Then oCompDefSM.Unfold oDataIO.WriteDataToFile(sOut, sFname) oCompDefSM.Document.Close(True) Else If oCompDefSM.HasFlatPattern = True Then oDataIO.WriteDataToFile(sOut, sFname)
oCompDefSM.Document.Close(True) End If End If Else Call SprawdzPodzespol(oOcc, Sciezka) End If Next
InventorVb.DocumentUpdate()
End Sub Private Sub SprawdzPodzespol(ByVal oCompOcc As ComponentOccurrence, Sciezka1 As String)
Dim oSubOcc As ComponentOccurrence For Each oSubOcc In oCompOcc.SubOccurrences If oSubOcc.SubOccurrences.Count = 0 Then If oSubOcc.DefinitionReference.ReferencedDefinition.Type = 150995200 Then Dim oCompDefSM As SheetMetalComponentDefinition oCompDefSM = oSubOcc.Definition Dim oDataIO As DataIO ' oDataIO = oCompDefSM.DataIO Dim sOut As String sOut = "FLAT PATTERN DXF?AcadVersion=2000&RebaseGeometry=True&SimplifySpline=True&InteriorProfilesLayer=IV_INTERIOR_PROFILES&InvisibleLayers=IV_TANGENT;IV_BEND;IV_BEND_DOWN;IV_ARC_CENTERS;IV_FEATURE_PROFILES;IV_FEATURE_PROFILES_DOWN;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_ANGENT;IV_ROLL&SplineToleranceDouble=0.01" Dim sFname As String sFname = oCompDefSM.Document.FullFilename el = oCompDefSM.FlatPattern.Length * 10 ew = oCompDefSM.FlatPattern.Width * 10
Pozycja=InStrRev(sFname,"\", -1) NazwaPliku=Right(sFname,Len(sFname)-Pozycja) NazwaPliku = Left$(NazwaPliku, Len(NazwaPliku) -4) Gr = oCompDefSM.Thickness.Value * 10 Dim MTOBJ As Material MTOBJ = oCompDefSM.Material Dim MT As String MT=MTOBJ.Name PN = iProperties.Value(oSubOcc.Name, "Project", "Part Number") quantity = ThisBOM.CalculateQuantity("Parts Only", PN) sFname = Sciezka1 & NazwaPliku & " " & Round(el) & "x" & Round(ew) & "x"& Gr & " " & MT & " sztuk " & quantity & ".dxf"
If oCompDefSM.HasFlatPattern = False Then oCompDefSM.Unfold oDataIO.WriteDataToFile(sOut, sFname) oCompDefSM.Document.Close(True) Else If oCompDefSM.HasFlatPattern = True Then oDataIO.WriteDataToFile(sOut, sFname)
oCompDefSM.Document.Close(True) End If End If Else Call SprawdzPodzespol(oOcc, Sciezka1) End If Next
InventorVb.DocumentUpdate()
End Sub
Show More