TheSwamp
Code Red => VB(A) => Topic started by: Keith™ on June 21, 2006, 08:09:55 PM
-
I have a need where I would like to programmatically setup all of the plotting parameters. I don't want any viewports to show on my new sheet. Essentially I want to create a new layout by adding a layout to the layouts collection, set the plotter, paper size, etc. and when the user selects it from the tab, it should not display the new setup window which places a viewport by default, but I want the page setup to show if the user creates a new layout outside of the program. Does this make sense. ... in short how do I turn off that feature for my programmatically created layouts?
-
You could attach an xrecord to the new layout when you create it. Then do something like this in the LayoutSwitched event:
Private Sub AcadDocument_LayoutSwitched(ByVal LayoutName As String)
If ThisDrawing.Layouts(LayoutName).HasExtensionDictionary Then
' Perhaps add a check here for the presence of a specific xrecord
Application.Preferences.Display.LayoutCreateViewport = False
Application.Preferences.Display.LayoutShowPlotSetup = False
Else
Application.Preferences.Display.LayoutCreateViewport = True
Application.Preferences.Display.LayoutShowPlotSetup = True
End If
End Sub
-
Or, using an idea gained by seeing Chuck's code, just set those 2 variables to false before creating the layout and return them to their previous settings when done.
-
Is there a specific tag, setting, xrecord etc. that you are aware of that causes the page setup window to pop up when a new layout is accessed for the first time? The reason I ask is because if you reset the variables prior to clicking on the layout, the new page setup window is still displayed. I cannot utilize (well not easily anyway) an event reactor because the programming will be compiled into a dll.
I have went as far as to dump a DXF of a drawing with 2 layouts, one selected and one not, then compare the ooutput, but I still have not found the slightest hint how to resolve this issue.
-
Just so I'm clear, you want to programatically do this
-
This worked for me, Keith.
Sub LayoutTest()
Dim oLayout As AcadLayout
Dim oOrigLayout As AcadLayout
Dim bVP As Boolean
Dim bDialg As Boolean
bVP = Application.Preferences.Display.LayoutCreateViewport
bDialg = Application.Preferences.Display.LayoutShowPlotSetup
Set oOrigLayout = ThisDrawing.ActiveLayout
Application.Preferences.Display.LayoutCreateViewport = False
Application.Preferences.Display.LayoutShowPlotSetup = False
Set oLayout = ThisDrawing.Layouts.Add("NewLayout")
'With oLayout
oLayout.CopyFrom ThisDrawing.Layouts.Item(0) 'gets the plot data from the first layout....probably would want to change this.
ThisDrawing.ActiveLayout = oLayout
Application.Preferences.Display.LayoutCreateViewport = bVP
Application.Preferences.Display.LayoutShowPlotSetup = bDialg
ThisDrawing.ActiveLayout = oOrigLayout
End Sub
-
Just so I'm clear, you want to programatically do this
No Bob .. I can do that easily enough. The issue is, that I do not want to turn off those settings, rather I want AutoCAD to ignore these settings when I programmatically create a layout. The reason is that if a user expects that to be set and I turn it off, they will simply turn it back on. This is not good from a programming point of view, for if they turn it back on, it will prompt for the page setup, which I have already setup with my programming.
Jeff I will try that and see if it resolves my issues.
-
This probably isn't the most elegant way to sink document level events in a DLL, but you don't get much simpler.
' EventSink.cls
Private WithEvents m_acadApp As AcadApplication
Private WithEvents m_currentDoc As AcadDocument
Private Sub m_acadApp_BeginCommand(ByVal CommandName As String)
Set m_currentDoc = m_acadApp.ActiveDocument
End Sub
Private Sub m_currentDoc_LayoutSwitched(ByVal LayoutName As String)
m_currentDoc.Utility.Prompt "Switched to layout: " & LayoutName
End Sub
Public Property Set Application(ByRef app As AcadApplication)
Set m_acadApp = app
Set m_currentDoc = m_acadApp.ActiveDocument
End Property