Pokusím se to zjistit u nich.
Jinak tedy u modelů co jsou na disku to funguje.
Jen když to exportuje dxf, tak ho to nepojmenuje dle modelu ze kterého se exportuje...
Název exportovaného dxf je prázdný.
Sub Main()
Dim excelFile As String = "C:\Users\czmiko4\Desktop\Test-excel-export\Test.xlsx"
Dim excelSheet As String = "List1"
Dim dataFromExcel = ReadDataFromExcel(excelFile, excelSheet)
Dim fileNames = CreateFileNames(dataFromExcel)
For Each fileName As String In fileNames
'Check file exists
If Not System.IO.File.Exists(fileName) Then
MsgBox ("File not found" & vbCrLf & fileName)
Continue For
End If
'Open file
Dim partDocument As PartDocument = ThisApplication.Documents.Open(fileName)
'Export to DXF
ExportToDxf (partDocument)
'Close without changes
partDocument.Close (True)
Next
End Sub
Private Sub ExportToDxf(partDocument As partDocument)
'Implement your export to DXF here
Dim FilePath As String
FilePath = "C:\Users\czmiko4\Desktop\Test-excel-export\"
If ThisApplication.ActiveDocument.ComponentDefinition.HasFlatPattern = False Then
ThisApplication.ActiveDocument.ComponentDefinition.Unfold
Else
ThisApplication.ActiveDocument.ComponentDefinition.FlatPattern.Delete
ThisApplication.ActiveDocument.ComponentDefinition.Unfold
End If
Dim fSett As String
fSett = "FLAT PATTERN DXF?AcadVersion=2000&OuterProfileLayer=IV_INTERIOR_PROFILES"
Dim fSname As String
fSname = FilePath & ThisDoc.FileName(False) & ".dxf"
ThisApplication.ActiveDocument.ComponentDefinition.DataIO.WriteDataToFile( fSett, fSname)
'MessageBox.Show("DXF uložen jako: " & fSname ,"Uložení DXF rozvinu", MessageBoxButtons.OK)
ThisApplication.ActiveDocument.ComponentDefinition.FlatPattern.ExitEdit
' MsgBox(String.Format("Exporting to dxf...{1}{0}", partDocument.FullFileName, vbCrLf))
End Sub
Private Function CreateFileNames(dataFromExcel As List(Of String)) As List(Of String)
Dim fileNames As New List(Of String)
For Each fileName As String In dataFromExcel
fileNames.Add(String.Format("C:\Users\czmiko4\Desktop\Test-excel-export\{0}.ipt", fileName))
Next
Return fileNames
End Function
Private Function ReadDataFromExcel(excelFile As String, excelSheet As String) As List(Of String)
Dim cellValues As New List(Of String)
Dim column As String = "A"
Dim row As Integer = 1
GoExcel.Open(excelFile, excelSheet)
Do
Dim cellAddress As String = String.Format("{0}{1}", column, row)
Dim cellValue = GoExcel.CellValue(cellAddress)
If (cellValue Is Nothing OrElse cellValue.ToString() = "") Then
Exit Do
End If
cellValues.Add (cellValue)
row += 1
Loop
GoExcel.Close()
Return cellValues
End Function