TheSwamp
Code Red => VB(A) => Topic started by: David Hall on May 03, 2005, 05:31:35 PM
-
Please post what kind of topics you would like to see in a VBA tutorial. Please try to keep this thread on topic. EX. I would like a utility to turn all my graphics to Color=ByLayer and Linetype=ByLayer
-
for tutorial topics i would like a tutorial on how to 'use' the utility created.
for specific utilitiesi would like a utility to create layers.
"" to insert blocks from specified location
-
both of those are good topics. Espically the first b/c VBA doesn't offer an EASY way to make a shortcut.
-
1 ) Entity manipulation and creation.
2 ) File I/O.
In that order.
-
I would like a utility to ...
How 'bout start a new job/open existing job.
New job would give an interface (dailog?) to enter pertinent info like job name, number, customer, etc. and create a folder, populate the titleblock info & save everything to a drive location. Existing job would either open an existing dwg for editing, or add a new dwg to the existing folder.
IOW, no more creating folders or browsing thru them in windoze.
-
Ok, that's easily do-able Birdy. Although, isn't this what the wonderful folks at Autodesk gave us the Sheet Set Manager for? :D J/k.
The entity manipulation is also a very good one. VBA gives us almost total control over all the aspects of a drawing object's properties, but very few of the modifications are available directly. (ex. trim, break, move, copy) You can still do all of those, but you have to know your way around to be able to pull it off.
For file I/O, are you talking about text files, or dwg files?
heh, "blocks" will be fun. Since "blocks" and "blockreferences" are two terms that don't come into AutoLisp very often.
As a given, any tutorials will seem easier for those versed in V-Lisp vs. those who only know AutoLisp. V-Lisp uses many of the same terms as VBA, and the way of manipulating objects is also somewhat similar.
I think that we can also work in the topics that Mark mentioned (private and public subs and functions) at the same time.
-
For file I/O, are you talking about text files, or dwg files?
text files.
-
Ok, that's easily do-able Birdy. Although, isn't this what the wonderful folks at Autodesk gave us the Sheet Set Manager for? :D J/k.
Sheet sets... gotta have em to use em (a2k4 here) unless I'm missing something.
-
So is this going to be a tag team teaching set? It is getting interesting.
-
Would it be possible to create a routine that stops users creating layers with "incorrect" layer names :roll:
-
some basic terms would be nice to begin with (for me at least)
and a tutorial of the vba manager (which i still don't quite grasp) :oops:
-
some basic terms would be nice to begin with (for me at least)
and a tutorial of the vba manager
Im working on that right now. I hope to have something ready to hand out by Monday
-
Would it be possible to create a routine that stops users creating layers with "incorrect" layer names :roll:
No, but maybe. Depends on how cruel you want to be to your non-conformists. Say for instance they created a wrong layer name, you can search the entire drawing for non standard names, and move all the graphics on those layers to another layer. Then they would have to sort out the mess on the correct layers. Or you could just delete it and make them do it again.
-
Sounds like ODBX to the rescue on that one?
-
Well, you "could" do something a little more sneaky .... how about turning off the ability to create layers altogether .. force users to use a template with the layers already defined. It can be done ... but it won't be pretty
-
Well, you "could" do something a little more sneaky .... how about turning off the ability to create layers altogether .. force users to use a template with the layers already defined. It can be done ... but it won't be pretty
Like undefining the commands or deeper than that?
-
Well, like an API that disables the "new" button in the layer dialog, removes the "new layer" option from the popup menu and intercepts the "layer" command from the command line.
Unfortunately, the only real way to prevent the making of layers is to have an event fire when a layer is created, check against a list of authorized layers then have the unauthorized layer deleted. The question becomes how to deal with any entities on the layer when you want to delete it ... such as when inserting a block .. any layers in the block are automatically created
-
Personally CMDuh, I think if you started with the basics, like how to use and test code in the ide, how to use the watch window, and other debugging tasks and the importance of indenting and commenting code. That would be a great start. You'll have some heavy hitters like Keith and Ben, but the majority of us are mush brained when it comes to starting vba. Myself, being knowledgeable in Vlisp, it wouldn't take too long to grasp this after getting through the basics, but until then, I'm a mush brain with vba.
-
Outline of good and bad habits to start / avoid. :?:
-
Personally CMDuh, I think if you started with the basics, like how to use and test code in the ide, how to use the watch window, and other debugging tasks and the importance of indenting and commenting code. That would be a great start.
Thats the idea.
You'll have some heavy hitters like Keith and Ben, but the majority of us are mush brained when it comes to starting vba.
And I'm counting on Ben and Keith and the other GURUs to fill in the blanks when we get to an area I'm not versed in. I'm self taught with a lot of questions asked on Cad Vault.
-
Outline of good and bad habits to start / avoid. :?:
Thats hard b/c that would be my opinion... There are the obvious ones like COMMENT you code, but we all know that, we just dont always follow thru. There are some good guidelines that I'm putting in the getting started guide I'm making. Hopefully that is what your looking for.
-
Personally CMDuh, I think if you started with the basics, like how to use and test code in the ide, how to use the watch window, and other debugging tasks and the importance of indenting and commenting code. That would be a great start.
Thats the idea.
You'll have some heavy hitters like Keith and Ben, but the majority of us are mush brained when it comes to starting vba.
And I'm counting on Ben and Keith and the other GURUs to fill in the blanks when we get to an area I'm not versed in. I'm self taught with a lot of questions asked on Cad Vault.
You can count me in as far as offering advice from time to time ... I won't soon be able to actually manage teaching a class, but I MIGHT over the course of the next few weeks put together an API primer ... Those who are familiar (intermediate) with VB(A) will likely want to look toward expanding its usefulness.
-
Keith, that would be great!
-
If it's ok I'd like to contribute too when I've time. I programmed in VB before it even became a Windows application.
:)
-
If it's ok I'd like to contribute too when I've time. I programmed in VB before it even became a Windows application.
:)
The more the better! This originally started out very small as a one-on-one thing, and its grown very quickly.
-
CmdrDuh :
I look forward to seeing what you come up with. I'm sure it will be quite excellent.
-
Well I hope I meet your expectations. I "used" to teach for a living for Autodesk reseller, so the teaching part is not too hard. But I have only done 1 or 2 web class things, so we will see how it goes.
-
Also, it should be noted that I am more of a hacker than a programmer(being self taught). I make it work, not always the most elegant way possible.
-
but I MIGHT over the course of the next few weeks put together an API primer ... Those who are familiar (intermediate) with VB(A) will likely want to look toward expanding its usefulness.
Keith:
I hope to see something like this from you. The Windows API is something I've yet to venture into in VBA and a primer course would be very nice. Judging by what I've seen from you in the past I'm sure it would be a worthwhile read.
-
Also, it should be noted that I am more of a hacker than a programmer(being self taught). I make it work, not always the most elegant way possible.
Quick, read this (http://www.theswamp.org/phpBB2/viewtopic.php?p=60813#60813).
(http://www.theswamp.org/screens/mp/thumbsup.gif)
-
MP, its funny that you sent me there, b/c I read that just this morning. Whats also funny is I teach by that very principle. What I meant about being a hacker is I have no formal trainging in VB(A) so the methods I will be showing are what I know. (Which is sometimes not the best way to get the job done) Also, I dont program for a living, so by someothers standards, that makes me a hacker not a programmer. Either way, I dont care, because if it helps me get my job done faster or more efficiently, its a program.
-
And if teaching it helps you get better knowledge, then you become a better hacker/programmer.
-
And if teaching it helps you get better knowledge, then you become a better hacker/programmer.
Exactly!!!
-
Also, I dont program for a living, so by someothers standards, that makes me a hacker not a programmer.
here, here. According to some people there are only the the 2 clubs.
Personal Opinion : Programming is about solving problems. You solve problems, therefore ...
< deleted derogarory remarks about some academics >
-
KWB - Thank You
-
OK, getting back on track, would it be easy to create a proggy that can issue a save every 10 commands? Could this be covered in a course?
-
Tracey, that would be a simple program in VBA ...
-
Not only simple but dam handy. :)
-
Has anyone tried applying VBA in other programs? I have several macros in Excel as well and quite frankly, enjoy it more then CAD at times.
The irony is that it helps me approach programming better in AutoCAD.
Anyone who is in this forum is very fortunate. I have learned a bit from different people and a lot from others.
I still have a long way to go but I have also come a long way in VBA. So anyone in this forum (with persistence) can learn just as I am.
-
OK, this is jumping ahead, but here is that program. I will have to look to see who gets credit for this.
Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
'***Below code is to AUTO save the drawing every 25 commands,
If ThisDrawing.GetVariable("DWGTITLED") = 1 Then 'don't use on new, unsaved drawings
Select Case CommandName
Case UCase("undo"), UCase("u"), UCase("zoom"), UCase("z"), UCase("pan")
command_count = command_count
Case UCase("QSAVE"), UCase("SAVE")
command_count = 0
Case Else
command_count = command_count + 1
If command_count = 25 Then 'change this to any number you want
ThisDrawing.Save
command_count = 0
End If
End Select
End If
End Sub
-
Jeff_M gets credit for that module.
-
That's Jeff Mishler in case anyone wants to know. An excellent programming lad that wears a white hat.
-
Did everyone want too turn this into a code posting post? Or are we going to stick to basic theory?
-
It needs to be placed in the ThisDrawing module of the Acad.dvb (or any dvb that will always be loaded) For those of you who do not know where that is, I will be covering that in an upcoming handout.
-
I am putting together handouts that will cover the theory, but by people posting code, we can use those examples in our discussions.
-
Has anyone tried applying VBA in other programs? I have several macros in Excel as well and quite frankly, enjoy it more then CAD at times.
I use VBA in Word, Excel, AutoCAD, Access, in fact only today I developed a small application in Word for my colleagues over in the US.
truth be told, I'm a lazy sonofa.... so if I can develop something that will save me doing something twice, then I'll do it.
-
truth be told, I'm a lazy sonofa.... so if I can develop something that will save me doing something twice, then I'll do it.
Words I live by :dood:
-
I second that emotion!
-
UPDATE: I have most of my images in the Doc file and have all my headings that I want to cover. Now I just have to add the small text that goes b/t pics. Should be done for a Monday posting.
-
:dood:
-
You guys here are great :dood:
-
Would it be an idea to create a new thread that is strictly a tutorial and only certain members can add to it (CmdrDuh etc)?That way the tutorial wont become disjointed, as members post their comments and the thread grows ever larger.
-
Would it be an idea to create a new thread that is strictly a tutorial and only certain members can add to it (CmdrDuh etc)?
Way ahead of ya. :)
-
Please PM me if you would like access to the Tutorial forum that Mark has created.
-
Hate it when I get busy (and lazy) So David, are you posting your first tutorial today?
Daron used to work for Pulte out here. (If I remember correctly)
-
I'd like access to veiw it but as far as teaching VBA goes. :lol: Thats why I'd like access as I havent a clue.
-
Yes, Im trying to set up the group access now
-
Yup, Ben. That's me. Your memory serves you well.