I am using TT's CommandLine class in my project. Initially, when I loaded the project in AutoCAD 2014 I had to change "acad.exe" to "accore.dll" and it worked fine and continues working fine in my developing machine. Now, I am having problems in some computers where the commandline class seems to be not working properly. It seems to me that I had come across some posts that talked about the differences in the function signature for 32 and 64bit platforms, however now I can't find any information about it. Can someone give me some help on this issue. It will be really appreciated.
Solved! Go to Solution.
I am using TT's CommandLine class in my project. Initially, when I loaded the project in AutoCAD 2014 I had to change "acad.exe" to "accore.dll" and it worked fine and continues working fine in my developing machine. Now, I am having problems in some computers where the commandline class seems to be not working properly. It seems to me that I had come across some posts that talked about the differences in the function signature for 32 and 64bit platforms, however now I can't find any information about it. Can someone give me some help on this issue. It will be really appreciated.
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Solved by DiningPhilosopher. Go to Solution.
There's no need to P/Invoke acedCmd() directly on recent releases of AutoCAD
thanks to the RunCommand wrapper (not sure what release it appeared in initially).
acedCmd() doesn't support the use of managed selection sets, but RunCommand()
does (it handles that internally for you) and allows them to be passed as arguments
where a command is expecting a selection set.
See this post:
http://forums.autodesk.com/t5/NET/Send-Command-Executes-after-exiting-command-method/td-p/3882929
There's no need to P/Invoke acedCmd() directly on recent releases of AutoCAD
thanks to the RunCommand wrapper (not sure what release it appeared in initially).
acedCmd() doesn't support the use of managed selection sets, but RunCommand()
does (it handles that internally for you) and allows them to be passed as arguments
where a command is expecting a selection set.
See this post:
http://forums.autodesk.com/t5/NET/Send-Command-Executes-after-exiting-command-method/td-p/3882929
DP thank you very much for your help, very appreciated. Now, would it be to much to ask if there is, you have or have seen a VB version. I am using VS2010 Express and can not use C# code. Trying to Port it myself will make the few hair left to fall out.
DP thank you very much for your help, very appreciated. Now, would it be to much to ask if there is, you have or have seen a VB version. I am using VS2010 Express and can not use C# code. Trying to Port it myself will make the few hair left to fall out.
Hi,
Here's a VB conversion of Tony's RunCommand wrapper.
With VB, extension methods have to be defined a module. If the module isn't part of the same namespace, you have to import it:
Imports EditorInputExtensionMethods
Module EditorInputExtensionMethods <System.Runtime.CompilerServices.Extension> _ Public Function Command(editor As Editor, ParamArray args As Object()) As PromptStatus If editor Is Nothing Then Throw New ArgumentNullException("editor") End If Return runCommand(editor, args) End Function Dim runCommand As Func(Of Editor, Object(), PromptStatus) = GenerateRunCommand() Private Function GenerateRunCommand() As Func(Of Editor, Object(), PromptStatus) Dim method As MethodInfo = GetType(Editor).GetMethod( _ "RunCommand", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.[Public]) Dim instance As ParameterExpression = Expression.Parameter(GetType(Editor), "editor") Dim args As ParameterExpression = Expression.Parameter(GetType(Object()), "args") Return Expression.Lambda(Of Func(Of Editor, Object(), PromptStatus)) _ (Expression.Call(instance, method, args), instance, args).Compile() End Function End Module
Hi,
Here's a VB conversion of Tony's RunCommand wrapper.
With VB, extension methods have to be defined a module. If the module isn't part of the same namespace, you have to import it:
Imports EditorInputExtensionMethods
Module EditorInputExtensionMethods <System.Runtime.CompilerServices.Extension> _ Public Function Command(editor As Editor, ParamArray args As Object()) As PromptStatus If editor Is Nothing Then Throw New ArgumentNullException("editor") End If Return runCommand(editor, args) End Function Dim runCommand As Func(Of Editor, Object(), PromptStatus) = GenerateRunCommand() Private Function GenerateRunCommand() As Func(Of Editor, Object(), PromptStatus) Dim method As MethodInfo = GetType(Editor).GetMethod( _ "RunCommand", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.[Public]) Dim instance As ParameterExpression = Expression.Parameter(GetType(Editor), "editor") Dim args As ParameterExpression = Expression.Parameter(GetType(Object()), "args") Return Expression.Lambda(Of Func(Of Editor, Object(), PromptStatus)) _ (Expression.Call(instance, method, args), instance, args).Compile() End Function End Module
Thank you both for your help. I have marked both of your posts as solutions, since it is what I was looking for. However, I have not been able to run or test this solution. Since the moment I added the ExtensionMethod to my project, I am getting a error message on VS 2010 that says "No Source Available". I am going to create a separate post about this issue. I have never come across something like this, but it seems to be common.
Thank you both for your help. I have marked both of your posts as solutions, since it is what I was looking for. However, I have not been able to run or test this solution. Since the moment I added the ExtensionMethod to my project, I am getting a error message on VS 2010 that says "No Source Available". I am going to create a separate post about this issue. I have never come across something like this, but it seems to be common.
I am having trouble with the EditorinputExtensionMethods. I'm not sure what I'm doing wrong, but when I call the editor.Command(parameters), absolutely nothing happens. I have access to the editor, because the editor.WriteMessage command works. I am calling the editor.Command from a button click on a windows form in a module loaded into AutoCAD with NETLOAD. Any insight would be greatly appreciated! Code is inserted below.
Imports System Imports System.Collections Imports System.Collections.Generic Imports System.IO Imports System.Linq Imports System.Reflection Imports System.Linq.Expressions Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.EditorInput Imports Autodesk.AutoCAD.Runtime Imports System.Windows.Forms Imports System.Runtime.InteropServices Imports System.Data.SqlServerCe Imports Autodesk.AutoCAD.Geometry Imports Autodesk.AutoCAD.ApplicationServices.DocumentExtension Module EditorInputExtensionMethods <System.Runtime.CompilerServices.Extension> _ Public Function Command(editor As Editor, ParamArray args As Object()) As PromptStatus If editor Is Nothing Then Throw New ArgumentNullException("editor") End If Return runCommand(editor, args) End Function Dim runCommand As Func(Of Editor, Object(), PromptStatus) = GenerateRunCommand() Private Function GenerateRunCommand() As Func(Of Editor, Object(), PromptStatus) Dim method As MethodInfo = GetType(Editor).GetMethod( _ "RunCommand", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) Dim instance As ParameterExpression = Expression.Parameter(GetType(Editor), "editor") 'Dim instance As ParameterExpression = Expression.Parameter(GetType(Editor), "instance") Dim args As ParameterExpression = Expression.Parameter(GetType(Object()), "args") Return Expression.Lambda(Of Func(Of Editor, Object(), PromptStatus)) _ (Expression.Call(instance, method, args), instance, args).Compile() End Function End Module Public Class frmMhsApp Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim ed As Editor = doc.Editor ed.Command("._line", New Point3d(0, 0, 0), New Point3d(5, 5, 0)) ed.WriteMessage("Message Test") End Sub
I am having trouble with the EditorinputExtensionMethods. I'm not sure what I'm doing wrong, but when I call the editor.Command(parameters), absolutely nothing happens. I have access to the editor, because the editor.WriteMessage command works. I am calling the editor.Command from a button click on a windows form in a module loaded into AutoCAD with NETLOAD. Any insight would be greatly appreciated! Code is inserted below.
Imports System Imports System.Collections Imports System.Collections.Generic Imports System.IO Imports System.Linq Imports System.Reflection Imports System.Linq.Expressions Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.EditorInput Imports Autodesk.AutoCAD.Runtime Imports System.Windows.Forms Imports System.Runtime.InteropServices Imports System.Data.SqlServerCe Imports Autodesk.AutoCAD.Geometry Imports Autodesk.AutoCAD.ApplicationServices.DocumentExtension Module EditorInputExtensionMethods <System.Runtime.CompilerServices.Extension> _ Public Function Command(editor As Editor, ParamArray args As Object()) As PromptStatus If editor Is Nothing Then Throw New ArgumentNullException("editor") End If Return runCommand(editor, args) End Function Dim runCommand As Func(Of Editor, Object(), PromptStatus) = GenerateRunCommand() Private Function GenerateRunCommand() As Func(Of Editor, Object(), PromptStatus) Dim method As MethodInfo = GetType(Editor).GetMethod( _ "RunCommand", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public) Dim instance As ParameterExpression = Expression.Parameter(GetType(Editor), "editor") 'Dim instance As ParameterExpression = Expression.Parameter(GetType(Editor), "instance") Dim args As ParameterExpression = Expression.Parameter(GetType(Object()), "args") Return Expression.Lambda(Of Func(Of Editor, Object(), PromptStatus)) _ (Expression.Call(instance, method, args), instance, args).Compile() End Function End Module Public Class frmMhsApp Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument Dim ed As Editor = doc.Editor ed.Command("._line", New Point3d(0, 0, 0), New Point3d(5, 5, 0)) ed.WriteMessage("Message Test") End Sub
I found my issue! I had to load my form as follows:
Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(frmApp)
Hope this helps someone else.
I found my issue! I had to load my form as follows:
Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(frmApp)
Hope this helps someone else.
I'm having the same issue as bruceamcd. Without a form it works fine.
But using a form with either Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog or ShowModelessDialog it doesn't.
I'm using Tony's Runcommand wrapper from Autocad 2014 x64.
FIBERWORLD is set to 1 as required.
Any thoughts on what might cause this behavior are welcome. thanks.
I'm having the same issue as bruceamcd. Without a form it works fine.
But using a form with either Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog or ShowModelessDialog it doesn't.
I'm using Tony's Runcommand wrapper from Autocad 2014 x64.
FIBERWORLD is set to 1 as required.
Any thoughts on what might cause this behavior are welcome. thanks.
Can't find what you're looking for? Ask the community or share your knowledge.