Error message for me only - Type Mismatch

Discussion in 'AutoCAD' started by Robert Plummer, Jul 2, 2004.

  1. When I run the routine below on my machine, it completes successfully. When
    I run it on another machine, it returns the error "Runtime error 13 - Type
    Mismatch" and debug grabs on to the line "Set acadplot =
    ThisDrawing.ActiveLayout". What could be unique about my machine to cause
    this?


    Public Sub resetWipeoutsInBlocks()
    Dim entity As AcadEntity
    Dim BlockEntity As AcadEntity
    Dim BlockDefinition As acadBlock
    Dim BlockRef As AcadBlockReference
    Dim strLayerName As String
    Dim wptLayer As AcadLayer
    Dim acadplot As AcadPlotConfiguration
    Dim sysVar As String
    Dim sysData As Integer

    strLayerName = "A-ANNO-MASK"

    sysVar = "PSTYLEMODE"
    sysData = ThisDrawing.GetVariable(sysVar)

    If sysData = 1 Then
    MsgBox "This drawing is not set to Named Plot Styles. Use
    CONVERTPSTYLES command first."
    End
    End If

    Set acadplot = ThisDrawing.ActiveLayout
    ThisDrawing.ActiveLayout.RefreshPlotDeviceInfo
    ThisDrawing.ActiveLayout.GetPlotStyleTableNames

    If ThisDrawing.ActiveSpace = acPaperSpace Then
    ThisDrawing.ActiveSpace = acModelSpace
    acadplot.StyleSheet = "Gensler Plot Style.stb"
    ThisDrawing.ActiveSpace = acPaperSpace
    Else
    acadplot.StyleSheet = "Gensler Plot Style.stb"
    End If

    On Error Resume Next
    Set wptLayer = ThisDrawing.Layers(strLayerName)

    If wptLayer Is Nothing Then
    Set wptLayer = ThisDrawing.Layers.Add(strLayerName)
    End If

    ThisDrawing.SendCommand "-layer" & vbCr & "PStyle" & vbCr & "0% Screen" &
    vbCr & "A-ANNO-MASK" & vbCr & vbCr

    For Each BlockDefinition In ThisDrawing.Blocks
    If Not (BlockDefinition.IsLayout) And Not (BlockDefinition.IsXRef)
    And Not (BlockDefinition.Name = "Ref_Pt") Then
    For Each BlockEntity In BlockDefinition
    If TypeOf BlockEntity Is IAcadRasterImage Then
    On Error Resume Next
    BlockEntity.Layer = strLayerName
    BlockEntity.color = 255
    BlockEntity.Update
    BlockEntity.PlotStyleName = "ByLayer"
    ElseIf TypeOf BlockEntity Is AcadAttribute Then
    Else
    End If
    Next BlockEntity
    End If
    Next BlockDefinition

    ThisDrawing.Regen acAllViewports

    wptLayer.Delete

    End Sub
     
    Robert Plummer, Jul 2, 2004
    #1
  2. ThisDrawing.ActiveLayout is an "acadlayout" not an "acadplotconfiguration"
     
    Jorge Jimenez, Jul 2, 2004
    #2
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.