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

RunCommand 2015 not working

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
coralie.jacobi
788 Views, 2 Replies

RunCommand 2015 not working

Have a DLL that runs fine in 2014, but when I run it in 2015 it breaks on the "RunCommand" method. Do I need to recompile it all with .NET 4.5, or is there a way to get it to work in both releases.

 

Module MyEditorExtensions

    Dim runCommand As MethodInfo = _
        GetType(Editor).GetMethod("RunCommand", BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.Public)

    <System.Runtime.CompilerServices.Extension()> _
    Public Function Command(ed As Editor, ParamArray args As Object()) As PromptStatus
        If Application.DocumentManager.IsApplicationContext Then
            Throw New InvalidOperationException("Invalid execution context for Command()")
        End If
        If ed.Document <> Application.DocumentManager.MdiActiveDocument Then
            Throw New InvalidOperationException("Document is not active")
        End If
        Return DirectCast(runCommand.Invoke(ed, New Object() {args}), PromptStatus)
    End Function

End Module

***********************************

Public Sub MultipleJoin()
        Dim db As Database = HostApplicationServices.WorkingDatabase
        Dim doc As Document = DocumentManager.MdiActiveDocument()
        Dim ed As Editor = DocumentManager.MdiActiveDocument.Editor
        '  Dim acEditor As Editor = Application.DocumentManager.MdiActiveDocument.Editor
        Dim peditAccept As Short = CShort(Application.GetSystemVariable("PEDITACCEPT"))

        Try
            Application.SetSystemVariable("PEDITACCEPT", 1)
            Dim typedValues() As TypedValue = {New TypedValue(8, "EX-CROSS-WELL-SCREEN"), New TypedValue(0, "ARC,LINE,LWPOLYLINE")}
            Dim sf As SelectionFilter = New SelectionFilter(typedValues)
            Dim psr As PromptSelectionResult = ed.SelectAll(sf)
            If psr.Status <> PromptStatus.OK Then
                Return
            End If

            ed.Command("_.pedit", "_multiple", psr.Value, "", "_join", 0.0, "")

        Catch ex As Autodesk.AutoCAD.Runtime.Exception
            MsgBox(ex.Message)

        Finally
            Application.SetSystemVariable("PEDITACCEPT", peditAccept)

        End Try

    End Sub

 thanks for any input..

 

cj

2 REPLIES 2
Message 2 of 3
_gile
in reply to: coralie.jacobi

Hi,

 

The Editor.Command() is a new built-in method in AutoCAD 2015 (see here).

You can make a new project for AutoCAD 2015 with exactly the same code but the extension module.

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3
coralie.jacobi
in reply to: _gile

Thanks Giles,

 

After a bit of fumbling around I got it over to a new project. I'm using VS2013 Express. Had a hard time getting it to go into Debug mode. I downloaded the .NET wizard, but they only have a C# one built, not a VB one.

 

Anyway, through some searching I got the .vbproj.user files modified and got it running.

 

Function is working fine again in 2015...THANKS!

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