.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom Command Parameters in .NET

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
michael.robertson
2578 Views, 2 Replies

Custom Command Parameters in .NET

Is there a way in the .NET api to create a custom command that takes parameters? Want to create the ability to call the netloaded command from an external application and send it parameters without user interaction.

Mike Robertson
FL. Dept. of Transportation
CADD Applications Developer
2 REPLIES 2
Message 2 of 3
djonio
in reply to: michael.robertson

Mike,

Yes. For my inter-process communication I use WCF, NetTcpBinding in particular, as this gives me the ability to have both server and client on different or the same machine(s). Because of threading issues within AutoCAD/Map3d I had to develop the Autodesk WCF side within a Windozes Form instantiated during IExtensionApplication.Initialize(). I have found WCF to be very reliable and full featured. Once I had finalized my approach to communication and realized how fast it was I developed a rather simple system for exchanging commands and data between the exe’s.

There are other approaches but I will let others speak to those. If you are interested and wish to explore the gory details we could take this offline.

r, dennis

Message 3 of 3
michael.robertson
in reply to: djonio

Thanks Dennis,

I actually just ended up creating a command using the <ListFunction> tag instead of the <CommandMethod> tag and it seems to do what I needed. I'm attaching the code incase anyone else runs into the same request.

 

Code:

If you need to create a custom autocad command that takes parameters the <CommandMethod> tag does not allow parameters.

 

BUT…

 

You can declare your custom command as a Lisp Function which can take parameters (but doesn’t have to) as follows:

 

        <LispFunction("MyFunction")> _

        Public Sub MyFunction(ByVal Args As ResultBuffer)

            ‘check if any parameters

            If Not Args = Nothing Then

                'step through the parameters

                For Each rb As TypedValue In Args

                    'check the param type

                    If (rb.TypeCode = Autodesk.AutoCAD.Runtime.LispDataType.Text) Then

                        'do something if text

                    End If

                    If (rb.TypeCode = Autodesk.AutoCAD.Runtime.LispDataType.ObjectId) Then

                        'do something if ObjectID

                    End If

                Next

            End If

        End Sub

 

To call the command from the command line enclose the command in parens as follows:

(MyFunction “myText”)

This calls the MyFunction command with a single text param = “myText”

Mike Robertson
FL. Dept. of Transportation
CADD Applications Developer

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost