Author Topic: VBA Plotting  (Read 2898 times)

0 Members and 1 Guest are viewing this topic.

NWcivil77

  • Guest
VBA Plotting
« on: May 20, 2006, 06:04:50 PM »
I am attempting to migrate my custom plot routines to VBA, and I am having a problem with the following code, I am at a loss as to how you set the paper size.  Any guidance would be appreciated...


Code: [Select]
Public Sub FULL_SIZE()

    ThisDrawing.ActiveLayout.RefreshPlotDeviceInfo
    Dim Layouts As AcadLayouts, Layout As AcadLayout
   
   
    Set Layouts = ThisDrawing.Layouts
    ThisDrawing.Regen acAllViewports

    With ThisDrawing.ActiveLayout
    .RefreshPlotDeviceInfo
    .GetPlotStyleTableNames
    .StyleSheet = "SFA1055.ctb"
    .ConfigName = "\\CENTRAL\HP DesignJet 500 42 by HP"
    .PlotRotation = ac0degrees
    .CenterPlot = True
    .PaperUnits = acInches
    .ScaleLineweights = False
    '.GetLocaleMediaName = "Oversize: Arch D (Landscape)"  <<This seems to be where the code fails!!>>
    .StandardScale = ac1_1
        End With
   
End Sub







EDIT: Wrapped your code in [ code ] tags for ya
   
« Last Edit: May 20, 2006, 10:44:21 PM by nivuahc »

Bryco

  • Water Moccasin
  • Posts: 1883
Re: VBA Plotting
« Reply #1 on: May 20, 2006, 07:56:35 PM »
.GetLocaleMediaName = "Oversize: Arch D (Landscape)" , the medianame makes it's own mind up what it wants to be, it becomes User something if you rotate the plot or center it etc. I grab a good plotconfig from a template using dbx and then
oLayout.CopyFrom PC. This sets everything just fine.

Dave R

  • Guest
Re: VBA Plotting
« Reply #2 on: May 22, 2006, 08:12:03 AM »
You need to use the layout's CanonicalMediaName  property to set the paper size. You can use the following code to get a list of the names for the current plotter:
Code: [Select]
Sub get_paper_names()
    Dim vPaperNames As Variant

    vPaperNames = ThisDrawing.ModelSpace.Layout.GetCanonicalMediaNames

    Dim iCnt As Integer
    For iCnt = LBound(vPaperNames) To UBound(vPaperNames)
        Debug.Print vPaperNames(iCnt)
    Next iCNt
End Sub

Then just find the one you need and apply it to your code. The GetLocaleMediaName property only retrieves the name of a papersize it doesn't set it.

I am attempting to migrate my custom plot routines to VBA, and I am having a problem with the following code, I am at a loss as to how you set the paper size.  Any guidance would be appreciated...


Code: [Select]
Public Sub FULL_SIZE()

    ThisDrawing.ActiveLayout.RefreshPlotDeviceInfo
    Dim Layouts As AcadLayouts, Layout As AcadLayout
   
   
    Set Layouts = ThisDrawing.Layouts
    ThisDrawing.Regen acAllViewports

    With ThisDrawing.ActiveLayout
    .RefreshPlotDeviceInfo
    .GetPlotStyleTableNames
    .StyleSheet = "SFA1055.ctb"
    .ConfigName = "\\CENTRAL\HP DesignJet 500 42 by HP"
    .PlotRotation = ac0degrees
    .CenterPlot = True
    .PaperUnits = acInches
    .ScaleLineweights = False
    '.GetLocaleMediaName = "Oversize: Arch D (Landscape)"  <<This seems to be where the code fails!!>>
    .StandardScale = ac1_1
        End With
   
End Sub







EDIT: Wrapped your code in [ code ] tags for ya