AutoCAD 2010/2011/2012

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

Custom Command

190 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,613
Registered: ‎08-15-2008
Message 2 of 11 (185 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 (178 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,613
Registered: ‎08-15-2008
Message 4 of 11 (172 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 (164 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,262
Registered: ‎09-16-2009
Message 6 of 11 (163 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 (161 Views)

Re: Custom Command

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

That worked! Thanks a ton!!

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

Re: Custom Command

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

COJonez is the man :smileywink:

*Expert Elite*
GrantsPirate
Posts: 1,613
Registered: ‎08-15-2008
Message 9 of 11 (147 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,262
Registered: ‎09-16-2009
Message 10 of 11 (145 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.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.