Unknown Command Problem

Unknown Command Problem

Anonymous
Not applicable
6,759 Views
48 Replies
Message 1 of 49

Unknown Command Problem

Anonymous
Not applicable

I'm brand new to the forums and to Visual LISP, so forgive me if this is in the wrong area or if I seem a bit lost.

 

I'm working in Carlson/Civil 3D and I'm trying to write a LISP that lets me select some polylines and then it sets them to the zero elevation and reduces the vertices. However, every time I try to call the LISP in the command line, it says "unknown command '3dto2d'". I know 3dto2d is a valid command in Carlson, so I assume I'm missing something in my code to make it look there. Any help would be greatly appreciated.

 

(DEFUN C:ZR ()
	(setq ss (ssget))
	(Command-s "._3dto2d" "0" ss "")
	(Command-s "._reduce" "5" ss "")
	(princ)
)

 

Thanks,

Mike

0 Likes
Accepted solutions (1)
6,760 Views
48 Replies
Replies (48)
Message 2 of 49

john.uhden
Mentor
Mentor
That may be because the commands are not tru AutoCAD commands, but just AutoLisp command functions.

Try instead:
(C:3dto2d "0" ss)
although i doubt that anyone would write an AutoLisp command function that would take input arguments.

At the command line, type in !c:3dto2d and report what it returns if anything.
If it is an AutoLisp function, we may be able to help you turn it into a real command that would make your code work.

John F. Uhden

0 Likes
Message 3 of 49

Anonymous
Not applicable

Command: !c:3dto2d
#<SUBR @000001f8d7cf5c00 C:3DTO2D>

 

This is what was returned when I typed that into the command line. What is the difference between using (Command ...) vs (C: ...)? Is it just a different way to call the command?

0 Likes
Message 4 of 49

dennis
Advisor
Advisor

I didn't recognize those commands, 3dto2d and reduce.  I typed them in at the command line of AutoCAD, it came "Unknown command".  So, if you can type that in manually at the command line, and get a prompt for selecting objects, then that says to me you are loading a DLL, VBA or Lisp file that includes those two commands.

If you manually type those in, and get the unknown command, then it means they are not defined.  Your code shown would actually do nothing.  As John was saying, you are trying to use a command that is not defined to do anything.

A defun is used to define your own command, while the Command call will use an existing AutoCAD command within your custom command.

A catch, a command defined by a LISP routine cannot be 'reinvoked' within another lisp command.

If you have the express tools loaded, try this: type in at the command line FLATTEN.  Should prompt for selection.  Then I think your reduce command is actually the SCALE command in AutoCAD.

 

0 Likes
Message 5 of 49

ВeekeeCZ
Consultant
Consultant

Not familiar with Carlson... but you can try use macro. 

 

^C^C_select;\_3dto2d;0;p;_reduce;5;p;

 

just a sketch, untested.

0 Likes
Message 6 of 49

Anonymous
Not applicable

Carlson (as far as I can tell) is pretty much the same thing as Civil 3D, it just has some commands and features that are focused on mining applications.

 

I have a macro already created for the command, I was just hoping to turn it into something that I could type out. For whatever reason, I work a lot faster when I can type commands as opposed to hunting for buttons. Is there a way to do that? Here's the macro for what I have:

 

^C^C_SELECT \^C^C3dto2d 0;p;;^C^Creduce 5;\;

 

One problem I have with the macro however is that I can only select one object at a time, and I have to reselect the object for the reduce part of the macro. Is there a way to set up selection sets in macros and then apply the selection set to multiple commands? Using "p" in the reduce part doesn't do anything because I guess you can't use that more than one time in a row? I'm not sure, like I said I'm pretty new at the whole customizing thing.

0 Likes
Message 7 of 49

ВeekeeCZ
Consultant
Consultant

Keyboard Shortcut? Use CUI, create a command with assigned shortcut. The only way I can imagine. 

Message 8 of 49

Anonymous
Not applicable

So when writing a lisp file, I can't call commands that are specific to modules? For example, The base program I am running in Carlson Civil 3D. However, within that program I have modules such as "Survey", "Civil", "Geology", "Surface Mining", etc... The commands I'm trying to call I believe are specific to one of those modules. I'm not positive which one yet though.

 

Flatten somewhat works, but it doesn't let me choose the elevation I would like to set it at. At some point down the road, if I had been successful with the lisp file, I would have liked to have been able to go back and edit it so that I can set it to the elevation I need.

 

Scale just changes the size of the object.

0 Likes
Message 9 of 49

Anonymous
Not applicable

That would actually be pretty handy! I guess I missed that option when I was making the macro. Where do I assign the shortcut? My options in CUI when I made the macro were: name, description, extended help file, command display name, macro, and tags.

0 Likes
Message 10 of 49

ВeekeeCZ
Consultant
Consultant

Look HERE

0 Likes
Message 11 of 49

Anonymous
Not applicable

I don't have "Custom" in my "Partial Customization Files" (step 4). I've attached what I see. The command that is highlighted in the command list and shown on the right side is the one I put together.

