.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

hello world vb.net

7 REPLIES 7
Reply
Message 1 of 8
jorge.friet
1791 Views, 7 Replies

hello world vb.net

hi all

i am new to vb.net (always used vba enabler but wanted to make the change to vb.net )

i am using this tutorial from autodesk but is for an older version of autocad 2010

and i am using autocad 2014 and objectarx2014

http://usa.autodesk.com/adsk/servlet/index?id=770215&siteID=123112

and i searched this site for some answers and when i build it i dont get any errors but when i load it into autocad

and use the myroutine i get an error and the application doesnt function

 

Imports System
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common

Imports Autodesk.AutoCAD.ApplicationServices.DocumentExtension


Public Class AdskCommands
    Public ReadOnly Property ThisDrawing() As AcadDocument
        Get
            Return Application.DocumentManager.MdiActiveDocument.GetAcadDocument()
        End Get
    End Property

    <Autodesk.AutoCAD.Runtime.CommandMethod("myroutine")> _
    Public Sub myRoutine()
        ThisDrawing.Utility.Prompt("Hello World from .NET")
    End Sub
End Class

 

i added all the references and put all local copy to false

anyone a idea what i do wrong?

 

 

 

7 REPLIES 7
Message 2 of 8
jeff
in reply to: jorge.friet

Imports Autodesk.AutoCAD.ApplicationServices.DocumentExten​sion

That namespace was added in 2013 or maybe later, but fairly certain it was after 2010.

 

That is for VBA here is turtorial for VB.NET

http://usa.autodesk.com/adsk/servlet/index?id=18162650&siteID=123112

Its starts off with a topic thats considered advanced.

 

If you plan on using COM objects and nothing wrong at all with using them if they provide all you need, but would not waste time learning .NET environment just to use them. On the hand if your wanting to learn for AutoCAD and many other areas it i used for then look at .NET developers guide.

Earliest they have is 2012

http://exchange.autodesk.com/autocad/enu/online-help/browse#WS73099cc142f48755a52158612bd434e551-7fd...

 

 

 

You can also find your answers @ TheSwamp
Message 3 of 8
_gile
in reply to: jorge.friet

Hi,
 
If you want to learn .NET, my first advice would be: avoid to code "as with VBA" (i.e. avoid using the COM API).
And to help you in this direction, forget VB,
learn C # instead (you'll find more samples in C #).
C # is not more difficult than VB (only more strinct, which is a good thing); it's .NET which is
long to learn, whatever the used language.
 
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;

namespace HelloWorld
{
    public class AdskCommands
    {
        [CommandMethod("Hello")]
        public void HelloWorld()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            ed.WriteMessage("Hello World from .NET (C#)");
        }
    }
}


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 4 of 8
jorge.friet
in reply to: _gile

hi _gile

 

thx for the advice maybe u are right 

and will give C# a try 

but i was  write in the past programs in vba for autocad and vb.net for revit seemed like the  right option 

thanks again 

Message 5 of 8
jorge.friet
in reply to: jeff

hi jeff thanks for ur answer

i will look into this too

Message 6 of 8
SENL1362
in reply to: _gile

I totally agree with Gilles, if free of choice go for C#. More samples and the preferred language of Microsoft as you can see in PowerShell. It's the successor for the DOS shell, build in Windows 7, 8 2008 etc. It understand DOS, Linux commands AND C#'s Net framework. And above all it's NOT Case Sensitive. To my opinion that's the biggest bump you have to take coming from VB(A).

Message 7 of 8
Keith.Brown
in reply to: SENL1362


@SENL1362 wrote:

 And above all it's NOT Case Sensitive.


Maybe I misunderstood what you were trying to say but I belive that the above is an incorrect statement.  C# is a case sensitive language.  A variable with the name of "total" is not the same as a variable with the name of "Total" or "toTal".  They are seperate and distinctive variable names in C#.  This makes it a case sensitive language. 

 

Message 8 of 8
SENL1362
in reply to: Keith.Brown

Hello Keith,

What i was trying to say is that c# is case sensitive, but PowerShell is not, and still be able to use c# like language.

See the sample below, the PowerShell variable  $Window is the same as $window set to a static instance of a .NET class

 

Now i need less attension to "syntax" and can focus more on the real problems.

 

 

powershell1.png

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost