Author Topic: Overrule not working in 2012  (Read 1589 times)

0 Members and 1 Guest are viewing this topic.

Jeff H

  • Needs a day job
  • Posts: 6144
Overrule not working in 2012
« on: August 02, 2011, 04:52:08 PM »
Any idea why this works in 2011 and not 2012?

To be more specific when you use the 'ToggleOverrule' comand below in 2011 it changes all lines to circles and call it again then they change back to lines and keeps changing each time you call it.

In 2012 when you call 'ToggleOverrule'  it changes the lines to circles but will never change back. It will not turn off the overrule in 2012
 
The line 
Code: [Select]
Overrule.Overruling = Not Overrule.Overruling
and have tried hard-coding to false but it never changes it false.


Code is from Stephen Preston's class
http://au.autodesk.com/?nd=class&session_id=7560
Code: [Select]
Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput

' This line is not mandatory, but improves loading performances
<Assembly: CommandClass(GetType(MyFirstOverrule_VB.MyCommands))>

Namespace MyFirstOverrule_VB

    'This is our custom DrawableOverrule class.
    'In this case we're just overruling WorldDraw
    Public Class MyDrawOverrule
        Inherits Autodesk.AutoCAD.GraphicsInterface.DrawableOverrule


        Public Overrides Function WorldDraw(ByVal drawable As Autodesk.AutoCAD.GraphicsInterface.Drawable, ByVal wd As Autodesk.AutoCAD.GraphicsInterface.WorldDraw) As Boolean
            'Cast Drawable to Line so we can access its methods and properties
            Dim thisLine As Line = drawable
            'Draw some graphics primitives
            wd.Geometry.Circle(thisLine.StartPoint + 0.5 * thisLine.Delta, thisLine.Length / 2, thisLine.Normal)
            'In this case we don't want the line to draw itself, nor do we want ViewportDraw called
            Return True
            'Return MyBase.WorldDraw(drawable, wd)
        End Function

    End Class



    Public Class myCommands

        'Shared member variable to store our Overrule instance
        Private Shared mDrawOverrule As MyDrawOverrule

        ' Define Command "TOGGLEOVERRULE"
        <CommandMethod("TOGGLEOVERRULE")> _
        Public Shared Sub MyCommand()
            ' Initialize Overrule if this is the first time this function has run
            If mDrawOverrule Is Nothing Then
                mDrawOverrule = New MyDrawOverrule
                Overrule.AddOverrule(RXObject.GetClass(GetType(Line)), mDrawOverrule, False)
            End If

            'Toggle Overruling on/off
            Overrule.Overruling = Not Overrule.Overruling
            'Regen is required to update changes on screen.
            Application.DocumentManager.MdiActiveDocument.Editor.Regen()
        End Sub

    End Class

End Namespace


Jeff H

  • Needs a day job
  • Posts: 6144
Re: Overrule not working in 2012
« Reply #1 on: August 02, 2011, 06:23:10 PM »
Not sure if this is best way but this makes it work 2012

Changing
Code: [Select]
Overrule.Overruling = Not Overrule.Overruling
to
Code: [Select]
            If mDrawOverrule Is Nothing Then
                mDrawOverrule = New MyDrawOverrule
                Overrule.AddOverrule(RXObject.GetClass(GetType(Line)), mDrawOverrule, False)
            Else
                Overrule.Overruling = False
                Overrule.RemoveOverrule(RXObject.GetClass(GetType(Line)), mDrawOverrule)
                mDrawOverrule = Nothing
            End If