0 Likes
Message 12 of 49

ВeekeeCZ
Consultant
Consultant
You can use the main root (see 4th line). You can create your custom file, if you have this customizations a log. It's good for migration....
0 Likes
Message 13 of 49

Anonymous
Not applicable

Oh, I see now. Thank you, I misread that part the first time.

0 Likes
Message 14 of 49

ВeekeeCZ
Consultant
Consultant

Btw Back to your original question.

 

If those command are LISP originally, you can call then by  (c:3dto2d). "c:" stands for command. Lisp command can't be run with (command "3dto2d") - or command-s or vl-cmdf. Only original autocad's command can. If the programmer wants to allow to fill user prompt, he makes a special subroutine with in/out parameters. In that case it could be call from lisp by (3dto2d 2 ss) - as any other subroutine.

 

0 Likes
Message 15 of 49

Anonymous
Not applicable

ahhh, ok. I think I'm starting to understand now.

 

So I now have this:

 

(DEFUN C:ZR ()
	(setq ss (ssget))
	(C:3dto2d 0 ss "")
	(C:reduce 5 ss "")
	(princ)
)

But I guess I'm still not doing it quite right. When I try to execute the command, it lets me select objects for my selection set, but when I press [enter] to move on to the 3dto2d part I get "too many arguments :error#0". Do I still need the "" at the end when using commands this way?

0 Likes
Message 16 of 49

ВeekeeCZ
Consultant
Consultant

@Anonymous wrote:

ahhh, ok. I think I'm starting to understand now.

 

So I now have this:

 

(DEFUN C:ZR ()
	(setq ss (ssget))
	(C:3dto2d 0 ss "")
	(C:reduce 5 ss "")
	(princ)
)

But I guess I'm still not doing it quite right. When I try to execute the command, it lets me select objects for my selection set, but when I press [enter] to move on to the 3dto2d part I get "too many arguments :error#0". Do I still need the "" at the end when using commands this way?


Sure. It knows the command name C:3dto2d but without parameters. It usually does not have. 

 

;This would be without error, but not doing what you want.

(DEFUN C:ZR ( / ss)
	(setq ss (ssget))
	(C:3dto2d)
	(C:reduce)
	(princ)
)

;You can try this, but it's just a guess. You need to dig into yourself, how these command are defined. Try look into carlson's root files....

(DEFUN C:ZR ( / ss)
	(setq ss (ssget))
	(3dto2d 0 ss)
	(reduce 5 ss)
	(princ)
)

 

0 Likes
Message 17 of 49

Anonymous
Not applicable

Great, I'll look into it. Thanks for all the help!

0 Likes
Message 18 of 49

john.uhden
Mentor
Mentor
That tells me that it is an AutoLisp defined function. You can try to turn it into an AutoCAD command by...
(vl-load-com)
(vlax-add-cmd "3DTO2D" 'c:3dto2d)
(vlax-add-cmd "REDUCE" 'c:reduce)

If it makes your code work, then you will probably have to add it to your acaddoc.lsp file which will run at the beginning of each drawing open.

John F. Uhden

0 Likes
Message 19 of 49

steve_carson
Enthusiast
Enthusiast

@Anonymous wrote:

I'm brand new to the forums and to Visual LISP, so forgive me if this is in the wrong area or if I seem a bit lost.

 

I'm working in Carlson/Civil 3D and I'm trying to write a LISP that lets me select some polylines and then it sets them to the zero elevation and reduces the vertices. However, every time I try to call the LISP in the command line, it says "unknown command '3dto2d'". I know 3dto2d is a valid command in Carlson, so I assume I'm missing something in my code to make it look there. Any help would be greatly appreciated.

 

(DEFUN C:ZR ()
	(setq ss (ssget))
	(Command-s "._3dto2d" "0" ss "")
	(Command-s "._reduce" "5" ss "")
	(princ)
)

 

Thanks,

Mike


Without actually being able to test it, I would try this:

 

(defun C:ZR ( / ss)

    (setq ss (ssget))

    (C:3dto2d)

    (command "0" ss "")

    (C:reduce)

    (command "5" ss "")

    (princ)

)

 

I don't know if it will work, but I've seen commands and arguments split up like that before. You may need to put "(command)" after the command calls. Testing will tell.

 

 

Steve

   

0 Likes
Message 20 of 49

Anonymous
Not applicable

Would doing that allow me to automate the commands within my lisp file?

 

So far, what I've found is that I can't add any arguments to either without getting an error. So I'm just stuck with (C:3dto2d) and (C:reduce). While this works, it doesn't really speed the process up any because I still have to step through each command.

 

When digging around in the Carlson directories, I've learned that both of the commands are .FAS files.

 

 

Ideally, I would like my lisp command to be set up in a way that when I type in "ZR" to the command line, it prompts me to pick the entities I want, and then automatically does the rest without any more user input. I.e... It sets the elevation to 0 and reduces the vertices in each polyline with an offset cutoff of 5.

0 Likes