Pass arguments to CommandMethod in managed application extension

Pass arguments to CommandMethod in managed application extension

Anonymous
Not applicable
1,625 Views
12 Replies
Message 1 of 13

Pass arguments to CommandMethod in managed application extension

Anonymous
Not applicable

Hi

Is a LISPFunction (LISP callable wrapper) still the acknowledged mechanism to pass arguments to a .NET plugin?

 

Leading on from this, if the answer is yes, how do I build an OEM application so that the same mechanism will work? Currently I get LISP command is not available when I run it. (I'm actually running from a tool palette command  (MYCOMMAND "myarg"). There are no LISP scripts or code beyond the call.

 

Thanks in advance.

Craig

 

0 Likes
1,626 Views
12 Replies
Replies (12)
Message 2 of 13

Anonymous
Not applicable

In AutoCAD OEM I had to implement an AutoLISP module that calls the LispFunction. The downside is the functions exposed in the lisp module (defun C:xxx) can't pass arguments.

Any suggestions how I can pass arguments to my command(s)?

 

The reason I would like to do this is I want to have a set of tool palette items each with a different image and setting that is passed to a single command. 

0 Likes
Message 3 of 13

Balaji_Ram
Alumni
Alumni

Hello Craig,

 

Can you please provide a broader picture of what you are trying with the tool palettes in AutoCAD OEM ?

 

Sorry, I do not understand what you mean by "have a set of tool palette items each with a different image and setting that is passed to a single command."

 

If you can please provide more information, I can try it in AutoCAD OEM and let you know if there is a way to do that.

 

Thanks

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 4 of 13

Anonymous
Not applicable

Hello Balaji,

We want the convenience of a tool palette to be able to insert blocks. We have many custom blocks, the number of which will change over time. We want to pre-process and post-process the insert but I have determined I cannot use events so I will use a dedicated command.  

 

Currently, I have a command for each block, which is inflexible. I would like to have a single command and pass the block name. This will allow us to change the number of blocks supported without the need to rebuild our OEM product.

 

Neither .NET command or LISP commands accept arguments. LISP route was investigated but eliminated. We would like to do this in .NET.

 

Regards

Craig

 

0 Likes
Message 5 of 13

Balaji_Ram
Alumni
Alumni

Hello Craig,

 

Thanks for clarifying.

 

 

If a .Net command uses the "Editor.GetString" to request for the block name, you can provide that while invoking the command as 

(command "MyInsertCommand" "Bolt").

 

[CommandMethod("MyInsertCommand")]
        public void MyMethod()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptStringOptions pso = new PromptStringOptions("\nBlock name to insert : ");
            pso.AllowSpaces = true;
            PromptResult pr = ed.GetString(pso);
            if (pr.Status != PromptStatus.OK)
                return;
            String blockName = pr.StringResult;
            ed.WriteMessage(String.Format("{0}Block name inside .Net command : {1}", Environment.NewLine, blockName));
        }

Will this work in your case ? 

 

Regards,

Balaji

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 6 of 13

Anonymous
Not applicable

Hi Balaji,

Not in this case. We don't want the user to be able to input the name or be given the opportunity to change it.

This is what I was hoping for ...

 

onecmd.jpg

 

Regards,

Craig

0 Likes
Message 7 of 13

Balaji_Ram
Alumni
Alumni

Hello Craig,

 

Please try the following command string in the tool properties :

 

^C^C_MyInsertCommand;Bolt;

 

This should provide the "Bolt" text as the input for the .Net command.

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 8 of 13

Anonymous
Not applicable

Hi Balaji,

Sorry, I don't understand how _MyInsertCommand can process "Bolt".

Can you explain what you would expect _MyInsertCommand should do?

 

Thanks

Craig

0 Likes
Message 9 of 13

Balaji_Ram
Alumni
Alumni

Hello Craig,

 

I think we are not on the same page yet 🙂

 

This is my understanding so far -

 

There is a single .Net command to which you need the block name to be provided as an input.

This .Net command can pre-process, insert and post process after the block is inserted.

The .Net command is to be invoked from the Tool palette 

 

Is there anything that I missed ?

 

In the code snippet, "MyInsertCommand" represents a .Net command that inserts the block and the command string provides the block name as the input to the command.

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 10 of 13

Anonymous
Not applicable
Yes. That is correct. What I don't understand is how MyInsertCommand gets access to command string without prompting for input.
0 Likes
Message 11 of 13

dgorsman
Consultant
Consultant

Standard menu macro process, same as with any other AutoCAD command which requests input from the user.  Try it with other commands, like "-Layer;make;foo;" to see how it works.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 12 of 13

Anonymous
Not applicable
So I have to include a request for input from the command line in my code for this to work?
0 Likes
Message 13 of 13

Anonymous
Not applicable

Ok I've just attended the macro guide to dummies course Smiley Happy

This will give us the flexibility we need .

Thank you for your help

Craig

0 Likes