Sub Main()
'aktualni slozka
Dim sPath As String
sPath = (ThisDoc.Path & "\")
'vystupni slozka
Dim sOutDir As String
sOutDir = "D:\DXF\"
'parametry rozvinu
Dim sSett As String
sSett = "FLAT PATTERN DXF?AcadVersion=2000" _
+ "&InvisibleLayers=IV_BEND;IV_BEND_DOWN;IV_TANGENT;IV_TOOL_CENTER;IV_TOOL_CENTER_DOWN;IV_ARC_CENTERS;IV_ALTREP_FRONT;IV_ALTREP_BACK;IV_UNCONSUMED_SKETCHES;IV_ROLL_TANGENT;IV_ROLL" _
+ "&SimplifySplines=True" _
+ "&LINEAR TOLERANCE=0.1" _
+ "&MergeProfilesIntoPolyline=True" _
+ "&RebaseGeometry=False" _
+ "&TrimCenterlines=True"
'oddelovac
Dim sSep As String
sSep = " - "
'vyber IPT souboru ve aktualni slozce
Dim files = IO.Directory.GetFiles(sPath, "*.ipt")
'cyklus pres IPT soubory
For Each file As String In files
Dim document = ThisApplication.Documents.Open(file)
ExportDocumentToDxf(document, sOutDir, sSep, sSett)
document.Close() 'KONEC TELA CYKLU
Next
End Sub
Private Sub ExportDocumentToDxf(document As _Document, sOutDir As String, sSep As String, sSett As String)
''Nadbytecne
'If part.DocumentSubType.DocumentSubTypeID <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
' document.Close()
' Return
'End If
Dim sheetmetalComponentDefinition As SheetMetalComponentDefinition
Dim part As PartDocument
Try
'Document is part
part = document
If part Is Nothing Then Return
'Part is SheetmetalPart
sheetmetalComponentDefinition = part.ComponentDefinition
If sheetmetalComponentDefinition Is Nothing Then Return
Catch
'Ignore eror and exit
Return
End Try
'ZACATEK TELA CYKLU
'cislo vykresu
Dim sVykres As String = part.PropertySets("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}")("Title").Value
'sVykres = iProperties.Value("Summary", "Title")
'MsgBox(sVykres, MessageBoxButtons.OKCancel)
'nazev dilu
Dim sNazev As String = part.PropertySets("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}")("Subject").Value
'sNazev = iProperties.Value("Summary", "Subject")
'MsgBox(sNazev, MessageBoxButtons.OKCancel)
'material
Dim sMatros As String = sheetmetalComponentDefinition.ActiveSheetMetalStyle.Material.Name
'sMatros = iProperties.Material
'MsgBox(sMatros, MessageBoxButtons.OKCancel)
'tloustka plechu
Dim sTloustka As String = "T" & part.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")("SM_Thickness").Value
'sTloustka = "T" & iProperties.Value("Custom", "SM_Thickness")
'MsgBox(sTloustka, MessageBoxButtons.OKCancel)
'poskladane jmeno vystupniho souboru
Dim sDxfFileName = sOutDir & sVykres & sSep & sNazev & sSep & sMatros & sSep & sTloustka & ".dxf"
' MsgBox(sDXFFileName, MessageBoxButtons.OKCancel)
'kdyz neexituje rozvin, tak se vytvori, kdyz existuje, tak se zaktivni
If sheetmetalComponentDefinition.HasFlatPattern = False Then
sheetmetalComponentDefinition.Unfold()
Else
sheetmetalComponentDefinition.FlatPattern.Edit()
End If
'vlastni export
sheetmetalComponentDefinition.DataIO.WriteDataToFile(sSett, sDxfFileName)
'prepnuti z rozvinu zpet
sheetmetalComponentDefinition.FlatPattern.ExitEdit()
End Sub