CUI - how to make own user command to macro and run it from command line ?

CUI - how to make own user command to macro and run it from command line ?

l_dabrowskiUZAN4
Contributor Contributor
537 Views
4 Replies
Message 1 of 5

CUI - how to make own user command to macro and run it from command line ?

l_dabrowskiUZAN4
Contributor
Contributor

Hello;

 

I wanted to create my own user command.
For example, I"ll call it JOHN
The macro for this command is ^C^C_line, which is very simple for the purposes of this example.
After typing JOHN in the command line, nothing happens "unknown command" .
I can create an icon, and then the macro reference works.
I wanted to assign the JOHN command in the PGP file
J,     *JOHN
and get a keyboard shortcut. I can't get this effect, because JOHN is unknown command. Help.

 

acad_cui.jpg

0 Likes
Accepted solutions (4)
538 Views
4 Replies
  • CUI
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

You can't do that. If you want to use a macro, then you only can assign a keyboard shortcut (in CUI).

 

If you want to make a named command, you need to use a LISP. Then, you can use PGP.

In LISP, your command can look like this:

 

(defun c:JOHN () (command-s "line") (princ))

 

Then save it as *.lsp file and use one of these methods to load it

https://www.lee-mac.com/runlisp.html

https://lee-mac.com/autoloading.html

 

Message 3 of 5

l_dabrowskiUZAN4
Contributor
Contributor
Accepted solution
Thank you, it's working.
I'm also posting a link to help for beginners like me.

https://help.autodesk.com/view/ACD/2024/ENU/?guid=GUID-5C9DC003-3DD2-4770-95E7-7E19A4EE19A1
https://help.autodesk.com/view/ACD/2025/PTB/?guid=GUID-1DABEF81-C431-442A-8916-7F9079AA7799

and example for join polylines in one move:

(defun c:POLIJOIN()(command "pedit" "M" (setq ss1 (ssget)) "" "J" "0" "") (princ))
0 Likes
Message 4 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Glad to help.

 

In my experience, today's version of the JOIN command is good enough to be a first-choice command. If it fails, other methods might come in handy.

0 Likes
Message 5 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

@l_dabrowskiUZAN4 wrote:
....and example for join polylines in one move:
(defun c:POLIJOIN()(command "pedit" "M" (setq ss1 (ssget)) "" "J" "0" "") (princ))

A small thing, and not really related to your original question, but....

 

There's no point in setting a variable [your 'ss1'] that is never used.  That could be just:

(defun c:POLIJOIN () (command "pedit" "M" (ssget) "" "J" "0" "") (princ))

Kent Cooper, AIA
0 Likes