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

speaking of cui files

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
602 Views, 6 Replies

speaking of cui files

Is there any way in .Net to enable/disable menu items?
In Arx I used the menucmd function to do this but don's
see anything like that in the .Net api's.
Perry
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

What about use of acedMenuCmd() with P/Invoke in .NET-application?
Message 3 of 7
Anonymous
in reply to: Anonymous

Alexander Rivilis wrote:
> What about use of acedMenuCmd() with P/Invoke in .NET-application?
I haven't tried that Alexander, I'm not really a COM kinda guy.
May have to though!
Message 4 of 7
Anonymous
in reply to: Anonymous

Try this code:
[code]
using System;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Runtime;

[assembly: CommandClass(typeof(ClassLibrary.Class))]

namespace ClassLibrary
{
public class Class
{
class MenuCmd
{
static int AcadVersion = Autodesk.AutoCAD.ApplicationServices.Application.Version.Major;
// For AutoCAD 2006:
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, EntryPoint = "acedMenuCmd")]
extern private static int acedMenuCmd16(string cmd);
// For AutoCAD 2007:
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "acedMenuCmd")]
extern private static int acedMenuCmd17(string cmd);
public static int acedMenuCmd(string cmd)
{
switch (AcadVersion)
{
case 16: return acedMenuCmd16 (cmd);
case 17: return acedMenuCmd17 (cmd);
}
return -1;
}
};

[CommandMethod("TESTMENU")]
static public void test() // This method can have any name
{
MenuCmd.acedMenuCmd("p0=ACAD.OSNAP");
MenuCmd.acedMenuCmd("p0=*");
}
}
}
[/code]
Message 5 of 7
Anonymous
in reply to: Anonymous

Alexander Rivilis wrote:
> Try this code:
> [code]
> using System;
> using System.Runtime.InteropServices;
> using Autodesk.AutoCAD.Runtime;
>
> [assembly: CommandClass(typeof(ClassLibrary.Class))]
>
> namespace ClassLibrary
> {
> public class Class
> {
> class MenuCmd
> {
> static int AcadVersion = Autodesk.AutoCAD.ApplicationServices.Application.Version.Major;
> // For AutoCAD 2006:
> [System.Security.SuppressUnmanagedCodeSecurity]
> [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, EntryPoint = "acedMenuCmd")]
> extern private static int acedMenuCmd16(string cmd);
> // For AutoCAD 2007:
> [System.Security.SuppressUnmanagedCodeSecurity]
> [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "acedMenuCmd")]
> extern private static int acedMenuCmd17(string cmd);
> public static int acedMenuCmd(string cmd)
> {
> switch (AcadVersion)
> {
> case 16: return acedMenuCmd16 (cmd);
> case 17: return acedMenuCmd17 (cmd);
> }
> return -1;
> }
> };
>
> [CommandMethod("TESTMENU")]
> static public void test() // This method can have any name
> {
> MenuCmd.acedMenuCmd("p0=ACAD.OSNAP");
> MenuCmd.acedMenuCmd("p0=*");
> }
> }
> }
> [/code]

Hey thanks Alexander :0
I will try this as soon as I can.
Looks like a good example for me to learn from also.
Message 6 of 7
Anonymous
in reply to: Anonymous

Alexander Rivilis wrote:
> Try this code:
> [code]
> using System;
> using System.Runtime.InteropServices;
> using Autodesk.AutoCAD.Runtime;
>
> [assembly: CommandClass(typeof(ClassLibrary.Class))]
>
> namespace ClassLibrary
> {
> public class Class
> {
> class MenuCmd
> {
> static int AcadVersion = Autodesk.AutoCAD.ApplicationServices.Application.Version.Major;
> // For AutoCAD 2006:
> [System.Security.SuppressUnmanagedCodeSecurity]
> [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, EntryPoint = "acedMenuCmd")]
> extern private static int acedMenuCmd16(string cmd);
> // For AutoCAD 2007:
> [System.Security.SuppressUnmanagedCodeSecurity]
> [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode, EntryPoint = "acedMenuCmd")]
> extern private static int acedMenuCmd17(string cmd);
> public static int acedMenuCmd(string cmd)
> {
> switch (AcadVersion)
> {
> case 16: return acedMenuCmd16 (cmd);
> case 17: return acedMenuCmd17 (cmd);
> }
> return -1;
> }
> };
>
> [CommandMethod("TESTMENU")]
> static public void test() // This method can have any name
> {
> MenuCmd.acedMenuCmd("p0=ACAD.OSNAP");
> MenuCmd.acedMenuCmd("p0=*");
> }
> }
> }
> [/code]

Thanks Alexander
what you provided worked like a charm. Took me awhile though to figure
out how to "grey" a menu item. Not used to cui files yet, was using the
wrong "ID's". Works good now though 🙂

Can I access any Acad command the same way?
Perry
Message 7 of 7
Anonymous
in reply to: Anonymous

> Can I access any Acad command the same way?
Yes you can: http://discussion.autodesk.com/thread.jspa?messageID=4852689

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