Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating my own commands 2

Status
Not open for further replies.

Bloodwig80

Mechanical
Jul 29, 2004
42
Hey:

i currently use 05' and we're soon switching to 06'. i already installed it but im too swamped to configure it.

anyways, im looking into creating some commands specific to the type of work im doing and have a few ideas of what i want the program to do for me.

Does anyone know how to go about this? I have used acad for a few years now so im extremely familiar with it. now im looking to make it do what I want! mwahaha!

if you guys know of a tutorial or walk-through to making my own commands let me know, im ready to read it and use it asap.
 
Replies continue below

Recommended for you

look at the acad.pgp file
look at the acad.lsp file
If you can be more specific about your needs....
 
okey to be more specific. i work for a walkway canopy manufacturer. our system utilizes a series of columns and beams to support the canopies.

i want to be able to insert blocks into the drawings and specify onscreen which block to insert from the library of dwgs.

the command would allow me to specify the type of column (diameter), the height of the columns, the separation between the columns, the beam type, etc. and import the appropriate column/beam depending on which answer i give it.

for example. i start command, it asks me insertion point, then it asks me column height, i tell it 10'6" and it would know to pull the dwg "10-6column.dwg" automatically. then asks beam width, it gets beam 8'10" according to my answer, etc.
 
This is more than I can do in this forum. It is not difficult, just time consuming and there would be a lot of back and forth between you and I. You would be better served by hiring a consultant to craft a program, or (better still IMHO) learn LISP or VBA to make a small program that you then enhance over time to speed up your drawing.

Here is a snippet to insert a column drawing:

