Author Topic: Overkill Command  (Read 16892 times)

0 Members and 1 Guest are viewing this topic.

TJK44

  • Guest
Overkill Command
« on: April 08, 2013, 11:24:39 AM »
Hi all,

I am trying to use this bit of code to run the overkill command silently in the background. I can't use SendStringToExecute because it does not execute synchronously. After you enter "All" in the autocad command line and select the objects a dialog appears each time the command is run, I would also want to suppress this dialog.
Code - Visual Basic: [Select]
  1.                 Dim rb As New ResultBuffer
  2.                 rb.Add(New TypedValue(5005, "_.OVERKILL"))
  3.                 acedCmd(rb.UnmanagedObject)
  4.  
  5.                 rb = New ResultBuffer
  6.                 rb.Add(New TypedValue(5005, "ALL"))
  7.                 acedCmd(rb.UnmanagedObject)
  8.  
  9.                 rb = New ResultBuffer
  10.                 rb.Add(New TypedValue(5005, vbLf))
  11.                 acedCmd(rb.UnmanagedObject)
  12.  
  13.                 rb = New ResultBuffer
  14.                 rb.Add(New TypedValue(5005, vbLf))
  15.                 acedCmd(rb.UnmanagedObject)
  16.  
  17.                 rb = New ResultBuffer
  18.                 rb.Add(New TypedValue(5005, vbLf))
  19.                 acedCmd(rb.UnmanagedObject)
  20.  
Thanks in advance,

-Ted
« Last Edit: April 08, 2013, 03:35:01 PM by TJK44 »

TheMaster

  • Guest
Re: Overkill Command
« Reply #1 on: April 08, 2013, 02:25:06 PM »
Hi all,

I am trying to use this bit of code to run the overkill command silently in the background. I can't use SendStringToExecute because it does not execute synchronously. After you enter "All" in the autocad command line and select the objects a dialog appears each time the command is run, I would also want to suppress this dialog.

                Dim rb As New ResultBuffer
                rb.Add(New TypedValue(5005, "_.OVERKILL"))
                acedCmd(rb.UnmanagedObject)

                rb = New ResultBuffer
                rb.Add(New TypedValue(5005, "ALL"))
                acedCmd(rb.UnmanagedObject)

                rb = New ResultBuffer
                rb.Add(New TypedValue(5005, vbLf))
                acedCmd(rb.UnmanagedObject)

                rb = New ResultBuffer
                rb.Add(New TypedValue(5005, vbLf))
                acedCmd(rb.UnmanagedObject)

                rb = New ResultBuffer
                rb.Add(New TypedValue(5005, vbLf))
                acedCmd(rb.UnmanagedObject)

Thanks in advance,

-Ted

Hi Ted.  It depends on what AutoCAD release(s) you're trying to use this with.

Overkill was made a built-in command in AutoCAD 2012, but prior to that it was an express tool that could not be automated via acedCmd().


TJK44

  • Guest
Re: Overkill Command
« Reply #2 on: April 08, 2013, 02:26:54 PM »
Hi Tony,

This would be for release 2012 and later. Testing on 2012

TheMaster

  • Guest
Re: Overkill Command
« Reply #3 on: April 08, 2013, 04:21:08 PM »
Hi Tony,

This would be for release 2012 and later. Testing on 2012

You should probably avoid acedCmd() in AutoCAD 2012 or later, since the Editor's RunCommand method does the grunt work for you and also translates all supported types including selection sets, which isn't done by acedCmd(). The Command() wrapper method shown below is one way to use RunCommand() without the overhead of reflection.

Your problem is solved very simply by using the command line version of OVERKILL, whose name starts with a hyphen (e.g., "-OVERKILL").



Code - C#: [Select]
  1. /// Example use of OVERKILL command
  2. /// (AutoCAD 2012 or later only)
  3. /// from managed code.
  4.  
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Reflection;
  10. using Autodesk.AutoCAD.Runtime;
  11. using Autodesk.AutoCAD.EditorInput;
  12. using Autodesk.AutoCAD.ApplicationServices;
  13. using Autodesk.AutoCAD.DatabaseServices;
  14.  
  15. namespace Namespace1
  16. {
  17.    public static class OverkillExample
  18.    {
  19.       [CommandMethod( "MYOVERKILL" )]
  20.       public static void MyOverkill()
  21.       {
  22.          Document doc = Application.DocumentManager.MdiActiveDocument;
  23.          
  24.          // Note the leading "-" on the OVERKILL command, which
  25.          // forces it to use the command line:
  26.          
  27.          doc.Editor.Command( "._-OVERKILL", "_ALL", "", "" );
  28.       }
  29.    }
  30. }
  31.  
  32.  
  33. /// EditorUtils.cs - Non-reflection-based access to the
  34. /// Editor's non-public RunCommand() method.
  35.  
  36. using System;
  37. using System.Collections.Generic;
  38. using System.Linq;
  39. using System.Text;
  40. using System.Linq.Expressions;
  41. using System.Reflection;
  42. using Autodesk.AutoCAD.ApplicationServices;
  43.  
  44. namespace Autodesk.AutoCAD.EditorInput
  45. {
  46.    public static class EditorInputExtensionMethods
  47.    {
  48.       public static PromptStatus Command( this Editor editor, params object[] args )
  49.       {
  50.          if( editor == null )
  51.             throw new ArgumentNullException( "editor" );
  52.          return runCommand( editor, args );
  53.       }
  54.  
  55.       static Func<Editor, object[], PromptStatus> runCommand = GenerateRunCommand();
  56.  
  57.       static Func<Editor, object[], PromptStatus> GenerateRunCommand()
  58.       {
  59.          MethodInfo method = typeof( Editor ).GetMethod( "RunCommand",
  60.             BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public );
  61.          var instance = Expression.Parameter( typeof( Editor ), "instance" );
  62.          var args = Expression.Parameter( typeof( object[] ), "args" );
  63.          return Expression.Lambda<Func<Editor, object[], PromptStatus>>(
  64.             Expression.Call( instance, method, args ), instance, args )
  65.                .Compile();
  66.       }
  67.    }
  68. }
  69.  
  70.  

TJK44

  • Guest
Re: Overkill Command
« Reply #4 on: April 09, 2013, 08:58:51 AM »
Thanks a lot for that example Tony, in the process of trying to get it to work in vb.

Edit:
I'm not that familiar with creating extensions, I tried writing it by hand and using a conversion website. Both ways I am getting an error with the Command Function. I am getting Type Editor and Type PromptStatus are not defined. I created a new class in my project called EditorUtils.vb and added the code below. Any ideas appreciated. Thanks.

Code - Visual Basic: [Select]
  1. Imports System.Collections.Generic
  2. Imports System.Linq
  3. Imports System.Text
  4. Imports System.Linq.Expressions
  5. Imports System.Reflection
  6. Imports Autodesk.AutoCAD.ApplicationServices
  7.  
  8. Namespace AutoDesk.AutoCAD.EditorInput
  9.     Public Class EditorInputExtensionMethods
  10.         Private Sub New()
  11.         End Sub
  12.  
  13.         <System.Runtime.CompilerServices.Extension()> _
  14.         Public Shared Function Command(ByVal editor As Editor, ParamArray args As Object()) As PromptStatus
  15.  
  16.         End Function
  17.     End Class
  18. End Namespace
  19.  
« Last Edit: April 09, 2013, 09:12:26 AM by TJK44 »

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Overkill Command
« Reply #5 on: April 09, 2013, 09:51:31 AM »
Hi,

In VB extension methods have to defined in a module.

Code - vb.net: [Select]
  1. Imports System.Linq.Expressions
  2. Imports System.Reflection
  3. Imports Autodesk.AutoCAD.EditorInput
  4.  
  5. Namespace AcadVb2010
  6.  
  7.     Module EditorInputExtensionMethods
  8.  
  9.         <System.Runtime.CompilerServices.Extension()> _
  10.         Public Function Command(ed As Editor, ParamArray args() As Object)
  11.             If ed Is Nothing Then
  12.                 Throw New ArgumentNullException("editor")
  13.             End If
  14.             Return runCommand(ed, args)
  15.         End Function
  16.  
  17.         Dim runCommand As Func(Of Editor, Object(), PromptStatus) = GenerateRunCommand()
  18.  
  19.         Public Function GenerateRunCommand() As Func(Of Editor, Object(), PromptStatus)
  20.             Dim method As MethodInfo = GetType(Editor).GetMethod( _
  21.                 "RunCommand", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.[Public])
  22.             Dim instance = Expression.Parameter(GetType(Editor), "instance")
  23.             Dim args = Expression.Parameter(GetType(Object()), "args")
  24.             Return Expression.Lambda(Of Func(Of Editor, Object(), PromptStatus)) _
  25.                 (Expression.[Call](instance, method, args), instance, args).Compile()
  26.         End Function
  27.  
  28.     End Module
  29.  
  30. End Namespace
Speaking English as a French Frog

TJK44

  • Guest
Re: Overkill Command
« Reply #6 on: April 09, 2013, 10:04:43 AM »
Hi and thanks Gile. Are you missing an Imports statement? I am getting 'Func' is ambiguous in namespace System?

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Overkill Command
« Reply #7 on: April 09, 2013, 10:15:44 AM »
Hi and thanks Gile. Are you missing an Imports statement? I am getting 'Func' is ambiguous in namespace System?

No.
Maybe it depends on the Framework targeted (4.0 here).
I'm not very comfortable with VB.
Speaking English as a French Frog

TheMaster

  • Guest
Re: Overkill Command
« Reply #8 on: April 09, 2013, 05:35:25 PM »
Here is what Reflector spits out, and it seems to compile but I haven't actually tried to run it:

Code - Visual Basic: [Select]
  1. Imports Autodesk.AutoCAD.EditorInput
  2. Imports System.Linq.Expressions
  3. Imports System.Reflection
  4.  
  5. <Runtime.CompilerServices.Extension()>
  6. Module Module1
  7.    <Runtime.CompilerServices.Extension()> _
  8.    Public Function Command(ByVal editor As Editor, ByVal ParamArray args As Object()) As PromptStatus
  9.       If (editor Is Nothing) Then
  10.          Throw New ArgumentNullException("editor")
  11.       End If
  12.       Return runCommand.Invoke(editor, args)
  13.    End Function
  14.  
  15.    Private Function GenerateRunCommand() As Func(Of Editor, Object(), PromptStatus)
  16.       Dim instance As ParameterExpression
  17.       Dim args As ParameterExpression
  18.       Dim method As MethodInfo = GetType(Editor).GetMethod("RunCommand", (BindingFlags.NonPublic Or (BindingFlags.Public Or BindingFlags.Instance)))
  19.       Return Expression.Lambda(Of Func(Of Editor, Object(), PromptStatus))(Expression.Call(Expression.Parameter(GetType(Editor), "instance"), method, New Expression() {Expression.Parameter(GetType(Object()), "args")}), New ParameterExpression() {instance, args}).Compile
  20.    End Function
  21.  
  22.  
  23.    ' Fields
  24.   Private runCommand As Func(Of Editor, Object(), PromptStatus) = GenerateRunCommand()
  25.  
  26. End Module
  27.  
  28.  

TJK44

  • Guest
Re: Overkill Command
« Reply #9 on: April 10, 2013, 08:09:59 AM »
For some reason I am still getting the error 'Func' is ambiguous in the namespace 'System'

The target framework is 4.0, attached is a screenshot of what I have for references. Google search doesn't really return anything useful for this certain error either

Edit: I went in to the object explorer and searched for Func. It looks like Func exists in System.Core and mscorlib.

Edit: I changed the target framework from 4.0 to 3.5 and these errors went away. Weird...

« Last Edit: April 10, 2013, 08:40:32 AM by TJK44 »

TJK44

  • Guest
Re: Overkill Command
« Reply #10 on: May 01, 2013, 09:32:04 AM »
Hi,

I am still having the same issue where VS is telling me 'Func' is ambiguous in the namespace 'System'.

I thought maybe it was the project I was working in because it is pretty large in size and didn't want to mess around with too many settings.

I created a new project from scratch using the AutoCAD plug-in wizard and accepted the defaults to the window that pops up.

I created a new class and entered the code as seen below and still get the ambiguous error. Can anyone else verify if they get the same behavior?

Thanks,

-Ted

 
Code - Visual Basic: [Select]
  1. Imports Autodesk.AutoCAD.EditorInput
  2. Imports System.Linq.Expressions
  3. Imports System.Reflection
  4.  
  5. <Runtime.CompilerServices.Extension()>
  6. Module Module1
  7.     <Runtime.CompilerServices.Extension()> _
  8.     Public Function Command(ByVal editor As Editor, ByVal ParamArray args As Object()) As PromptStatus
  9.         If (editor Is Nothing) Then
  10.             Throw New ArgumentNullException("editor")
  11.         End If
  12.         Return runCommand.Invoke(editor, args)
  13.     End Function
  14.  
  15.     Private Function GenerateRunCommand() As System.Func(Of Editor, Object(), PromptStatus)
  16.         Dim instance As ParameterExpression
  17.         Dim args As ParameterExpression
  18.         Dim method As MethodInfo = GetType(Editor).GetMethod("RunCommand", (BindingFlags.NonPublic Or (BindingFlags.Public Or BindingFlags.Instance)))
  19.         Return Expression.Lambda(Of System.Func(Of Editor, Object(), PromptStatus))(Expression.Call(Expression.Parameter(GetType(Editor), "instance"), method, New Expression() {Expression.Parameter(GetType(Object()), "args")}), New ParameterExpression() {instance, args}).Compile
  20.     End Function
  21.  
  22.     ' Fields
  23.    Private runCommand As System.Func(Of Editor, Object(), PromptStatus) = GenerateRunCommand()
  24.  
  25. End Module
  26.  

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Overkill Command
« Reply #11 on: May 01, 2013, 01:35:40 PM »
It will build for me and maybe go to project properties and uncheck it from imported namespaces and see if using a importing statement helps or maybe load up the project.
 
You might have to do a repair on framework.
http://msdn.microsoft.com/en-us/library/8f0k13d2.aspx
 
You could also look at results from Gacutil.exe to help find problems

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Overkill Command
« Reply #12 on: May 01, 2013, 02:13:12 PM »
Hi,

This one works on my computer:
Code - vb.net: [Select]
  1.     Module EditorInputExtensionMethods
  2.  
  3.         <System.Runtime.CompilerServices.Extension> _
  4.         Public Function Command(editor As Editor, ParamArray args As Object()) As PromptStatus
  5.             If editor Is Nothing Then
  6.                 Throw New ArgumentNullException("editor")
  7.             End If
  8.             Return runCommand(editor, args)
  9.         End Function
  10.  
  11.         Dim runCommand As Func(Of Editor, Object(), PromptStatus) = GenerateRunCommand()
  12.  
  13.         Private Function GenerateRunCommand() As Func(Of Editor, Object(), PromptStatus)
  14.             Dim method As MethodInfo = GetType(Editor).GetMethod( _
  15.                 "RunCommand", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.[Public])
  16.             Dim instance As ParameterExpression = Expression.Parameter(GetType(Editor), "editor")
  17.             Dim args As ParameterExpression = Expression.Parameter(GetType(Object()), "args")
  18.             Return Expression.Lambda(Of Func(Of Editor, Object(), PromptStatus))( _
  19.                 Expression.Call(instance, method, args), instance, args).Compile()
  20.         End Function
  21.  
  22.     End Module
Speaking English as a French Frog

TJK44

  • Guest
Re: Overkill Command
« Reply #13 on: May 01, 2013, 03:37:05 PM »
Quote

It will build for me and maybe go to project properties and uncheck it from imported namespaces and see if using a importing statement helps or maybe load up the project.
 
You might have to do a repair on framework.
http://msdn.microsoft.com/en-us/library/8f0k13d2.aspx
 
You could also look at results from Gacutil.exe to help find problems

Hi Jeff,

Thanks for the suggestions, if you look at the code I posted I did try to fully qualify the name but still getting the ambiguous error.

System.Func should be the fully qualified name right?

Do you think there could be an issue with the .NET 4.0 framework installed on my machine since I created an empty project and it still won't compile?

Edit:
I tried to also create a C# project using the AutoCAD wizard then created a class using Tony's example. Still getting the same error.

Edit:
Looking at the error message close it looks like there is a reference to a file in the AutoDesk folder to System.Core.DLL. What is this, do I need it?
« Last Edit: May 01, 2013, 04:09:42 PM by TJK44 »

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Overkill Command
« Reply #14 on: May 01, 2013, 07:00:03 PM »
The first thing I would do is try to isolate what causes the ambiguity, but I am not familiar with mechanical and can not see why they would distribute assemblies that would clash with BCL.
 
