Imports System
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Runtime
...
<CommandMethod("ReconfigurerLayoutsToPDF")> _
Public Sub ReconfigurerLayoutsToPDF()
'Dim acAppComObj As AcadApplication
Dim acAppComObj As AcadApplication
acAppComObj = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
Dim acDocComObj As AcadDocument
acDocComObj = acAppComObj.ActiveDocument
If acDocComObj.Saved = False Then
Dim result As Integer
result = MsgBox("Перед запуском процедуры сохраните Ваш чертеж!" & vbCr & "Сохранить чертеж?", MsgBoxStyle.YesNo, "Вопрос")
If result = vbYes Then
acDocComObj.Save()
Else
End If
End If
MsgBox("Изменения произойдут в файле: " & vbCr & acAppComObj.ActiveDocument.FullName)
IO.
File.
Copy(acAppComObj.
ActiveDocument.
FullName, IO.
Path.
GetTempFileName & _
IO.Path.GetFileNameWithoutExtension(acAppComObj.ActiveDocument.FullName) & "_copy.dwg")
For i = 0 To acDocComObj.Layouts.Count - 1
Select Case acDocComObj.Layouts.Item(i).Name
Case Is <> "Model", "Модель"
'...
'Весь код не стал выкладывать
End Select
If acDocComObj.Layouts.Item(i).Name <> "Model" Then
If acDocComObj.Layouts.Item(i).Name <> "Модель" Then
' Для текущего листа зададим каноническое имя формата печати: DWG_To_PDF_Gallurgy.pc3
With acDocComObj.Layouts.Item(i)
.ConfigName = "DWG_To_PDF_Gallurgy.pc3"
.CanonicalMediaName = glCanonicalMediaName
.PaperUnits = 1
.PlotHidden = False
.PlotOrigin = {0, 0}
.PlotRotation = 0
LowerLeft = {xMin, yMin} ' pTo
UpperRight = {xMax, yMax} 'pTo
.SetWindowToPlot(LowerLeft, UpperRight)
.UseStandardScale = True
.SetCustomScale(1, 1)
.PlotType = 4
.CenterPlot = True
.PlotViewportBorders = True
.PlotViewportsFirst = True
.PlotWithLineweights = True
.PlotWithPlotStyles = True
.StyleSheet = IIf(glColored = True, "acad.ctb", "monochrome.ctb")
acDocComObj.Utility.Prompt(" Установлены следующие параметры листа:" & vbCrLf)
acDocComObj.Utility.Prompt(" 1. Формат: " & glCanonicalMediaName & "(" & glFormatClassic & ")" & vbCrLf)
acDocComObj.Utility.Prompt(" 2. Размеры: " & ДлинаГлобальная & "x" & ШиринаГлобальная & vbCrLf)
acDocComObj.Utility.Prompt(" 3. Цвет печати: " & IIf(glColored = True, "acad.ctb", "monochrome.ctb") & vbCrLf)
acDocComObj.Utility.Prompt(" 4. Начало области печати: " & xMin & "," & yMin & vbCrLf)
acDocComObj.Utility.Prompt(" 5. Конец области печати: " & xMax & "," & yMax & vbCrLf)
End With
End If
End If
End If
'...
Next i
End Sub