花了一下午完成了一個初步的示範的例子,看來解決圖紙統一治理有了解決的辦法了.下一步用jacob封裝在Java中調用,在服務器上控制打印治理.做個記號再慢慢完善.'取得當前文檔對象(vba中的方法,假如是在VB中時需要從頂層對象開始引用取得)
Dim currentDoc As AcadDocument
Set currentDoc = ThisDrawing'文檔的模型空間
Dim sp As AcadModelSpace
Set sp = currentDoc.modelspace'取得模型空間中的塊屬性
Dim index As Integer
For index = 0 To sp.Count - 1
Dim name As String
name = sp.Item(index).ObjectName
'判定模型空間中的項目是否是一個塊引用
If name Like "*Ac*" Then
Dim blockRef As AcadBlockReference
Set blockRef = sp.Item(index)
'塊引用的插入點
Dim insertPoint As Variant
insertPoint = blockRef.InsertionPoint
'放大比例
Dim xScale, yScale As Integer
xScale = blockRef.XScaleFactor
yScale = blockRef.YScaleFactor
'寬高基數
Dim width, height As Double
width = 297
height = 210
'打印區域
Dim UpperRight(0 To 1) As Double, LowerLeft(0 To 1) As Double
UpperRight(0) = insertPoint(0)
UpperRight(1) = insertPoint(1)
LowerLeft(0) = insertPoint(0) + width * xScale
LowerLeft(1) = insertPoint(1) - height * yScale
list.AddItem "inserPoint:X=" & UpperRight(0) & " Y:" & UpperRight(1)
list.AddItem "lowerLeft :X=" & LowerLeft(0) & " Y:" & LowerLeft(1)
Dim plotConfs As AcadPlotConfigurations
Set plotConfs = ThisDrawing.PlotConfigurations
list.AddItem plotConfs.Count
Dim plotconf As AcadPlotConfiguration
Set plotconf = plotConfs.Add("plot")
'list.AddItem plotconf.GetPlotDeviceNames(5)
'Set plotConf = ThisDrawing.PlotConfigurations.Add
'設置定義要打印的布局範圍的坐標
ThisDrawing.ActiveLayout.SetWindowToPlot LowerLeft, UpperRight
'指定布局或打印配置的類型
ThisDrawing.ActiveLayout.PlotType = acWindow
'按局部或完整視圖預覽方式顯示打印預覽對話框
ThisDrawing.Plot.DisplayPlotPreview acFullPreview
'打印布局到設備
ThisDrawing.Plot.PlotToDevice
End If
Next index