Results 1 to 6 of 6

Thread: "Hello World" Routine - "Obviously haven't a clue..."

  1. #1
    100 Club
    Join Date
    2006-07
    Posts
    130
    Login to Give a bone
    0

    Default "Hello World" Routine - "Obviously haven't a clue..."

    I'm dipping my toe in the Revit API waters, AND learning VB.NET (using Visual Studio 200 at the same time, and would appreciate a little help. Here's what I\ve done:

    1. In VS2008, I created a new class library. I *do* see that it's ".NET Framework 3.5"--does this make a difference?

    2. In my new class ("PatricksClass"), I added a reference to "C:\Program Files\Revit Structure 2008\Program\RevitAPI.dll".

    3. Here's my code:

    Public Class PatricksClass
    Implements Autodesk.Revit.IExternalCommand

    Public Function Execute(ByVal commandData As Autodesk.Revit.ExternalCommandData, _
    ByRef message As String, _
    ByVal elements As Autodesk.Revit.ElementSet) _
    As Autodesk.Revit.IExternalCommand.Result _
    Implements Autodesk.Revit.IExternalCommand.Execute
    MsgBox("Hello World")
    Return Autodesk.Revit.IExternalCommand.Result.Succeeded
    End Function
    End Class

    (This is correctly indented in my program, but doesn't appear so here in the forum)

    4. In VS2008, I built the program.

    5. I edited "C:\Program Files\Revit Structure 2008\Program\Revit.ini" and added the following:

    [ExternalCommands]
    ECCount= 1
    ECName1= "Program01"
    ECClassName1=RevitProgram01.PatricksClass
    ECAssembly1=C:\Documents and Settings\pap\My Documents\Visual Studio 2008\Projects\RevitProgram01\RevitProgram01\bin\Release\RevitProgram01.dll
    ECDescription1="Displays a Greeting"

    (There are no line breaks in the ECAssembly1 line)
    6. I started Revit, and my command showed up in the "Tools\External Tools" menu. It's the only one in there. So, I clicked on it, and...nothing happens.

    Most of this is directly out of the AU2007 "ABCs of Programming in Revit" handout. TIA for any help in pointing out my error(s).

  2. #2
    100 Club
    Join Date
    2004-02
    Location
    Brookline, MA
    Posts
    186
    Login to Give a bone
    0

    Default Re: "Hello World" Routine - "Obviously haven't a clue..."

    Patrick,

    Everything looks right to me... And to the best of my knowledge, VS2008 / .NET 3.5 is supported (although I've only tested up to 3.0 personally).

    1. When something appears in your External Tools menu but nothing happens when you pick it, 99% of the time it means there is something wrong with your INI file entries.
    The only thing that I typically do differently than what you've done there is I tend to put the Assembly entry in double quotes (since there are spaces in the path). I don't think it's a problem anymore though (at least in my current build - Revit 2008 SP3).

    2. I presume that the "namespace" is RevitProgram01? If the namespace for your class was different, that would also cause this issue (although it seems unlikely based on how you've named everything else).

    3. VS2008 can build projects against .NET 2.0 as well, have you tried that?

    Best Regards,
    Matt



    That's my only suggestion...

    Best Regards,
    Matt

  3. #3
    100 Club
    Join Date
    2006-07
    Posts
    130
    Login to Give a bone
    0

    Default Re: "Hello World" Routine - "Obviously haven't a clue..."

    Matt! You nailed it! As I noted in my post, I'm *just* learning VB.NET. Consequently, I had no clue (this supports the subject) about namespaces. As soon as I fixed that, it ran.

    OK, now back to my second program...writing a complete replacement interface for Ramsteel. Well, maybe I'll pick something smaller. :^D

    Thanks, again.

  4. #4
    100 Club
    Join Date
    2007-10
    Location
    Brisbane
    Posts
    138
    Login to Give a bone
    0

    Default Re: "Hello World" Routine - "Obviously haven't a clue..."

    If you are goign to learn visual basic 2008, perhaps learning C# would be easier, depends on your background of course, but alot of the samples are in C# rather than visual basic.net

    If you don't like the bracketted interface of C# (takes some getting used to if you are a VB man) there are some resources to convert code from C# to VB - so when you get stuck, and you look at the samples, you can translate it back to something you understand better.

    something like this http://www.carlosag.net/Tools/CodeTr...r/Default.aspx

  5. #5
    100 Club
    Join Date
    2006-07
    Posts
    130
    Login to Give a bone
    0

    Default Re: "Hello World" Routine - "Obviously haven't a clue..."

    Quote Originally Posted by r.howarth View Post
    If you are going to learn visual basic 2008, perhaps learning C# would be easier,
    Thanks for the suggestion. I kick the idea around from time to time, but continue to fall back on what I'm used to. This might be a golden opportunity.

  6. #6
    100 Club
    Join Date
    2007-10
    Location
    Brisbane
    Posts
    138
    Login to Give a bone
    0

    Default Re: "Hello World" Routine - "Obviously haven't a clue..."

    Quote Originally Posted by ppirtle View Post
    Thanks for the suggestion. I kick the idea around from time to time, but continue to fall back on what I'm used to. This might be a golden opportunity.
    yeah I learnt VB in school and have always done VB work, when I finally pulled myself into the plunge I am loving it and can't see me going back. Also just been reading a book on java basics and its all pretty much the same syntax as C# which is handy.

Similar Threads

  1. Replies: 0
    Last Post: 2012-06-06, 11:54 AM
  2. Replies: 4
    Last Post: 2009-07-29, 09:43 PM
  3. Replies: 5
    Last Post: 2009-04-17, 10:10 AM
  4. ENTIDADES EN ALIGNMENT COMO "FIXED", "FLOTING" y "FREE"
    By cadia in forum AutoCAD Civil 3D - General
    Replies: 1
    Last Post: 2009-02-01, 04:21 AM
  5. Replies: 1
    Last Post: 2006-06-13, 06:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •