新建布局视口显示
本帖最后由 hnzgs 于 2012-12-4 17:27 编辑代码如下:'锁定文档
Using acLckDoc As DocumentLock = doc.LockDocument
'全部显示
Autodesk.AutoCAD.Internal.Utils.ZoomAuto(1, 1, 1, 1, 1)
Using trans As Transaction = db.TransactionManager.StartTransaction()
Dim lm As LayoutManager = LayoutManager.Current
Dim layName As String = GenerateLayoutName()
'创建新布局
Dim layoutId As ObjectId = lm.CreateLayout(layName)
'设置为当前布局
lm.CurrentLayout = layName
Dim acLayout As Layout = TryCast(trans.GetObject(layoutId, OpenMode.ForRead), Layout)
Dim pi As PlotInfo = New PlotInfo()
pi.Layout = acLayout.ObjectId
Dim ps As PlotSettings = New PlotSettings(acLayout.ModelType)
ps.CopyFrom(acLayout)
Dim psv As PlotSettingsValidator = PlotSettingsValidator.Current
With psv
'设置打印设备和纸张
.SetPlotConfigurationName(ps, "Adobe PDF", "A4")
'设置打印单位
.SetPlotPaperUnits(ps, PlotPaperUnit.Millimeters)
'设置打印比例
.SetUseStandardScale(ps, True)
.SetStdScaleType(ps, StdScaleType.ScaleToFit)
''设置打印区域
.SetPlotType(ps, Autodesk.AutoCAD.DatabaseServices.PlotType.Extents)
'设置横向打印
.SetPlotRotation(ps, PlotRotation.Degrees090)
' 设置是否居中打印
.SetPlotCentered(ps, True)
End With
'将布局由只读改为读写模式
acLayout.UpgradeOpen()
'置为当前布局
acLayout.CopyFrom(ps)
acLayout.DowngradeOpen()
'保存新对象到数据库中
trans.Commit()
End Using
'重生成一下,否则显示不正确
doc.Editor.Regen()
End Using直接建好后的效果不大满意,怎样才能实现附图3那种想要的效果~~谢了先!
好像没做过,看到有下面这个东西,不知道楼主有没有用过。
public void SetPlotWindowArea(Autodesk.AutoCAD.DatabaseServices.PlotSettings plotSet, Autodesk.AutoCAD.DatabaseServices.Extents2d windowArea)
Autodesk.AutoCAD.DatabaseServices.PlotSettingsValidator 的成员
至于Extents2d windowArea哪里来,若是我可能用笨办法算,楼主不妨试试看能不能用下面这个
public Autodesk.AutoCAD.DatabaseServices.Extents3d Extents { get; }
Autodesk.AutoCAD.DatabaseServices.Layout 的成员 sieben 发表于 2012-12-4 19:44 static/image/common/back.gif
好像没做过,看到有下面这个东西,不知道楼主有没有用过。
public void SetPlotWindowArea(Autodesk.AutoC ...
多谢sieben老兄!
SetPlotWindowArea是窗选,也试过了,跟PlotType.Extents的的结果一样。
acLayout.Extents为只读属性,在PlotSettingsValidator前后均为((0,0,0),(0,0,0)) acLayout.Extents为只读属性,在PlotSettingsValidator前后均为((0,0,0),(0,0,0))
-----------------------------
或者是因为你的acLayout还没提交到数据库,我好像用过acLayout.Extents不是0 sieben 发表于 2012-12-5 17:05 static/image/common/back.gif
acLayout.Extents为只读属性,在PlotSettingsValidator前后均为((0,0,0),(0,0,0))
---------------------- ...
提交后显示也是如此,奇怪了 啊?可能我记错了,你的AutoCAD什么版本?
public Autodesk.AutoCAD.DatabaseServices.Extents2d Limits { get; }
Autodesk.AutoCAD.DatabaseServices.Layout 的成员
这个东西有没有试过?
或者
public Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection GetViewports()
Autodesk.AutoCAD.DatabaseServices.Layout 的成员
用视口Viewport来试试?
sieben 发表于 2012-12-7 16:13 static/image/common/back.gif
啊?可能我记错了,你的AutoCAD什么版本?
public Autodesk.AutoCAD.DatabaseServices.Extents2d Limits { ...
谢谢老兄,我用的是CAD2010。郁闷了
页:
[1]