Author Topic: Get Modelspace or Paperspace (Plotting)  (Read 1476 times)

0 Members and 1 Guest are viewing this topic.

GumbyCAD

  • Newt
  • Posts: 84
Get Modelspace or Paperspace (Plotting)
« on: March 06, 2014, 01:00:17 AM »
I think is might be a dumb question... But Ill ask it anyway.
I'm sure it an easy one......

Code: [Select]
      '' Reference the Layout Manager
      Dim acLayoutMgr As LayoutManager
      acLayoutMgr = LayoutManager.Current
 
      '' Get the current layout and output its name in the Command Line window
      Dim acLayout As Layout
      acLayout = acTrans.GetObject(acLayoutMgr.GetLayoutId(acLayoutMgr.CurrentLayout), _
                                   OpenMode.ForRead)

So the Layout Manager "acLayoutMgr.CurrentLayout" get the current space either Model Space or Current Layout.

But what if I wanted to Specifically get ModelSpace or Layout1 ........
In the context of Plotting.

Reference Link http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html?url=WS1a9193826455f5ff2566ffd511ff6f8c7ca-33b0.htm,topicNumber=d0e50852

GumbyCAD

  • Newt
  • Posts: 84
Re: Get Modelspace or Paperspace (Plotting)
« Reply #1 on: March 06, 2014, 01:13:31 AM »
I guess I could do.... but is this ideal during plotting?

Code: [Select]
      '' Switch to the previous Paper space layout
      Application.SetSystemVariable("TILEMODE", 0)
      acDoc.Editor.SwitchToPaperSpace()

 
Code: [Select]
      '' Activate model space in the viewport
      acDoc.Editor.SwitchToModelSpace()

GumbyCAD

  • Newt
  • Posts: 84
Re: Get Modelspace or Paperspace (Plotting)
« Reply #2 on: March 06, 2014, 01:46:39 AM »
Nope that won't work.

eInvalidInput

GumbyCAD

  • Newt
  • Posts: 84
Re: Get Modelspace or Paperspace (Plotting)
« Reply #3 on: March 06, 2014, 02:11:55 AM »
Bingo Solved it.

Code: [Select]
                    Dim acLayout As Layout = Nothing

                    Select Case ModelSpaceOnly
                        Case True
                            acLayout = CType(acTrans.GetObject(acBlkTblRec_MS.LayoutId, OpenMode.ForRead), Layout)
                        Case False
                            acLayout = CType(acTrans.GetObject(acBlkTblRec_PS.LayoutId, OpenMode.ForRead), Layout)
                    End Select

                    Dim acPlInfo As PlotInfo = New PlotInfo()

                    Dim acPlSet As PlotSettings = New PlotSettings(acLayout.ModelType)
                    LayoutManager.Current.CurrentLayout = acLayout.LayoutName
                    acPlInfo.Layout = acLayout.ObjectId
                    acPlSet.CopyFrom(acLayout)