Author Topic: Palettes Revisited  (Read 7629 times)

0 Members and 1 Guest are viewing this topic.

DBARANAS

  • Guest
Palettes Revisited
« on: October 21, 2006, 03:14:35 AM »
During the last few months I have been exploring the ways to get my apps GUI to be efficeint and slick. When I was a CAD monkey I had to endure to torture of navigating through menu structures in plain Autocad. In a production environment trying to crank out drawings everyday do the same things over and over again (navigating menus) gets boring and painful.

Recently I ran across this:

http://www.codeproject.com/cs/miscctrl/TgXPPanel.asp?df=100&forumid=59468&exp=0&select=1337707

This control is not yet implemented in VS.....but it ROCKS!!!!!

Put this in a palette and it changes everything. I had to tweek it up a bit by killing off the other panels when I clicked on the panel I wanted to display. Now I have the same thing as the tabs in the stock palette but I don't have read sideways when I want to go somewhere else. Think of the user doing this all day long :ugly:

The guy that wrote this should be given a .Net hero award.

The next thing I would like to happen is to get rid of the menu structure in Autocad and not even see it anymore.

Here is what I am so happy about.


DBARANAS

  • Guest
Even Better
« Reply #1 on: October 21, 2006, 03:35:21 AM »
OverRiding the Right Click event when an object is selected and displaying what is exactly available to the user has got to speed things up.  :lol:

Code: [Select]
Imports System
Imports System.Windows.Forms

Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.EditorInput
Imports AcAp = Autodesk.AutoCAD.ApplicationServices.Application
Imports AcOp = Autodesk.AutoCAD.Interop
Imports AcRu = Autodesk.AutoCAD.Runtime
Public Class AcadDocumentRightClick
    Private _AcadDocument As AcOp.AcadDocument
    Public Sub RightClick()

        If _AcadDocument Is Nothing Then
            _AcadDocument = CType(AcAp.DocumentManager.MdiActiveDocument.AcadDocument, _
            Autodesk.AutoCAD.Interop.AcadDocument)
            AddHandler _AcadDocument.BeginRightClick, AddressOf _AcadDocument_BeginRightClick
        Else

            RemoveHandler _AcadDocument.BeginRightClick, AddressOf _AcadDocument_BeginRightClick
            _AcadDocument = Nothing
        End If

    End Sub
    Private Sub _AcadDocument_BeginRightClick(ByVal PickPoint As Object)

        Dim MdiActiveDocument As Document = AcAp.DocumentManager.MdiActiveDocument
        Dim GetSelection As PromptSelectionResult = MdiActiveDocument.Editor.GetSelection()
        Using DocumentLock As DocumentLock = MdiActiveDocument.LockDocument()
            If GetSelection.Status <> PromptStatus.OK Then Return
            If GetSelection.Value.Count <> 1 Then Return
            Dim ObjectId As ObjectId = GetSelection.Value(0).ObjectId
            Using Transaction As Transaction = MdiActiveDocument.TransactionManager.StartTransaction()
                Dim DBObject As DBObject = Transaction.GetObject(ObjectId, DatabaseServices.OpenMode.ForWrite)
                Dim Entity As Entity = TryCast(DBObject, Entity)
                If Entity Is Nothing Then Return
                Dim RightClickWall As New frmRightClickWall
                AcAp.ShowModalDialog(RightClickWall)
                Transaction.Abort()
            End Using
        End Using

    End Sub

End Class

