PDA

View Full Version : New to VBA



BeKirra
2012-12-13, 09:50 PM
Hi All,
I'm new in this VBA forum and know 0.00% of VBA.
I know that AutoLisp is a drawing level language.
I am now going to learn some basic of VBA.
To start, could anyone please give me some help on which can be functional when a drawing is open.
Here is a sample:


If a specified drawing (in folder "C:\Test", for example) is open, set "LTscale" to 0.5.

Thanks in advance.

BlackBox
2012-12-13, 10:23 PM
If you're looking to learn a higher level development language, then I would strongly suggest that you instead look into the .NET (C#,F#,VB,etc.) API in lieu of VBA, as it is no longer supported, and the newer application versions are increasingly exposing API features to the .NET API.

The only other alternative I can think of would be the ObjectARX (C++ for AutoCAD) API.

Good luck! :beer:

BeKirra
2012-12-14, 01:09 AM
Thanks RenderMan.
I will post the same question to ".NET" forum though.

arshiel88
2012-12-15, 08:05 AM
...


If a specified drawing (in folder "C:\Test", for example) is open, set "LTscale" to 0.5.



Sorry, cant resist. :D But just for fun, that would translate to:


Dim aDoc As AcadDocument
For Each aDoc In Documents
If aDoc.FullName = "C:\Test\SomeDrawing.dwg" Then
ThisDrawing.SetVariable "LTSCALE", 0.5
MsgBox "The value of LTSCALE is now " & ThisDrawing.GetVariable("LTSCALE") & "."
End If
Next


But, I would strongly encourage you to go for .NET while you're at the least knowledge on VBA. Because when you can solve 95% of the problems in VBA, you would find it hard/impractical to learn/bother using a stand alone developing software (e.g. Visual Studio Express) as opposed to using the integrated VBA IDE in AutoCAD. Like me, who was encouraged many times to learn .NET, never found the time or the necessity to do it. So, go for it while you can.

BlackBox
2012-12-15, 02:55 PM
Thanks RenderMan.
I will post the same question to ".NET" forum though.

Sorry for the delayed response, work has very much unexpectedly become hectic... Had I see this prior, I could have just moved this thread for you. :beer:

I'm happy to help, BoKirra :) - I think you'll find .NET development to be a great challenge, yet incredibly useful, and it's (the .NET API's) ability to expand LISP by way of LispFunction Methods can also be incredibly powerful (as we will be working to do in this thread (http://forums.augi.com/showthread.php?143663-New-LISP-Expressions-created-with-NET-%28VB-or-C-%29)).