Message 1 of 1
SetPlotCentered - Layout set to 'centered', but isn't.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've got a VB.net program that creates several layouts. The first layout is created correctly, but the rest are not, in that the floating viewport isn't centered, even though the page setup for the viewport has that option checked. Regen and Audit don't correct the view, but unchecking and rechecking the option in the page dialog box does finally center the view.
Since transactions are unfamiliar to me, I'm inclined to lay the blame there.
(Some lines of code sample have been omitted for brevity.)
For Each BlockNum As Integer In blockSheetNumberlist
Using acTrans2 As Transaction = acCurDb.TransactionManager.StartTransaction()
' create layout
Dim newlayoutobjID As ObjectId = acLayoutMgr.CreateLayout("Sheet " & blockSheetNumberlist(BlockNum - 1))
Dim newlayoutobj As Layout = acTrans2.GetObject(newlayoutobjID, OpenMode.ForWrite)
newlayoutobj.Initialize()
Dim layoutblockrecord As BlockTableRecord = acTrans2.GetObject(newlayoutobj.BlockTableRecordId, OpenMode.ForWrite)
Dim layoutview As Viewport = acTrans2.GetObject(newlayoutobj.GetViewports.Item(0), OpenMode.ForWrite)
Dim pltSetObj As New PlotSettings(newlayoutobj.ModelType)
Dim BlockHeight As Double
Dim BlockWidth As Double
acLayoutMgr.CurrentLayout = newlayoutobj.LayoutName
Dim acPlSetVdr As PlotSettingsValidator = PlotSettingsValidator.Current
' create mview
Dim newView As New Viewport
layoutblockrecord.AppendEntity(newView)
acTrans2.AddNewlyCreatedDBObject(newView, True)
' set view of layout
Dim LayoutCtr As New Point2d(newView.Width / 2, newView.Height / 2)
layoutview.ViewCenter = LayoutCtr
layoutview.ViewHeight = 12
' set position and size of floating viewport
Dim ViewBordCtr As New Point3d(newView.Width / 2, newView.Height / 2, 0)
newView.CenterPoint = ViewBordCtr
' set position and size of model space in floating viewport
Dim ViewModCenter As New Point2d(blockInsertPtList(BlockNum - 1).X + (blockScaleList(BlockNum - 1).X * BlockWidth / 2),
blockInsertPtList(BlockNum - 1).Y + (blockScaleList(BlockNum - 1).Y * BlockHeight / 2))
newView.ViewCenter = ViewModCenter
newView.ViewHeight = blockScaleList(BlockNum - 1).Y * BlockHeight
newView.On = vbTrue
newView.UpdateDisplay()
' set Page Setup
pltSetObj.CopyFrom(newlayoutobj)
acPlSetVdr.RefreshLists(pltSetObj)
acPlSetVdr.SetPlotConfigurationName(pltSetObj, "DWFx ePlot (XPS Compatible).pc3", "ANSI_expand_B_(17.00_x_11.00_Inches)")
acPlSetVdr.SetPlotRotation(pltSetObj, PlotRotation.Degrees000)
acPlSetVdr.SetPlotType(pltSetObj, PlotType.Extents)
acPlSetVdr.SetUseStandardScale(pltSetObj, vbTrue)
acPlSetVdr.SetStdScaleType(pltSetObj, StandardScaleType.ScaleToFit)
acPlSetVdr.SetPlotCentered(pltSetObj, vbTrue)
newlayoutobj.CopyFrom(pltSetObj)
layoutview.UpdateDisplay()
acTrans2.Commit()
End Using
Next