Does the AutoCAD installation folder contain a System.Core.Dll?
Also are you referencing the dll's in SDK or AutoCAD installation folder?
 
To maybe isolate if has to do referencing dll's in AutoCAD folder create a new Windows Console Application and try the code below to see what happens
Code - Visual Basic: [Select]
  1.  
  2.  Module Module1
  3.     Sub Main()
  4.         Dim addOne As Func(Of Integer, Integer) = Function(i) i + 1
  5.         Dim num As Integer
  6.         Console.Write("Enter integer: ")
  7.         While (Not (Integer.TryParse(Console.ReadLine(), num)))
  8.             Console.WriteLine("Please enter an Integer only: ")
  9.         End While
  10.         Console.WriteLine("Adding 1 to {0} is {1}", num, addOne(num))
  11.         Console.Read()
  12.     End Sub
  13. End Module
  14.  

TheMaster

  • Guest
Re: Overkill Command
« Reply #15 on: May 01, 2013, 11:11:34 PM »
Quote

It will build for me and maybe go to project properties and uncheck it from imported namespaces and see if using a importing statement helps or maybe load up the project.
 
You might have to do a repair on framework.
http://msdn.microsoft.com/en-us/library/8f0k13d2.aspx
 
You could also look at results from Gacutil.exe to help find problems

Hi Jeff,

Thanks for the suggestions, if you look at the code I posted I did try to fully qualify the name but still getting the ambiguous error.

System.Func should be the fully qualified name right?

Do you think there could be an issue with the .NET 4.0 framework installed on my machine since I created an empty project and it still won't compile?

Edit:
I tried to also create a C# project using the AutoCAD wizard then created a class using Tony's example. Still getting the same error.

Edit:
Looking at the error message close it looks like there is a reference to a file in the AutoDesk folder to System.Core.DLL. What is this, do I need it?

Do you know if it was installed with the software?  If so, then that's definitely a problem.

System.Core.dll should not be anywhere except in your .NET framework distribution folder. That's not a file that should be deployed with any application that uses it.

Try renaming it, and then starting AutoCAD and see if there's a problem. Also have a look at acad.exe.config to see what redirects there are if any.

If Autodesk distributed that file with the software, that's a major screw-up.

TJK44

  • Guest
Re: Overkill Command
« Reply #16 on: May 02, 2013, 08:12:31 AM »
This is weird, when I rename the System.Core.dll file in C:\Program Files\Autodesk\AutoCAD Mechanical 2012 and then start AutoCAD it regenerates this file. On starting also says please wait while windows configures AutoCAD each time this file is not present. I tried resetting Settings to Default then renaming this file but same behavior.

I also opened acad.exe.config in notepad and searched for System.Core, nowhere to be found.

Edit: It seems like this file is getting referenced when using AutoCADs wizard. If I create an empty Class Library and reference the AutoCAD dlls then create Tony's Editor Extension Method class I don't get these errors. Not sure if there would be a way to fix an older project to not reference this System.Core file in the AutoCAD install folder. I cannot find the reference to this dll anywhere in the project.
« Last Edit: May 02, 2013, 08:37:17 AM by TJK44 »

TheMaster

  • Guest
Re: Overkill Command
« Reply #17 on: May 02, 2013, 11:08:53 AM »
This is weird, when I rename the System.Core.dll file in C:\Program Files\Autodesk\AutoCAD Mechanical 2012 and then start AutoCAD it regenerates this file. On starting also says please wait while windows configures AutoCAD each time this file is not present. I tried resetting Settings to Default then renaming this file but same behavior.

I also opened acad.exe.config in notepad and searched for System.Core, nowhere to be found.

Edit: It seems like this file is getting referenced when using AutoCADs wizard. If I create an empty Class Library and reference the AutoCAD dlls then create Tony's Editor Extension Method class I don't get these errors. Not sure if there would be a way to fix an older project to not reference this System.Core file in the AutoCAD install folder. I cannot find the reference to this dll anywhere in the project.

In that case, Autodesk is installing System.Core.dll, but I can't fathom why they would do that, and install it into the application folder.  That makes no sense at all.