(DEFUN C:COL (/ Hgt Nam P1) ; Insert columns
(SetVar "CMDECHO" 0)
(Setq om (GetVar "OSMODE"))
(SetVar "OSMODE" 0)
(setq Hgt (getstring "\nEnter Column Height ie 10-6 ")
Nam (strcat Hgt "column")
P1 (getpoint "\nPick the insertion point)
)
(COMMAND "INSERT" Nam P1 1 1 0)
(SetVar "OSMODE" om)
(princ)
)
 
so i should learn LISP then or VBA.

thanks. i will look into these two things. i know nothing about them but having programmed CNC machinery in the past im sure they cant be too hard. right? :D
 
LISP is easy. Sometimes convoluted and unforgiving. Not well suited for very involved programs. VBA is very powerfull - you can do just about anything and it runs within AutoCAD. With VB6 you can make stand-alone programs that create or modify dwg or dxf files.

For your needs, I think LISP will work at least for a while.

Have fun !!
 
I would probably go with VBA on this one, especially if you want to use dialog's.

The first step is to write up your "program" in pseudo code ~ i.e. List all the steps, prompts, user interaction you would like to complete your program in the order you wish them to be displayed. Break it down as far as you can, then you can look at writing each portion in sequence.
I think such a program may end up to be quite complicated but is certainly feasible and worth investing in.


~ for your CAD solutions
 
thanks for the input hendie.

guys, whats a good place to start if i want to learn VBA?

i really dont know how it works at all. i looked at the online help files but they are a little over my head.
 
the autocad help files is as good a place to start as any. There are a lot of good samples in there.
is just about to start a VBA tutorial in the next week or so (I think) so you may want to check it out.

If you are willing to invest the time in learning then people will be ready to help you out. Be prepared though... it does take time and effort to learn (just like anything else)

If this is your first project then (being brutally honest..) what you have described above may be a bit too much to chew on for a first project. I would seriously suggest starting off with something a lot simpler.


~ for your CAD solutions
 
Sounds like 06's dynamic block feature will do what you need...
 
Just a thought-

2 ways to write your own commands without LISP or VBA, and the results are useful immediately.

Menu Macros

Icon Macros.

A third would include ACAD.pgp, but more on that later (if you're interested).

Menu Macros-

1. Copy ACAD.mns to another location. I use a directory (folder) under the ACAD support directory, that I call ORIGINAL VERSIONS.
The idea is to always have the original ready, in case you make a mistake. You will. No sweat.

2. Open ACAD.mns in the parent acad support directory using a standard text editor. I use Notepad, but the basic ACAD.mns file has grown large enough that you may get a message from Windows that its too large, do you want to use another Windows standard text editor instead. CLick "Yes" if you get this message. Just be sure to save any edits as standard text. This is critical.

This time, though, just look. You may notice some command names you recognize. Good. You may notice some command names with OPTIONS you recognize. Good again. DON'T TOUCH! Ok, now that you've done some reading and familiarizing, use your text editor's find-go-to to go to "POP0" (popzero). Why POP0? Its a safe place to experiment. Don't worry AT ALL about the cryptic command-like text at the beginning of each line. Look a few spaces over to the right. See a command name you recognize? Go to the end of that line. Hit return to make a line-space. now on the new empty line/space you've created, SPACE (not tab) over and line up with the command name above. Now- TYPE A COMMAND NAME you want to try.

Here's an example:

move \;\\

See the empty space after the word "move"? its the same as return, if you type the command in at the command prompt.

See the back-slashes? those are pauses for you to pick something. The first one lets you pick an object to move. The Semi-colon is another char that means "return" ("space"==;=="return") the NEXT back-slash is the "base-point" of the move command. The third one is the destination point.

OK. You've typed this in at the line you cleared in the menu. MAKE SURE THERE IS _NO_ "space" at the end of the line (after the last back-slash). Autocad will add the final return for you, as it compiles the change you've made.

Save your work. Exit.
RESTART ACAD.
Yes there are "Menu" and MENULOAD" commands. Don't bother 'til you have alot more experience modifying your menu. ACAD should re-compile the base menu without affecting your ICONS at all. If you have add-on menu-based programs you're running, you'll have to find out how they are affected, but the solution is almost always as simple as the menuload command, re-identifying the add-on, and reselecting the pop-downs to re-include, and this is almost always a fairly straight forward process- they want you using their product!

3. Assuming no add-in, simply re-start your ACAD. Let ACAD re-compile the ACAD.mns file for you.
Use SHift-Return if your middle button isn't already set to bring up the OSNAP pop-menu. Look for the "move" command now appearing in the menu. If you don't find it, look in one of the fly-outs(pull-outs) in this pop-0 menu. You might have put it a level down. Find it? Click it and do a "move" the way you'd do it if you typed in "MOVE" from the keyboard.

Thats it! EVERY command in AutoCAD behaves this way.
After you've tried putting a couple of commands in, and seeing how they work, Write down in detail OTHER commands you want to try, and each step and option of that command.

Here's an example relating to your first question:

Insert c:/dir-1/dir-2/blockname;

See the slashes? They're backwards, to not confuse ACCAD with back-slashes meaning "pause for user input". See the semi-colon on the end? ACAD will know not to add another space where you've put a semi-colon at the end of a line.

Want a cancel" in a command? Use ^c usually twice, as in ^c^c. (Shift-6c shift-6c).

Useful hint: you can even set a variable then do the conmmand, right on the command line, as in:

^Omove \;\\

Notice- NO SPACE between the shift-6capital-O (^O) and the word move? That's right! This turns ortho on (or off-its a "toggle"), runs the move command, lets you pick an object, and move it along 0/90/180 (ortho-on) or releases it to allow you freedom, if you usually run WITH ortho. This really isn't a great example, but illustrates the idea. Take it from here!

Icon Macros

A command and its options in a menu macro, works EXACTLY this same way, when used as the instruction line of an icon. Try creating a new ICON in one of the icon menus by right-clicking the icon-bar, and choosing "new user command" from the dialog box. Drag the empty "button" into place on the bar you want it in, and right-click the button, and experiment with commands and their options. As in ALL programming, caution is appropriate- phantom "extra" spaces are a usual culprit, and typos/misspellings can be hard to catch, too.

Your BEST bet? Buy a GOOD book (usually~$35-$50) that has a well written chapter on this subject. In fact, start with that, and then try what I've given you here.

Good Luck!

C.F.
 
wow thats very elaborate. im gonna have to concentrate to absorb all that info. thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor