второе правило:
'тащим папку с компонентами и чертежами
' ipt;iam;idw_copy
newPach = ThisDoc.Path + "\" + "папка с компонентами"
If IO.Directory.Exists(newPach) = False Then
System.IO.Directory.CreateDirectory(newPach)'создаём папку для компонентов
Else MessageBox.Show("эта папка уже существует", "Проверка")
End If
Dim sourceDir As String = "путь к материнской сборке" + "\" + "папка с компонентами"
Dim backupDir As String = ThisDoc.Path + "\" + "папка с компонентами"
Dim Pr As String = "имя параметра с номером заказа или проекта или ещё какой критерий"
Dim Directory As System.IO.Directory
Dim iptList As String() = Directory.GetFiles(sourceDir, "*.ipt")
Dim idwList As String() = Directory.GetFiles(sourceDir, "*.idw") ' чертежи тоже тащим с собой
Dim iamList As String() = Directory.GetFiles(sourceDir, "*.iam")
Try
For Each f As String In iamList 'копируем сборки
Dim fName As String = f.Substring(sourceDir.Length + 1)
NewFileName = backupDir & "\" & Pr & " " & fName ' ok
OldFileName = sourceDir & "\" & fName ' ok
OldName = Left(fName, Len(fName) - 4) & ":1" ' ok
If IO.File.Exists(NewFileName) = False Then
System.IO.File.Copy(OldFileName, NewFileName, True)
End If
Try
Component.Replace(OldName, NewFileName, True)
Catch
End Try
Next
For Each f As String In iptList'копируем детали
Dim fName As String = f.Substring(sourceDir.Length + 1)
NewFileName = backupDir & "\" & Pr & " " & fName ' ok
OldFileName = sourceDir & "\" & fName ' ok
OldName = Left(fName, Len(fName) - 4) & ":1" ' ok
If IO.File.Exists(NewFileName) = False Then
System.IO.File.Copy(OldFileName, NewFileName, True)
End If
Try
Component.Replace(OldName, NewFileName, True)
Catch
End Try
Next
For Each f As String In idwList
Dim fName As String = f.Substring(sourceDir.Length + 1)
NewFileName = backupDir & "\" & Pr & " " & fName ' ok
OldFileName = sourceDir & "\" & fName ' ok
If IO.File.Exists(NewFileName) = False Then
System.IO.File.Copy(OldFileName, NewFileName, True)
End If
Next
Catch
End Try