AutoCAD 2010/2011/2012

Reply
Valued Contributor
mlfgale
Posts: 51
Registered: ‎10-26-2006
Message 1 of 11 (197 Views)
Accepted Solution

Custom Command

197 Views, 10 Replies
05-02-2012 07:26 AM

Hello everyone.

 

I would like to create a custom command to run offset and then specify a distance. I can create a custom tool, which works fine. But now, I would like to assign a key to that command. I added the key with the command to the pgp file, but no luck. Is there anyway to do this?

 

Thanks!

Mark

So you want to type in number 2 to do offset ?

 

(DEFUN C:2 ()
(SETVAR "CMDECHO" 0)
(COMMAND ".OFFSET"  "4")
(PRIN1))

That worked! Thanks a ton!!

*Expert Elite*
GrantsPirate
Posts: 1,648
Registered: ‎08-15-2008
Message 2 of 11 (192 Views)

Re: Custom Command

05-02-2012 07:34 AM in reply to: mlfgale

Do you want a key or two to start Offset and then you would type in the distance?  Or do you want a key to start Offset and already have a set distance input for you as part of the command?

 

If the first one, the O, enter, should be set in the acad.pgp already.

 

If the other then you will need to add a simple line of code into your acaddoc.lsp file.

 

(DEFUN C:smileysurprised:4 () (SETVAR "CMDECHO" 0)(COMMAND ".OFFSET"  "4")(PRIN1))

 

Set the O4 to what ever keys you want, set the "4" value to the distance you would want encoded.

 

----------------------------------------------------------------------------
If something I wrote can be interpreted two ways, and one of the ways makes you sad or angry, I meant the other one.
Valued Contributor
mlfgale
Posts: 51
Registered: ‎10-26-2006
Message 3 of 11 (185 Views)

Re: Custom Command

05-02-2012 08:21 AM in reply to: GrantsPirate

Doesn't seem to be working.

I added the line (had to create the file) and it is loaded.

I assigned it to the "2" key and nothing. Any ideas?

*Expert Elite*
GrantsPirate
Posts: 1,648
Registered: ‎08-15-2008
Message 4 of 11 (179 Views)

Re: Custom Command

05-02-2012 08:25 AM in reply to: mlfgale

You have to tell me exactly what you added and where as it is unclear from your post.  

 

The code I posted substituted in a smiley face, the code should be.

 

(DEFUN C:O4 () (SETVAR "CMDECHO" 0)(COMMAND ".OFFSET"  "4")(PRIN1))

 Just in case, after typing 4 you have to hit enter.

----------------------------------------------------------------------------
If something I wrote can be interpreted two ways, and one of the ways makes you sad or angry, I meant the other one.
Valued Contributor
mlfgale
Posts: 51
Registered: ‎10-26-2006
Message 5 of 11 (171 Views)

Re: Custom Command

05-02-2012 08:35 AM in reply to: GrantsPirate

I did this:

 

(DEFUN OFF18 () (SETVAR "CMDECHO" 0)(COMMAND ".OFFSET"  "1/8")(PRIN1))

 So if i type off18 and enter, it should work correct?

*Expert Elite*
Patchy
Posts: 6,322
Registered: ‎09-16-2009
Message 6 of 11 (170 Views)

Re: Custom Command

05-02-2012 08:36 AM in reply to: mlfgale

So you want to type in number 2 to do offset ?

 

(DEFUN C:2 ()
(SETVAR "CMDECHO" 0)
(COMMAND ".OFFSET"  "4")
(PRIN1))

Valued Contributor
mlfgale
Posts: 51
Registered: ‎10-26-2006
Message 7 of 11 (168 Views)

Re: Custom Command

05-02-2012 08:39 AM in reply to: Patchy

That worked! Thanks a ton!!

*Expert Elite*
Patchy
Posts: 6,322
Registered: ‎09-16-2009
Message 8 of 11 (162 Views)

Re: Custom Command

05-02-2012 08:41 AM in reply to: mlfgale

COJonez is the man :smileywink:

*Expert Elite*
GrantsPirate
Posts: 1,648
Registered: ‎08-15-2008
Message 9 of 11 (154 Views)

Re: Custom Command

05-02-2012 09:05 AM in reply to: mlfgale

Patchy,

 

The emoticon got me again, is there a way to force those to not show?  I thought using the code wrap would do it, but no. 

----------------------------------------------------------------------------
If something I wrote can be interpreted two ways, and one of the ways makes you sad or angry, I meant the other one.
*Expert Elite*
Patchy
Posts: 6,322
Registered: ‎09-16-2009
Message 10 of 11 (152 Views)

Re: Custom Command

05-02-2012 09:10 AM in reply to: mlfgale

I don't know what the difference is, when I used Google, it uses emotional icon, if I used Firefox, it doesn't.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.