Public Class AcadDocumentDoubleClick
    Private _AcadDocument As Autodesk.AutoCAD.Interop.AcadDocument
    Public Sub DoubleClick()

        If _AcadDocument Is Nothing Then
            _AcadDocument = CType(AcAp.DocumentManager.MdiActiveDocument.AcadDocument, _
            Autodesk.AutoCAD.Interop.AcadDocument)
            AddHandler _AcadDocument.BeginDoubleClick, AddressOf _AcadDocument_BeginDoubleClick
        Else
            RemoveHandler _AcadDocument.BeginDoubleClick, AddressOf _AcadDocument_BeginDoubleClick
            _AcadDocument = Nothing
        End If

    End Sub
    Private Sub _AcadDocument_BeginDoubleClick(ByVal PickPoint As Object)

        Dim MdiActiveDocument As Document = AcAp.DocumentManager.MdiActiveDocument
        Dim SelectImplied As PromptSelectionResult = MdiActiveDocument.Editor.SelectImplied()
        Using DocumentLock As DocumentLock = MdiActiveDocument.LockDocument()
            If SelectImplied.Status <> PromptStatus.OK Then Return
            If SelectImplied.Value.Count <> 1 Then Return
            Dim ObjectId As ObjectId = SelectImplied.Value(0).ObjectId
            Using Transaction As Transaction = MdiActiveDocument.TransactionManager.StartTransaction()
                Dim DBObject As DBObject = Transaction.GetObject(ObjectId, DatabaseServices.OpenMode.ForWrite)
                Dim Entity As Entity = TryCast(GetObject(), Entity)
                If Entity Is Nothing Then Return

                Dim DBDictionary As DBDictionary = Transaction.GetObject(Entity.ExtensionDictionary(), _
                DatabaseServices.OpenMode.ForWrite, False)

                Dim Xrecord As Xrecord
                Xrecord = Transaction.GetObject(DBDictionary.GetAt("EntityData"), DatabaseServices.OpenMode.ForRead)
                Dim ObjectType As TypedValue = Xrecord.Data.AsArray(0)
                Dim MyObjectID As TypedValue = Xrecord.Data.AsArray(1)
                Select Case ObjectType.Value
                    Case "Wall"
                        Walls.Adjust(Walls.Find(Walls.ID), Enu.Adjust.UnHighlite)
                        Dim Wall As _Wall = Walls.Find(MyObjectID.Value)
                        Walls.ID = Wall.ID
                        ctlProject.PropertyGrid1.SelectedObject = WallItems
                        ctlProject.SplitContainer2.Panel2Collapsed = True
                        Walls.Adjust(Wall, Enu.Adjust.Highlite)
                End Select
                Transaction.Commit()

            End Using
        End Using
    End Sub

End Class

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Palettes Revisited
« Reply #2 on: October 21, 2006, 03:55:46 AM »
Dave .. is this acceptable as used ?
Quote
Dim Entity As Entity = TryCast(DBObject, Entity)

ditto for
Quote
Using Transaction As Transaction

Quote
Dim DBObject As DBObject


I haven't had a real chance to look at the code, but just as a matter of interest, why do you use so much Com ?
Which Acad version is this for ?
« Last Edit: October 21, 2006, 03:57:23 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Palettes Revisited
« Reply #3 on: October 21, 2006, 03:58:48 AM »
The Menu's look really interesting ..
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

DBARANAS

  • Guest
Re: Palettes Revisited
« Reply #4 on: October 21, 2006, 04:03:05 AM »
Hi Kerry

It seems to work. Mostly I can get away with naming things like the type they belong to.

It makes for easily readable code. In a few instances it thows up and I have to pick a new name for the instance of the object I am trying to create.


Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Palettes Revisited
« Reply #5 on: October 21, 2006, 04:10:39 AM »
I may misunderstand ..

DBObject is the base type for objects stored in the AutoCAD database.

.. how can you use a variable named the same and declare it's type to be the same as the name you are using .. ?

.. this may be an indicator of my lack of familiarity with VBNet.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Palettes Revisited
« Reply #6 on: October 21, 2006, 04:13:35 AM »
what happens if you add Option Strict << or whatever >> to the head of your code ??

.. or is that Option Explicit ?
« Last Edit: October 21, 2006, 04:20:30 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

DBARANAS

  • Guest
Re: Palettes Revisited
« Reply #7 on: October 21, 2006, 04:14:58 AM »
This if for 2k7 and If I can lose the COM I will do it too.

