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

acedcommand function in .Net managed classes

9 REPLIES 9
Reply
Message 1 of 10
tangferry
3369 Views, 9 Replies

acedcommand function in .Net managed classes

What is the corresponding functions or classes for thesethe arx Global
function acedcommand in the .NET managed classes?
9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: tangferry

There's none. This function isn't exposed via the .NET API. The function
that comes closest is Document.SendStringToExecute.

Albert
wrote in message news:4852689@discussion.autodesk.com...
What is the corresponding functions or classes for thesethe arx Global
function acedcommand in the .NET managed classes?
Message 3 of 10
Anonymous
in reply to: tangferry

They didn't expose it.

Give the following a go, and see what happens.

Note that the same exact rules that govern the use
of acedCommand() in native ObjectARX apply here
(namely, you can't use it from the Application context).

////////////////// CommandSample.cs ///////////////////
// Copyright (c)2005 Tony Tanzillo, all rights reserved
//
// Shows how to execute commands without resorting
// to the kludgy SendStringToExecute method.
//
// The command 'COMMANDTEST' draws a circle
// centered at 2,2,0 with a radius of 4.0 units.

using System;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

public class CommandSample
{
const Int32 RTREAL = 5001;
const Int32 RTSTR = 5005;
const Int32 RT3DPOINT = 5009;

[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint="acedCmd")]
extern static int acedCmd(IntPtr pResbuf);

unsafe static int Command(ResultBuffer args)
{
if( ! AcadApp.DocumentManager.IsApplicationContext )
return acedCmd((IntPtr) args.UnmanagedObject.ToPointer());
else
return 0;
}

[Autodesk.AutoCAD.Runtime.CommandMethod("COMMANDTEST")]
public static void CommandTest()
{
ResultBuffer args = new ResultBuffer();
args.Add(new TypedValue(RTSTR, "._circle"));
args.Add(new TypedValue(RT3DPOINT, new Point3d(2.0, 2.0, 0.0)));
args.Add(new TypedValue(RTREAL, 4.0));
Command(args);
}
}



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:4852689@discussion.autodesk.com...
What is the corresponding functions or classes for thesethe arx Global
function acedcommand in the .NET managed classes?
Message 4 of 10
tangferry
in reply to: tangferry

can you tell me how to use Document.SendStringToExecute functioon?An example is not bad.
Message 5 of 10
Anonymous
in reply to: tangferry

I am trying to learn C# based on examples that I find in this discussion
group. With that said, based on the example below, I am receiving the error
message: The name 'acedCmd' does not exist in the class or namespace
'AcadTest01.CommandSample' Can someone help?


"Tony Tanzillo" wrote in message
news:4853121@discussion.autodesk.com...
They didn't expose it.

Give the following a go, and see what happens.

Note that the same exact rules that govern the use
of acedCommand() in native ObjectARX apply here
(namely, you can't use it from the Application context).

////////////////// CommandSample.cs ///////////////////
// Copyright (c)2005 Tony Tanzillo, all rights reserved
//
// Shows how to execute commands without resorting
// to the kludgy SendStringToExecute method.
//
// The command 'COMMANDTEST' draws a circle
// centered at 2,2,0 with a radius of 4.0 units.

using System;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

public class CommandSample
{
const Int32 RTREAL = 5001;
const Int32 RTSTR = 5005;
const Int32 RT3DPOINT = 5009;

[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint="acedCmd")]
extern static int acedCmd(IntPtr pResbuf);

unsafe static int Command(ResultBuffer args)
{
if( ! AcadApp.DocumentManager.IsApplicationContext )
return acedCmd((IntPtr) args.UnmanagedObject.ToPointer());
else
return 0;
}

[Autodesk.AutoCAD.Runtime.CommandMethod("COMMANDTEST")]
public static void CommandTest()
{
ResultBuffer args = new ResultBuffer();
args.Add(new TypedValue(RTSTR, "._circle"));
args.Add(new TypedValue(RT3DPOINT, new Point3d(2.0, 2.0, 0.0)));
args.Add(new TypedValue(RTREAL, 4.0));
Command(args);
}
}



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:4852689@discussion.autodesk.com...
What is the corresponding functions or classes for thesethe arx Global
function acedcommand in the .NET managed classes?
Message 6 of 10
Mikko
in reply to: tangferry

Something like this:
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("_Zoom _E ", False, True, False)
Message 7 of 10
Anonymous
in reply to: tangferry

You'll probably have more success "trying to learn C#" at places like
http://msdn.microsoft.com/vcsharp/gettingstarted/default.aspx; this
discussion group more-or-less assumes knowledge of a .NET language.

Dan

"Edward Merkins" wrote in message
news:4858845@discussion.autodesk.com...
I am trying to learn C# based on examples that I find in this discussion
group. With that said, based on the example below, I am receiving the error
message: The name 'acedCmd' does not exist in the class or namespace
'AcadTest01.CommandSample' Can someone help?


"Tony Tanzillo" wrote in message
news:4853121@discussion.autodesk.com...
They didn't expose it.

Give the following a go, and see what happens.

Note that the same exact rules that govern the use
of acedCommand() in native ObjectARX apply here
(namely, you can't use it from the Application context).

////////////////// CommandSample.cs ///////////////////
// Copyright (c)2005 Tony Tanzillo, all rights reserved
//
// Shows how to execute commands without resorting
// to the kludgy SendStringToExecute method.
//
// The command 'COMMANDTEST' draws a circle
// centered at 2,2,0 with a radius of 4.0 units.

using System;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

public class CommandSample
{
const Int32 RTREAL = 5001;
const Int32 RTSTR = 5005;
const Int32 RT3DPOINT = 5009;

[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint="acedCmd")]
extern static int acedCmd(IntPtr pResbuf);

unsafe static int Command(ResultBuffer args)
{
if( ! AcadApp.DocumentManager.IsApplicationContext )
return acedCmd((IntPtr) args.UnmanagedObject.ToPointer());
else
return 0;
}

[Autodesk.AutoCAD.Runtime.CommandMethod("COMMANDTEST")]
public static void CommandTest()
{
ResultBuffer args = new ResultBuffer();
args.Add(new TypedValue(RTSTR, "._circle"));
args.Add(new TypedValue(RT3DPOINT, new Point3d(2.0, 2.0, 0.0)));
args.Add(new TypedValue(RTREAL, 4.0));
Command(args);
}
}



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:4852689@discussion.autodesk.com...
What is the corresponding functions or classes for thesethe arx Global
function acedcommand in the .NET managed classes?
Message 8 of 10
Anonymous
in reply to: tangferry

Never mind - I had a typo.

"Edward Merkins" wrote in message
news:4858845@discussion.autodesk.com...
I am trying to learn C# based on examples that I find in this discussion
group. With that said, based on the example below, I am receiving the error
message: The name 'acedCmd' does not exist in the class or namespace
'AcadTest01.CommandSample' Can someone help?


"Tony Tanzillo" wrote in message
news:4853121@discussion.autodesk.com...
They didn't expose it.

Give the following a go, and see what happens.

Note that the same exact rules that govern the use
of acedCommand() in native ObjectARX apply here
(namely, you can't use it from the Application context).

////////////////// CommandSample.cs ///////////////////
// Copyright (c)2005 Tony Tanzillo, all rights reserved
//
// Shows how to execute commands without resorting
// to the kludgy SendStringToExecute method.
//
// The command 'COMMANDTEST' draws a circle
// centered at 2,2,0 with a radius of 4.0 units.

using System;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

public class CommandSample
{
const Int32 RTREAL = 5001;
const Int32 RTSTR = 5005;
const Int32 RT3DPOINT = 5009;

[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint="acedCmd")]
extern static int acedCmd(IntPtr pResbuf);

unsafe static int Command(ResultBuffer args)
{
if( ! AcadApp.DocumentManager.IsApplicationContext )
return acedCmd((IntPtr) args.UnmanagedObject.ToPointer());
else
return 0;
}

[Autodesk.AutoCAD.Runtime.CommandMethod("COMMANDTEST")]
public static void CommandTest()
{
ResultBuffer args = new ResultBuffer();
args.Add(new TypedValue(RTSTR, "._circle"));
args.Add(new TypedValue(RT3DPOINT, new Point3d(2.0, 2.0, 0.0)));
args.Add(new TypedValue(RTREAL, 4.0));
Command(args);
}
}



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:4852689@discussion.autodesk.com...
What is the corresponding functions or classes for thesethe arx Global
function acedcommand in the .NET managed classes?
Message 9 of 10
Anonymous
in reply to: tangferry

So I take it you didn't no the answer. Don't post responses if you don't
have anything intelligent to say! I am already somewhat familiar with C#.
Just like the majority of people in this discussion group, I am trying to
get a better understanding of using C# with AutoCAD.


"J. Daniel Smith" wrote in message
news:4858917@discussion.autodesk.com...
You'll probably have more success "trying to learn C#" at places like
http://msdn.microsoft.com/vcsharp/gettingstarted/default.aspx; this
discussion group more-or-less assumes knowledge of a .NET language.

Dan

"Edward Merkins" wrote in message
news:4858845@discussion.autodesk.com...
I am trying to learn C# based on examples that I find in this discussion
group. With that said, based on the example below, I am receiving the error
message: The name 'acedCmd' does not exist in the class or namespace
'AcadTest01.CommandSample' Can someone help?


"Tony Tanzillo" wrote in message
news:4853121@discussion.autodesk.com...
They didn't expose it.

Give the following a go, and see what happens.

Note that the same exact rules that govern the use
of acedCommand() in native ObjectARX apply here
(namely, you can't use it from the Application context).

////////////////// CommandSample.cs ///////////////////
// Copyright (c)2005 Tony Tanzillo, all rights reserved
//
// Shows how to execute commands without resorting
// to the kludgy SendStringToExecute method.
//
// The command 'COMMANDTEST' draws a circle
// centered at 2,2,0 with a radius of 4.0 units.

using System;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

public class CommandSample
{
const Int32 RTREAL = 5001;
const Int32 RTSTR = 5005;
const Int32 RT3DPOINT = 5009;

[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint="acedCmd")]
extern static int acedCmd(IntPtr pResbuf);

unsafe static int Command(ResultBuffer args)
{
if( ! AcadApp.DocumentManager.IsApplicationContext )
return acedCmd((IntPtr) args.UnmanagedObject.ToPointer());
else
return 0;
}

[Autodesk.AutoCAD.Runtime.CommandMethod("COMMANDTEST")]
public static void CommandTest()
{
ResultBuffer args = new ResultBuffer();
args.Add(new TypedValue(RTSTR, "._circle"));
args.Add(new TypedValue(RT3DPOINT, new Point3d(2.0, 2.0, 0.0)));
args.Add(new TypedValue(RTREAL, 4.0));
Command(args);
}
}



--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

wrote in message news:4852689@discussion.autodesk.com...
What is the corresponding functions or classes for thesethe arx Global
function acedcommand in the .NET managed classes?
Message 10 of 10
Anonymous
in reply to: tangferry

Can Document.SendStringToExecute() be used (and executed) from within an
application? I'm trying to write a VB.NET batch script processor and what
seems to be happening is that the script doesn'tr execute until my app has
finished. When I've tested my DLL code on a single DWG file my app runs all
the way through, first setting FILEDIA to 0 then back to 1 but the command
my app sends as a string doesn't execute until my app has finished, so
FILEDIA is set back to 1 and the user has to browse for the script file to
run.

Is there a reson why SendCommand hasn't been exposed in the .NET API?

I've successfully built a version of my app as an exe using COM but I'm
trying to get my head into the .NET API. The code I have so far follows:

THIS WORKS IN MY EXE

Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common

Public WithEvents AcadApp As Autodesk.AutoCAD.Interop.AcadApplication
Dim AcadDoc As Autodesk.AutoCAD.Interop.AcadDocument

Sub ProcessDwg(ByVal ThisDwg As String)
'open the file
AcadDoc.Application.Documents.Open(ThisDwg)
AcadDoc = AcadApp.ActiveDocument
'AcadApp.ZoomExtents()

'process the script
AcadDoc.SetVariable("filedia", 0)

AcadDoc.SendCommand("script" & vbCr & """" & Me.txtScriptFile.Text &
"""" & vbCr)

AcadDoc.SetVariable("filedia", 1)

'close the file
AcadDoc.Close(Me.chkSaveDWG.Checked, ThisDwg)
End Sub


THIS DOESN'T WORK IN MY DLL

Imports acadApp = Autodesk.AutoCAD.ApplicationServices.Application
Imports acadDoc = Autodesk.AutoCAD.ApplicationServices.Document

Dim file As acadDoc

Sub ProcessDwg(ByVal ThisDwg As String)

acadApp.DocumentManager.Open(ThisDwg)
file = acadApp.DocumentManager.MdiActiveDocument
'AcadApp.ZoomExtents()

'process the script
acadApp.SetSystemVariable("filedia", 0)

file.SendStringToExecute("script" & vbCr & """" & Me.txtScript.Text
& """" & vbCr, False, False, False)

acadApp.SetSystemVariable("filedia", 1)

'close the file
file.CloseAndSave(ThisDwg)
End Sub

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