Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Create custom Chamfer commands with different values

Status
Not open for further replies.

nxprog

Mechanical
Jan 11, 2004
85
How do I create custom Chamfer commands with different values. For instance I want a chamfer command for a 1/16” , 1/8”, 3/16”, and 1/4" I would prefer to have separate icons for each size. I'm having trouble with the exact syntax.
I am using AutoCAD Mechanical 2015.
 
Replies continue below

Recommended for you

You can do this with a Lisp routine.
Locate the file in your Autodesk folders called "acad.lsp" (or create a new one with a text editor if there isn't one already there).
This file should be put with the rest of your AutoCad files but the folder structure changes with each release.
You will also want to look through the Options -> Files list in AutoCAD where the exact address of LISP files is stored.
The "ACAD.LSP" file at that location is automatically loaded every time AutoCAD runs.

Then you can write a one-line script for each pre-programmed chamfer command followed by the size prompts as needed.
Once that is done, use the CUI to create custom buttons that invoke the Lisp commands you created.

Here is an example from mine. Instead of typing "XL" and then "V" to make a vertical Xline (construction line) I created "XV" in my ACAD.LSP file:

Code:
(defun c:xv     () (command "xline" "v"))

Here's a more complicated one. It's a sequence of commands that I use to select an object, make a copy, and rotate it 90 degrees to the original just by typing "CORO":

Code:
(defun c:coro   () (command "copy" pause "" "0,0" "@" "rotate" "p" "" pause "90"))

Your chamfer command would work like these. Create one line per shortcut, call it something like CF1, CF2, etc. and set the size for each on that line.

I'm a little less familiar with creating buttons through the CUI. It can be done, and I did it many many years ago. I don't even know if it works the same way in 2015 like it did ten years ago. I'll let someone else chime in for that.

STF
 
I create both shortcut menu items and buttons.

Under pull-down menu: TOOLS-Customize-CUI,

All I do is put the command, and answer prompts for distances, etc, then let the running command turn control over to me to select the 2 lines to chamfer or fillet. I also use this for a few standard "scales" I use frequently. For example: "chamfer d .25 .25;" then the command releases control to you to pick your 2 lines - Then I pick my 2 lines. If a polyline, it might look something like "chamfer d .25 .25 p;" then the command releases control to you to pick the polyline. This is what you'd put in the command macro line of the CUI dialog. (possible examples only: YOUR personal research is REQUIRED for exact command and format.)

For first-timers, it LOOKS intimidating, but if you'll take just a moment and just examine the available tabs, etc, in the dialog box - it really is something you can figure out with only a little bit of patient effort. Its NOT obvious, but it's also NOT difficult. Also you might get a SPACE or a semicolon (;) (which equals a space) wrong, and the command doesn't work quite like you expected, but that's ok. just go back and add or subract the " space " or " ; ", and you're good. A " space " and a semicolon "; " is the way you pot in the "Return" or "Enter" required by the command if you typed it in at the command prompt. Another thing - if you want the command to pause for you to pick something (or other input from you) use a back-slash ( \ ) at that point in your command.

You're creating a new command item, so you need to look into what the dialog box has you do, to insert a new command. It's right there, so open the Help while you examine the dialog box, and go for it !

Finally, PLEASE read up just a little from the CUI "Help". It'll talk about not modifying the base menu but making a sub-menu or something else to load so you don't corrupt the base default menu that came with your AutoCAD. A possible to approach might be to create a replaceacble menu from the entire base menu, and load that instead. Important possibility, if you're concerned about messing up the menu that came with your AutoCAD, but not necessarily the only right choice.

(Notice no mention of using "LISP.")

[ Hint: Among other things - like toolbar buttons, etc, I've modified my DEFAULT and my EDIT right-click shortcut menus ... EXTENSIVELY for my 3D Modeling - with NO LISP involved in a single command. Just sayin' ...! ;) ]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor