Author Topic: RootNamespace  (Read 23128 times)

0 Members and 1 Guest are viewing this topic.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: RootNamespace
« Reply #15 on: December 26, 2007, 12:43:17 PM »
Probably not, since you're just using it as a glorified texteditor for the vb samples. I recall someone saying all the code samples were snippets you add to the solution, is that correct?
Yes.  I opened one of the snippets to see if there were Namespace conflicts there, but couldn't find any
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: RootNamespace
« Reply #16 on: December 26, 2007, 12:49:18 PM »
I DL'd VB08, created a project manually without the wizard (Wasn't an option when I created new project) and did not generate the error msg and code ran fine.  Must be something inside the template files
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: RootNamespace
« Reply #17 on: December 26, 2007, 12:50:36 PM »
And, after learning how to make a snippet today, other than adding the references to the 2 ac*.dll files, why would I want to use that template?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: RootNamespace
« Reply #18 on: December 26, 2007, 12:50:51 PM »

Probably not, since you're just using it as a glorified texteditor for the vb samples. I recall someone saying all the code samples were snippets you add to the solution, is that correct?
Yes.  I opened one of the snippets to see if there were Namespace conflicts there, but couldn't find any

I'm guessing here ..
I'd guess it's a Template or Add-in.

Do you get the same issue if you build a project environment from scratch ? If not, you could save your own template from a 'good' project.
 File -> Export Template ...

ADDED:
I note that you've posted concurrently that you've done this. (I won't delete this post just in case the post police come along :D)
« Last Edit: December 26, 2007, 12:54:24 PM 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.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: RootNamespace
« Reply #19 on: December 26, 2007, 12:55:16 PM »
No, it doesn't generate the error.  I dont think I'll use that template anymore
Quote from: Kerry Brown
If not, you could save your own template from a 'good' project.
That was what I was thinking as well.  Thanks Kerry.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Fatty

  • Guest
Re: RootNamespace
« Reply #20 on: December 26, 2007, 12:57:12 PM »

Hi David,

What Add-In's are you using ? and which IDE ?

Does it display when the IDE opens or at build time ..
.. The message rings a bell, but I can't recall the details.

VbMgdAcad3 ?? is that the Project ?


VbMgdAcad is default project name of AutoCAD VB.NET Template
that installed from CD from this nice book:
"VB.NET Programming for AutoCAD Customization
VB.NET Training for AutoCAD 2007 and AutoCAD 2008"
by Jerry Winters
You can find it on www.vbcad.com
I have just one that I got as gift from my friend
Brian from California, God bless him for that


~'J'~




David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: RootNamespace
« Reply #21 on: December 26, 2007, 01:02:11 PM »
Yes, that is the 'book' being referenced.  Its a good book, and the examples are pretty well written.  I'm finding it pretty easy to move my VBA code to .Net using it as a guide.  On a side note, if you ever get the chance to attend one of his classes, do it.  Great speaker, and has a lot of good presentation skills that makes learning it easier.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: RootNamespace
« Reply #22 on: December 26, 2007, 01:29:19 PM »
Translating concepts to C# is a great idea.

I'd imagine that casting types for C# is one of the biggest differences.

 using (Transaction tr = tm.StartTransaction())
 {             
   BlockTable bt = (BlockTable)tm.GetObject(db.BlockTableId,OpenMode.ForRead,false);
   BlockTableRecord btr = (BlockTableRecord)tm.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite,false);


as opposed to something like this in vb

       Dim tr As Transaction = tm.StartTransaction()
       Try
           Dim bt As BlockTable = tm.GetObject(db.BlockTableId, OpenMode.ForRead, False)
           Dim btr As BlockTableRecord = tm.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False)


the vb compiler is more 'forgiving' about type safety ... but we won't go there ...
« Last Edit: December 26, 2007, 01:32:51 PM 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.

Fatty

  • Guest
Re: RootNamespace
« Reply #23 on: December 26, 2007, 01:36:47 PM »
Agreed with you, but I should't get a chance at all

~'J'~

Glenn R

  • Guest
Re: RootNamespace
« Reply #24 on: December 26, 2007, 02:21:59 PM »
First off, I sometimes get the error about 'RootNamespace' but I just ignore it, although I haven't investigated it (I suspect it's a timing issue with loading VS).

Secondly, WRT the copylocal thing I understand it as such:

When you compile a .exe, the framework will spin up an 'AppDomain' which is the framework's equivalent of a separate address space for the application to use (think WIN32 application isloation so a bad proggy won't bring windows to a GPF faster than you can say GPF) :)

Now, Acad spins up it's own AppDomain, which you load your .dll's into and all is good. Now with an AppDomain, there are rules for how it looks for supporting files (read dll's) and this is called 'probing' or assembly resolution ie how the main exe resolves and finds it's supporting files. From memory, this is the same folder as the exe or any sub-folders, but this probing can be modified by the yourExeName.exe.config file or in this case, the acad.exe.config file - I must stress that I would never, ever modify the base acad install and this DEFINATELY falls into this category.

So, you *could* modify the acad.exe.config and add the appropriate entries into this xml file to cause it to 'look' in different folders for additional files, but DON'T.

Hope this helps.
Merry Xmas from the UK.

Cheers,
Glenn.

Fatty

  • Guest
Re: RootNamespace
« Reply #25 on: December 26, 2007, 02:45:09 PM »
Late is better than never :)
Happy Chrismas from Russia


~'J'~

Glenn R

  • Guest
Re: RootNamespace
« Reply #26 on: December 26, 2007, 02:57:01 PM »
Merry Christmas to you too, Fatty.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: RootNamespace
« Reply #27 on: December 28, 2007, 10:02:46 AM »
David,

I had a look at one of the Methods from that book today.
It seemed a little verbose, so I had a look at an option in C# the way I thought I'd write it if I was trying to teach someone.

Here's the comparison.

The book VB code :
    <CommandMethod("DrawALineA")> _
       Sub DrawALineA()
        Dim myTransMan As DatabaseServices.TransactionManager
        Dim myTrans As DatabaseServices.Transaction
        Dim myDWG As ApplicationServices.Document
        Dim myBT As DatabaseServices.BlockTable
        Dim myBTR As DatabaseServices.BlockTableRecord

        'Get the active document and begin a Transaction
        myDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument
        myTransMan = myDWG.TransactionManager
        myTrans = myTransMan.StartTransaction

        'Open the BlockTable for Read
        myBT = myDWG.Database.BlockTableId.GetObject( _
            DatabaseServices.OpenMode.ForRead)
        myBTR = myBT(DatabaseServices.BlockTableRecord.ModelSpace).GetObject( _
            DatabaseServices.OpenMode.ForWrite)

        'Draw the line
        Dim StartPoint As New Geometry.Point3d(0, 0, 0)
        Dim EndPoint As New Geometry.Point3d(4, 5, 6)
        Dim myLine As New DatabaseServices.Line(StartPoint, EndPoint)
        myBTR.AppendEntity(myLine)
        myTrans.AddNewlyCreatedDBObject(myLine, True)

        'Commit the Transaction
        myTrans.Commit()

        myTrans.Dispose()
        myTransMan.Dispose()
    End Sub
   
 


my C# hack
       
[CommandMethod("Cmd1")]
    static public void AddLineToModelSpace()
    {
        // Calculate the Line extent
        Point3d startPoint = new Point3d(1, 2, 3);
        Point3d endPoint = new Point3d(4, 5, 6);

        // Start a Drawing DataBase Transaction
        Database db = AcadApp.DocumentManager.MdiActiveDocument.Database;
        using (Transaction tr = db.TransactionManager.StartTransaction())
        {
            // Define the Line
            Line lineEnt = new Line(startPoint, endPoint);

            ((BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db),
                    OpenMode.ForWrite, false)).AppendEntity(lineEnt);

            tr.AddNewlyCreatedDBObject(lineEnt, true);
            tr.Commit();
        }
    }


Now I'm sure the VB code could be trimmed, but why wasn't it ?


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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8659
  • AKA Daniel
Re: RootNamespace
« Reply #28 on: December 28, 2007, 10:14:45 AM »
...Now I'm sure the VB code could be trimmed, but why wasn't it ?

It’s probably because one needs to speak more slowly for VB users.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: RootNamespace
« Reply #29 on: December 28, 2007, 10:18:21 AM »
 Dim as joke


this could get out of hand ... but Mav's on holidays so it may be ok.
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.