The reference is most-likely indirect. IOW, one of the AutoCAD assemblies that you're referencing is referencing it.

TJK44

  • Guest
Re: Overkill Command
« Reply #18 on: May 02, 2013, 02:25:56 PM »
Does anyone else who has an install of AutoCAD 2012 see the same behavior?

TheMaster

  • Guest
Re: Overkill Command
« Reply #19 on: May 02, 2013, 03:14:56 PM »
Does anyone else who has an install of AutoCAD 2012 see the same behavior?

i just looked and noticed that it's installed in my AutoCAD 2012 folder too, and the version of the assembly is 3.5. What framework release is your project targeting, and is it installed into the same folder as Acad.exe ?

TJK44

  • Guest
Re: Overkill Command
« Reply #20 on: May 02, 2013, 04:18:03 PM »
Thanks Tony,

My project is targeting .NET 4.0.

What are you asking is installed into my acad folder?

TheMaster

  • Guest
Re: Overkill Command
« Reply #21 on: May 02, 2013, 04:20:55 PM »
Thanks Tony,

My project is targeting .NET 4.0.

What are you asking is installed into my acad folder?

Is your project's assembly installed in the same folder as Acad.exe/System.Core.dll is what I mean by the last question.

TJK44

  • Guest
Re: Overkill Command
« Reply #22 on: May 02, 2013, 10:23:34 PM »
No it is not. The project is not located locally on my machine, it is located on a server.

TheMaster

  • Guest
Re: Overkill Command
« Reply #23 on: May 03, 2013, 12:47:27 AM »
No it is not. The project is not located locally on my machine, it is located on a server.

Have you tried running your app from the local system, and if so, is the result the same?

TJK44

  • Guest
Re: Overkill Command
« Reply #24 on: May 03, 2013, 08:16:21 AM »
Quote
Have you tried running your app from the local system, and if so, is the result the same?

I copied the project folder locally and same result when open in VS

It seems like it is the wizard that is referencing the System.Core dll from the AutoCAD folder because if I create a new project and reference the AutoCAD dlls (AcDbMgd and AcMgd) manually I didn't have the same issue of ambiguity. But if I use the wizard I see this issue.

At this point I just want to not reference the System.Core dll from the AutoCAD folder because I shouldn't even need a reference to it and I don't want to have to recreate the project because I have a lot of forms I would need to recreate and code to make sure is correct again.

This is starting to get frustrating because I can't find the reference anywhere and I don't see why it would be referenced in the first place with the wizard?
« Last Edit: May 03, 2013, 08:21:25 AM by TJK44 »

TheMaster

  • Guest
Re: Overkill Command
« Reply #25 on: May 03, 2013, 05:09:36 PM »
Quote
Have you tried running your app from the local system, and if so, is the result the same?

I copied the project folder locally and same result when open in VS

It seems like it is the wizard that is referencing the System.Core dll from the AutoCAD folder because if I create a new project and reference the AutoCAD dlls (AcDbMgd and AcMgd) manually I didn't have the same issue of ambiguity. But if I use the wizard I see this issue.

At this point I just want to not reference the System.Core dll from the AutoCAD folder because I shouldn't even need a reference to it and I don't want to have to recreate the project because I have a lot of forms I would need to recreate and code to make sure is correct again.

This is starting to get frustrating because I can't find the reference anywhere and I don't see why it would be referenced in the first place with the wizard?

I don't use the wizard so I can't tell you much about what it is doing, but my guess is that the reference is indirect (IOW, one of the Autodesk assemblies referenced by your project references the file in the AutoCAD folder).

And, it is probably not AcMgd or AcDbMgd, it is most-likely one of the assemblies that is dependent on WPF (like AdWindows.dll), so unless you referenced all of the assemblies that are referenced in the problem solution, you might not see it.

[Update]

Here is something that may be worth a try: If your project contains references to any assemblies located in the AutoCAD program folder (and are not in the SDK folder), try copying those assemblies to the SDK folder, and reference them from there (CopyLocal=false). Because System.Core.dll is not in the SDK folder, the Autodesk assemblies that are referencing it should use the same one that you're referencing.

« Last Edit: May 04, 2013, 04:04:03 PM by TT »

