create a command with parameter

create a command with parameter

Anonymous
Not applicable
1,631 Views
4 Replies
Message 1 of 5

create a command with parameter

Anonymous
Not applicable

Dear All,

I want transmit a outside parameter to CAD, my thinking is like following :

//outside code

class xxxxx

{

//outside code

string parameter="ParameterToTransmit";  

 

document acdoc.SendCommand("MyCommand ",ParameterToTransmit😞

}

 

//CAD command

 [CommandMethod("MyCommand ")]
        public static void MyCommand (ParameterToTransmit)
        {

        //

         }

But i don't know how to make a command with parameter .

Is  it possible to create a command with parameter ?

Or is  it have other solution? 

0 Likes
Accepted solutions (1)
1,632 Views
4 Replies
Replies (4)
Message 2 of 5

moogalm
Autodesk Support
Autodesk Support
0 Likes
Message 3 of 5

Anonymous
Not applicable

Dear Sir:

I can't open your link, and i got a solution in net forums, but thank you very much also.

https://forums.autodesk.com/t5/net/make-a-command-with-parameter/m-p/7179108#M53965

0 Likes
Message 4 of 5

tbrammer
Advisor
Advisor
Accepted solution

If you create a new ARX with the ObjectARX-Wizard, it will contain a lisp command called "MyLispFunction".

You find the implementation in acrxEntryPoint.cpp:

 

	static int ads_MyLispFunction () {
		struct resbuf *args =acedGetArgs () ;		
		// Put your command code here
		acutRelRb (args) ;
		
		// Return a value to the AutoCAD Lisp Interpreter
		// acedRetNil, acedRetT, acedRetVoid, acedRetInt, acedRetReal, acedRetStr, acedRetPoint, acedRetName, acedRetList, acedRetVal

		return (RTNORM) ;
	}

If you enter this command in AutoCAD:     (mylispfunction "abc" 10 3.141 123456789)

args will be a resbuf list with the four arguments.

 

A different approach could be to implement a "normal" command that calls acedGetString(TRUE,NULL,argline) to retrieve arguments from the commandline. Than you have to parse argline yourself.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

0 Likes
Message 5 of 5

Anonymous
Not applicable

Thank you very much

0 Likes