Unknown Command with Macro, defun

Unknown Command with Macro, defun

Anonymous
Not applicable
1,474 Views
6 Replies
Message 1 of 7

Unknown Command with Macro, defun

Anonymous
Not applicable

I wrote this macro using the Customize User Interface Editor:

 

(defun c:dimcl( )(command "-layer" "s" "dimensions" "" "" "_dimlinear" pause pause pause """._layerp")(princ));dimcl

 

When I select the macro button it works real nice, exactly as intended.  And when I type "dimcl" at the command prompt the new command works just fine.

 

However I get this message everytime:

 

Unknown command "DIMCL".  Press F1 for help.

 

Considering the macro actually works then probably okay.  But I would like to know what I am doing wrong here.

 

Any ideas?

0 Likes
Accepted solutions (1)
1,475 Views
6 Replies
Replies (6)
Message 2 of 7

hmsilva
Mentor
Mentor

@Anonymous wrote:

I wrote this macro using the Customize User Interface Editor:

When I select the macro button it works real nice, exactly as intended.  And when I type "dimcl" at the command prompt the new command works just fine.

However I get this message everytime:

Unknown command "DIMCL".  Press F1 for help.

Considering the macro actually works then probably okay.  But I would like to know what I am doing wrong here.

Any ideas?


Hi tyannotti,

an AutoLISP code, needs to be loaded in each dwg.

One way is, if you don't have a 'acaddoc.lsp' file, create one, and save it in a 'Support File Search Path', AutoCAD will load 'acaddoc.lsp' in each dwg

To check if you have already an 'acaddoc.lsp', enter at the command line

(findfile "acaddoc.lsp")

If find one, will return the path, if not returns a 'nil'...

 

Hope that helps

Henrique

EESignature

0 Likes
Message 3 of 7

ВeekeeCZ
Consultant
Consultant
... and save it as e.g. dimcl.lsp in a 'Support File Search Path'...
0 Likes
Message 4 of 7

hmsilva
Mentor
Mentor

@ВeekeeCZ wrote:
... and save it as e.g. dimcl.lsp in a 'Support File Search Path'...

To save the code as an external lisp file, it's a different way of doing it, my advice was simply copy/paste the code in acaddoc...

If the OP choose that way, will need to use a 'load' or 'autoload' function in 'acaddoc.lsp' file to load the file

e.g.

(load "dimcl" "\nDimcl.lsp not loaded")

or using 'autoload'

(autoload "dimcl" '("dimcl"))

 

Henrique

EESignature

0 Likes
Message 5 of 7

Kent1Cooper
Consultant
Consultant

I believe the problem is that you have an extraneous Enter "" in the Layer command.  The command will end at the first of the pair, and the second will recall the latest command entered, which will be your custom command name, but within a (command) function that won't be recognized [only "real" AutoCAD command names work there].

Kent Cooper, AIA
0 Likes
Message 6 of 7

Anonymous
Not applicable

Kent,

 

I am not quite sure what you are suggesting, please help me understand.

 

It looks like all the quotes and parenteses are paired up okay.  To illustrate:

 

(defun c:dimcl( )
   (command
      "-layer"
      "s"
      "dimensions"
      ""
      ""
      "_dimlinear"
      pause
      pause
      pause
      ""
      "._layerp"
   )
   (princ)
)
;dimcl

 

 

Please explain, thanks

 

 

hmsilva & BeekeeCZ,

 

Thank you, you are correct and I did plan on doing this.

 

But first I have to get this little bit of code to work correctly.  If it works as a macro (or at the command line, etc) then I know it will work as a .lsp later.

 

For now I just re - define everytime I use it, no problem

 

Again, thanks

Tony

 

0 Likes
Message 7 of 7

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... 

It looks like all the quotes and parenteses are paired up okay.  To illustrate:

 

(defun c:dimcl( )
   (command
      "-layer"
      "s"
      "dimensions"
      ""
      ""
      "_dimlinear"
....

 

Please explain, thanks

.... 


They're paired up okay, but there's one more pair of double-quotes than there should be:

....

   (command
      "-layer"
      "s"
      "dimensions"
      "" ; this Enter completes the Layer command
      "" ; this Enter is extraneous, and recalls the previous command entered from outside the (command) function,

          ; which, not being a native AutoCAD command name, gives an error when used inside a (command) function
      "_dimlinear"

....

 

It's possible that you've picked up the idea of two Enters at the end of a Layer command from other routines.  That is appropriate only in those that end with assigning something like a color or a linetype to the current Layer:

....

  (command

    "_.layer"

    "_color"

    123

    "" ; first Enter accepts the current Layer's name as default to assign the color to

    "" ; second Enter completes the Layer command

  )

Kent Cooper, AIA