Problems with CanonicalMediaName

Discussion in 'AutoCAD' started by Miles, May 25, 2004.

  1. Miles

    Miles Guest

    All,
    I have spent countless hours working this last detail of a custom plotting
    app. No matter what I try, search for, etc. I cannot get it working. I
    repeatedly receive a "Run-time error '-2145386493 (80200003) Invalid input'
    error.

    We have 2 PC3s, CLASER and BLASER, both have "Letter" as a papersize, one
    has "11x17" the other has "Ledger". The problem I am having is when
    switching devices, because the papersizes do not match, I get the above
    error when trying to assign the papersize to the .CanonicalMediaName
    property. Every other property works just fine, except this one.

    Can someone please put an end to my nightmare ?

    Public Sub CreatePageSetup()
    Dim strView As String
    Dim intCheckView As Integer

    Dim oPlotCon As AcadPlotConfiguration
    Dim vPaper As Variant, vPlotter As Variant
    Dim sPaper(0 To 4) As String
    Dim dOffset(0 To 1) As Double
    Dim i, ii As Integer

    Set oPlotConfigs = ThisDrawing.PlotConfigurations
    ThisDrawing.PaperSpace.Layout.RefreshPlotDeviceInfo

    intCheckView = 0

    For i = 0 To lstViews.ListCount - 1 Step 1
    If lstViews.Selected(i) = True Then
    intCheckView = 1

    For Each objView In objViews
    strView = objView.Name
    If strView = lstViews.List(i) Then
    strView = objView.Name
    Set oPlotCon = ThisDrawing.PlotConfigurations.Add(strView,
    False)
    vPlotter = oPlotCon.GetPlotDeviceNames

    oPlotCon.configName = cmbPC3.Value 'CLASER.PC3 or BLASER.PC3

    vPaper = oPlotCon.GetCanonicalMediaNames
    For ii = LBound(vPaper) To UBound(vPaper)
    Select Case oPlotCon.GetLocaleMediaName(vPaper(ii))
    Case "Letter"
    sPaper(0) = vPaper(ii)
    Case "11x17"
    sPaper(1) = vPaper(ii)
    Case "Ledger"
    sPaper(2) = vPaper(ii)
    End Select
    Next

    If cmbPC3.Value = "CLASER.PC3" Then
    If cmbPaperSize.Value = "(A) 8x11" Then
    oPlotCon.CanonicalMediaName = sPaper(0)
    ElseIf cmbPaperSize.Value = "(B) 11x17" Then
    oPlotCon.CanonicalMediaName = sPaper(1)
    End If
    End If

    If cmbPC3.Value = "BLASER.PC3" Then
    If cmbPaperSize.Value = "(A) 8x11" Then
    oPlotCon.CanonicalMediaName = sPaper(0)
    ElseIf cmbPaperSize.Value = "(B) 11x17" Then
    oPlotCon.CanonicalMediaName = sPaper(2)
    End If
    End If

    dOffset(0) = 0
    dOffset(1) = 0

    oPlotCon.ViewToPlot = strView
    oPlotCon.PlotOrigin = dOffset
    oPlotCon.PlotRotation = ac90degrees
    oPlotCon.StyleSheet = cmbCTB.Value ' "CLASER.CTB"
    oPlotCon.PlotType = acView

    ThisDrawing.PaperSpace.Layout.RefreshPlotDeviceInfo

    End If
    Next objView
    End If
    Next i

    If intCheckView = 0 Then MsgBox "ERROR : You must select at least 1 view"
     
    Miles, May 25, 2004
    #1
  2. Miles

    Ed Jobe Guest

    Try this and see what you get in the Immediate window.

    Sub test1()
    Debug.Print ThisDrawing.ActiveLayout.CanonicalMediaName
    End Sub

    The media names are not what's listed in the dialog, but an index name. The text string listing the paper size is just one of the media's properties.

    --
    ----
    Ed
    ----
    All,
    I have spent countless hours working this last detail of a custom plotting
    app. No matter what I try, search for, etc. I cannot get it working. I
    repeatedly receive a "Run-time error '-2145386493 (80200003) Invalid input'
    error.

    We have 2 PC3s, CLASER and BLASER, both have "Letter" as a papersize, one
    has "11x17" the other has "Ledger". The problem I am having is when
    switching devices, because the papersizes do not match, I get the above
    error when trying to assign the papersize to the .CanonicalMediaName
    property. Every other property works just fine, except this one.

    Can someone please put an end to my nightmare ?

    Public Sub CreatePageSetup()
    Dim strView As String
    Dim intCheckView As Integer

    Dim oPlotCon As AcadPlotConfiguration
    Dim vPaper As Variant, vPlotter As Variant
    Dim sPaper(0 To 4) As String
    Dim dOffset(0 To 1) As Double
    Dim i, ii As Integer

    Set oPlotConfigs = ThisDrawing.PlotConfigurations
    ThisDrawing.PaperSpace.Layout.RefreshPlotDeviceInfo

    intCheckView = 0

    For i = 0 To lstViews.ListCount - 1 Step 1
    If lstViews.Selected(i) = True Then
    intCheckView = 1

    For Each objView In objViews
    strView = objView.Name
    If strView = lstViews.List(i) Then
    strView = objView.Name
    Set oPlotCon = ThisDrawing.PlotConfigurations.Add(strView,
    False)
    vPlotter = oPlotCon.GetPlotDeviceNames

    oPlotCon.configName = cmbPC3.Value 'CLASER.PC3 or BLASER.PC3

    vPaper = oPlotCon.GetCanonicalMediaNames
    For ii = LBound(vPaper) To UBound(vPaper)
    Select Case oPlotCon.GetLocaleMediaName(vPaper(ii))
    Case "Letter"
    sPaper(0) = vPaper(ii)
    Case "11x17"
    sPaper(1) = vPaper(ii)
    Case "Ledger"
    sPaper(2) = vPaper(ii)
    End Select
    Next

    If cmbPC3.Value = "CLASER.PC3" Then
    If cmbPaperSize.Value = "(A) 8x11" Then
    oPlotCon.CanonicalMediaName = sPaper(0)
    ElseIf cmbPaperSize.Value = "(B) 11x17" Then
    oPlotCon.CanonicalMediaName = sPaper(1)
    End If
    End If

    If cmbPC3.Value = "BLASER.PC3" Then
    If cmbPaperSize.Value = "(A) 8x11" Then
    oPlotCon.CanonicalMediaName = sPaper(0)
    ElseIf cmbPaperSize.Value = "(B) 11x17" Then
    oPlotCon.CanonicalMediaName = sPaper(2)
    End If
    End If

    dOffset(0) = 0
    dOffset(1) = 0

    oPlotCon.ViewToPlot = strView
    oPlotCon.PlotOrigin = dOffset
    oPlotCon.PlotRotation = ac90degrees
    oPlotCon.StyleSheet = cmbCTB.Value ' "CLASER.CTB"
    oPlotCon.PlotType = acView

    ThisDrawing.PaperSpace.Layout.RefreshPlotDeviceInfo

    End If
    Next objView
    End If
    Next i

    If intCheckView = 0 Then MsgBox "ERROR : You must select at least 1 view"
     
    Ed Jobe, May 25, 2004
    #2
  3. Miles

    Miles Guest

    Thank you for your reply. I am not kidding when I saw "I swear I've tried this before...", but, changing the
    code to this:

    If cmbPC3.Value = "CLASER.PC3" Then
    If cmbPaperSize.Value = "(A) 8x11" Then
    oPlotCon.CanonicalMediaName = "Letter"
    ElseIf cmbPaperSize.Value = "(B) 11x17" Then
    oPlotCon.CanonicalMediaName = "11x17"
    End If
    End If

    If cmbPC3.Value = "BLASER.PC3" Then
    If cmbPaperSize.Value = "(A) 8x11" Then
    oPlotCon.CanonicalMediaName = "Letter"
    ElseIf cmbPaperSize.Value = "(B) 11x17" Then
    oPlotCon.CanonicalMediaName = "Tabloid"
    End If
    End If

    doesn't give me any error. So far so good. I need to do some more testing, but your post put
    me on the right track, btw, the debug.print was correctly displaying the paper names.

    Off to do more testing =)
    Try this and see what you get in the Immediate window.

    Sub test1()
    Debug.Print ThisDrawing.ActiveLayout.CanonicalMediaName
    End Sub

    The media names are not what's listed in the dialog, but an index name. The text string listing the paper size is just one of the media's properties.
     
    Miles, May 25, 2004
    #3
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.