code to plot drawing right justified?

Discussion in 'AutoCAD' started by ljb, Feb 22, 2005.

  1. ljb

    ljb Guest

    Does anyone have code to plot a drawing scaled to fit, right justified and
    centered vertically on a page? I have spent hours trying to get plotter
    paper margins, get drawing extents, adjust drawing scale and adjust plot
    origin but just can't seem to get it right. I'm trying to use 17"x11" paper
    and 1/4" margins all around with various drawing sizes that don't match that
    aspect ratio.

    thanks
    LJB
     
    ljb, Feb 22, 2005
    #1
  2. ljb

    ljb Guest

    I finally managed to solve the problem myself.

    Const InchToMM = 25.4
    Const DesiredMargine = 0.25 * InchToMM '1/4" margin converted to mm

    ExtLL(0) = CadDoc.GetVariable("extmin")(0) * InchToMM: ExtLL(1) =
    CadDoc.GetVariable("extmin")(1) * InchToMM
    ExtUR(0) = CadDoc.GetVariable("extmax")(0) * InchToMM: ExtUR(1) =
    CadDoc.GetVariable("extmax")(1) * InchToMM

    Set cadLayout = CadDoc.ActiveLayout
    With cadLayout

    .ConfigName = "Xerox DocuTech 6135 (01.02.00)"
    .RefreshPlotDeviceInfo
    .CanonicalMediaName = "Ledger"
    .PlotWithPlotStyles = True
    .StyleSheet = "butler.ctb"
    .PlotRotation = ac0degrees
    .PlotType = acExtents
    .CenterPlot = False

    .GetPaperSize PaperWidth, PaperHeight
    .GetPaperMargins LLMargin, URMargin

    DwgWidth = ExtUR(0) - ExtLL(0)
    DwgHeight = ExtUR(1) - ExtLL(1)

    DwgScaleFactor = (PaperWidth - 2 * DesiredMargine) / DwgWidth
    If DwgScaleFactor > (PaperHeight - 2 * DesiredMargine) / DwgHeight
    Then
    DwgScaleFactor = (PaperHeight - 2 * DesiredMargine) / DwgHeight
    End If

    .SetCustomScale DwgScaleFactor, 1

    OffsetX = PaperWidth - DesiredMargine - DwgWidth * DwgScaleFactor
    OffsetY = PaperHeight - DesiredMargine - DwgHeight * DwgScaleFactor

    OrgOffset(0) = OffsetX - DesiredMargine + LLMargin(0)
    OrgOffset(1) = OffsetY - DesiredMargine + LLMargin(1)

    .PlotOrigin = OrgOffset

    .RefreshPlotDeviceInfo
    End With
    CadDoc.Plot.PlotToFile strName
     
    ljb, Feb 24, 2005
    #2
  3. ljb

    MP Guest

    Glad you got it working. Those margins can be a bear. Luckily another guy
    here has to mess with all that.

    Just a tiny observation on the code...
    you might consider setting a var instead of calling getvariable twice
    and you could use another With clause if you wanted to wrap the doc calls as
    well
    (very minor points)

    With CadDoc
    vmin = .GetVariable("extmin")
    vmax = .GetVariable("extmax")
    ExtLl(0) = vmin(0) * InchToMM: ExtLl(1) = vmin(1) * InchToMM
    ExtUr(0) = vmax(0) * InchToMM: ExtUr(1) = vmax(1) * InchToMM
    Set cadLayout = .ActiveLayout
    With cadLayout
    etc
    End With 'CadLayout
    .Plot.PlotToFile strName
    End With 'CadDoc

    Mark
     
    MP, Feb 24, 2005
    #3
  4. ljb

    ljb Guest

    Thanks for the comments. Not only was I interested in margins, and right
    justifying the drawing on the paper, I also need to rescale some of the
    drawings. It was a bear.

    I will implement the changes you noted.

    Thanks
    LJB
     
    ljb, Feb 24, 2005
    #4
  5. ljb

    MP Guest

    I also need to rescale some of the drawings.

    I'm guessing you're still with Butler? And further that some of their shop
    dwgs are not necessarily "to scale"
    That's the only way I can think how you can "get away with" scaling the dwg
    to fit a page? (since you mentioned earlier a different aspect ratio)

    :)
    Mark
    ps
    Thanks for sharing your success with the ng.
    I'll tuck that away for the day when *I* need to deal with the plotting
    issues!
    :)
     
    MP, Feb 24, 2005
    #5
  6. ljb

    ljb Guest

    You got it! Are you familiar with Butler? Nothing is to scale around here.
    To scale our structural steel detailing would result in drawings looking
    like sticks with a little smudge of holes near each end. One of our CAD
    systems (AutoTrol GS5000) produces drawings with different X and Y scale now
    often being imported into AutoCAD from DXF files.
     
    ljb, Feb 24, 2005
    #6
  7. ljb

    MP Guest

    Hey, everyone in KC is familiar with Butler aren't they?
    Yep, I know the concept of that kind of detailing - it's all about
    information.
    If you're used to having everything to scale they look funny at first, but
    like you say, that's the only way to clearly convey the information - which
    is the important part.
     
    MP, Feb 24, 2005
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.