I ran across another UCS post in the AD group that solves my Twist UCS problem that also uses COM.  I think we are on the rough edge now and I have to suck a few things up and get on with finishing my project. I came here 4 months ago as a .Net newbe with a finished project in VBA except it leaked tons of memory and I could never even finish a project before things would crash and burn.

The whole .Net way and OOP has changed my whole view of things, I have basically rewritten my app in 4 months after 3 years of pain...either I am going to win or hang myself

DBARANAS

  • Guest
Re: Palettes Revisited
« Reply #8 on: October 21, 2006, 04:21:46 AM »
I may misunderstand ..

DBObject is the base type for objects stored in the AutoCAD database.

.. how can you use a variable named the same and declare it's type to be the same as the name you are using .. ?

.. this may be an indicator of my lack of familiarity with VBNet.
[/quote

Kerry I might be way off the wall with this naming convention stuff but the code runs and when I debug things it is easy to read.

I have been though camel,pascal, and my own conveluted abortion naming conventions.

It works and I do not have any project team supporting me...I am totally on my own trying to deliiver a product. I come at everything like an idiot, I only got as far a grade 8 in school. So I have hacked my way through every problem

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Palettes Revisited
« Reply #9 on: October 21, 2006, 04:23:29 AM »
Quote
I think we are on the rough edge ...
hehehehe
.. bleeding edge actually ..

Quote
.. either I am going to win or hang myself ..

yeah, I know the feeling. :-)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Palettes Revisited
« Reply #10 on: October 21, 2006, 04:28:57 AM »
Heh :-) Dave, I know about the hacking stuff .. suck it and see <- thats me.

I'm just surprised the compiler will let you use variables names the same as Autodesk classes ... a real puzzle to me. Perhaps I recall incorrectly, and as I said, VB is NOT my language.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

DBARANAS

  • Guest
Re: Palettes Revisited
« Reply #11 on: October 21, 2006, 04:33:12 AM »
Heh :-) Dave, I know about the hacking stuff .. suck it and see <- thats me.

I'm just surprised the compiler will let you use variables names the same as Autodesk classes ... a real puzzle to me. Perhaps I recall incorrectly, and as I said, VB is NOT my language.

Hey Kerry

I have not heard "Bleeding Edge" for the last 10 years!!!!!

I lived on it for 20 years...maybe I should check my pulse and see if there is any blood left inside.  :lmao:

DBARANAS

  • Guest
Re: Palettes Revisited
« Reply #12 on: October 21, 2006, 04:47:23 AM »
Anyway this naming convention scheme I have hit upon might seem different, but when I read lines of code when I have to debug things I know exactly what that line means without having to use any mental thought.

Just like I said about being a CAD monkey drafting doing the same things repetively and how that becomes a drag, being a CODE monkey I can eliminate that mental thought every time I look at a line of code that is cacking up that I wrote so long ago I can't even remember exactly why I even wrote it.

Maybe I am going to smash into a wall soon by doing this, but for now I am driving a race car with 600HP under the hood. :evil:

DBARANAS

  • Guest
Re: Palettes Revisited
« Reply #13 on: October 21, 2006, 05:06:23 AM »
BTW when I get my app finished this is the 600HP crash/pass car my company sponsers that I helped build and will get to have fun with :lol:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Palettes Revisited
« Reply #14 on: October 21, 2006, 05:27:31 AM »
OMG !! is that an 10" steel channel bolted to the body



[see, I do know what an inch is :-) ]
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

DBARANAS

  • Guest
Re: Palettes Revisited
« Reply #15 on: October 21, 2006, 05:44:25 AM »
OMG !! is that an 10" steel channel bolted to the body



[see, I do know what an inch is :-) ]

Kerry go here:

http://www.saratogaspeedway.bc.ca/

Road Rage to its extreme. This is just 30km south of my factory. You gotta love Vancouver Island. Even Bill gates bought an island up here.