TJK44

  • Guest
Re: Overkill Command
« Reply #26 on: May 06, 2013, 10:22:28 AM »
Hi Tony,

Thanks for your time.

I copied AcDbMgd, AcMgd, and AdWindows to the separate folder, deleted the references created by the wizard and the reference the dlls in the other folder. Same situation arises. It seems like there is no way around this if using AutoCAD's wizard.

MexicanCustard

  • Swamp Rat
  • Posts: 705
Re: Overkill Command
« Reply #27 on: May 06, 2013, 01:43:20 PM »
At the risk of sounding like Captain Obvious,  don't use the wizard.

I never liked their wizard.  I used AcadNetAddinWizard for a while too.  Now I just created a basic template for AutoCAD and another one for AutoCAD MEP and I just use those to start with.  That along with some basic snippets on my tool bar and I never seem to need to use the wizard anymore.
Revit 2019, AMEP 2019 64bit Win 10

TJK44

  • Guest
Re: Overkill Command
« Reply #28 on: May 06, 2013, 01:51:53 PM »
I'm not going to use the wizard anymore, but this VS studio project was one of my earlier ones so I used Autodesk's wizard. I really don't want to have to recreate the entire project if it's not necessary.

TheMaster

  • Guest
Re: Overkill Command
« Reply #29 on: May 06, 2013, 08:13:21 PM »
I'm not going to use the wizard anymore, but this VS studio project was one of my earlier ones so I used Autodesk's wizard. I really don't want to have to recreate the entire project if it's not necessary.

I've used project templates right from the outset, and have never used their Wizard.

I have different project templates for different project types, some include WinForms or WPF or both, and others include some of my own libraries assemblies.

There isn't much the Wizard does except set a few properties (like native debugging, and it even asks you if you want it on x64, which isn't supported).

The wizard may be ok for a complete noob, but most the experience, it is like tits on a bull.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Overkill Command
« Reply #30 on: May 06, 2013, 09:28:59 PM »
Quote
... it is like tits on a bull.
Thanks Tony.
That takes me back about 50+ years to our next door neighbour on the farm.
He was Irish and another of his favourite sayings was 'Take your hurry boy'.

He had 2 daughters, but that's another story altogether.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

TJK44

  • Guest
Re: Overkill Command
« Reply #31 on: May 09, 2013, 03:43:56 PM »
I think I found a workaround that appears to work so I don't have to rebuild my project, although I would really like to incorporate Tony's Extension Method  :-(

Code - Visual Basic: [Select]
  1.                 Dim curAcadDoc As Object = Application.DocumentManager.MdiActiveDocument.AcadDocument
  2.                 curAcadDoc.SendCommand("._-OVERKILL" & vbLf)
  3.                 curAcadDoc.SendCommand("_ALL" & vbLf)
  4.                 curAcadDoc.SendCommand(vbLf)
  5.                 curAcadDoc.SendCommand(vbLf)
  6.  

Edit:
I lied, this still does not execute synchronously. Back to the drawing board.
« Last Edit: May 09, 2013, 03:56:37 PM by TJK44 »

TheMaster

  • Guest
Re: Overkill Command
« Reply #32 on: May 10, 2013, 01:55:45 AM »
I think I found a workaround that appears to work so I don't have to rebuild my project, although I would really like to incorporate Tony's Extension Method  :-(

Code - Visual Basic: [Select]
  1.                 Dim curAcadDoc As Object = Application.DocumentManager.MdiActiveDocument.AcadDocument
  2.                 curAcadDoc.SendCommand("._-OVERKILL" & vbLf)
  3.                 curAcadDoc.SendCommand("_ALL" & vbLf)
  4.                 curAcadDoc.SendCommand(vbLf)
  5.                 curAcadDoc.SendCommand(vbLf)
  6.  

Edit:
I lied, this still does not execute synchronously. Back to the drawing board.

If you're still having problems getting the RunCommand wrapper working, you can also use reflection to call it, without the System.Core.dll problem. 

Here's a post with the reflection-based version:

http://www.theswamp.org/index.php?topic=43113.msg483306#msg483306


TJK44

  • Guest
Re: Overkill Command
« Reply #33 on: May 13, 2013, 02:12:07 PM »
Thanks Tony, that did the trick.