03-15-2021
08:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-15-2021
08:17 AM
Hello
First, you posted only the iam, the included 3 ipt's are missing.
Anyway, I'll tried to modify the code so you could try to paste it in your assembly.
Sub Main()
SharedVariable("VPR_Codice") = ""
Dim IPT_OM_Template As String = ThisDoc.FileName(False) 'Filename of the assembly without file type extension (iam)
Dim pathOutputDXF As String = ThisDoc.Path & "\Output_DXF\" & IPT_OM_Template & ".dxf" 'Path to save the dxf to including filename of assembly and file type extension (dxf)
Call Print_Assembly_IPT_DXF(IPT_OM_Template, pathOutputDXF)
End Sub
Sub Print_Assembly_IPT_DXF(IPT_OM_Template As String, pathOutputDXF As String)
Dim oAsm As AssemblyDocument = ThisDoc.Document
'Dim oPenDoc As Document=ThisDoc.Document
Dim AsmCompDefMainL0 As AssemblyComponentDefinition = oAsm.ComponentDefinition 'ThisApplication.ActiveDocument.ComponentDefinition
Dim AsmCompDefL1 As AssemblyComponentDefinition '= ThisApplication.ActiveDocument.ComponentDefinition
Dim OccurMainL0 As ComponentOccurrence
Dim OccurL1 As ComponentOccurrence
'Dim AsmCompMainL0 As ComponentDefinition = ThisDoc.Document.ComponentDefinition
'Dim AsmCompMainL1 As ComponentDefinition = ThisDoc.Document.ComponentDefinition
For Each OccurMainL0 In AsmCompDefMainL0.Occurrences
Dim oOccNameL0 As String = OccurMainL0.Name
'Dim thisAssembly As AssemblyDocument = OccurMainL0.Definition.Document
Logger.Info("Apro assieme per DXF: " & oOccNameL0)
If OccurMainL0.Definition.Type = ObjectTypeEnum.kAssemblyComponentDefinitionObject Then
For Each OccurL1 In OccurMainL0.SubOccurrences
'For Each doc In thisAssembly.AllReferencedDocuments
If OccurL1.Definition.Type = ObjectTypeEnum.kSheetMetalComponentDefinitionObject Then
Dim parsedPartName = OccurL1.ReferencedDocumentDescriptor.DisplayName ' doc.DisplayName
Logger.Info("Selezionare parte da esportare in DXF: " & parsedPartName)
If parsedPartName.Contains("CTG") Then
Logger.Info("Ho selezionato la parte in CTG")
Else
Logger.Info("Ho selezionato la parte in lamiera")
Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=2004&OuterProfileLayer=OUTER_PROFILE&OuterProfileLayerColor=0;0;0&InteriorProfilesLayer=INNER_PROFILE&InteriorProfilesLayerColor=0;0;0&InvisibleLayers=IV_BEND;IV_BEND_DOWN;IV_UNCONSUMED_SKETCH;IV_ARC_CENTERS;IV_TANGENT;IV_ROLL;IV_ROLL_TANGENT;IV_ALTREP_BACK;IV_ALTREP_FRONT;IV_FEATURE_PROFILES_DOWN;IV_FEATURE_PROFILES;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;DIGI_MARKER_TOOL_1;DIGI_MARKER_TOOL_2"
Dim component As SheetMetalComponentDefinition = OccurL1.Definition
'Dim PathDXF As String = pathOutputLamieraDXF & iProperties.Value(OccurL1, "Custom", "Nome_File")
component.Unfold
If System.IO.File.Exists(pathOutputDXF) = True Then
System.IO.File.Delete(pathOutputDXF)
End If
component.DataIO.WriteDataToFile(sOut, pathOutputDXF)
Logger.Info("DXF " & SharedVariable("VPR_Codice") & " SUCCESS")
component.FlatPattern.ExitEdit()
'component.Document.close()
End If
End If
Next
End If
Next
End Sub
R. Krieg
RKW Solutions
www.rkw-solutions.com