.NET

Reply
Valued Contributor
cjacobi
Posts: 55
Registered: ‎11-12-2012
Message 1 of 3 (184 Views)
Accepted Solution

RunCommand 2015 not working

184 Views, 2 Replies
06-04-2014 06:54 AM

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

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.

 

*Expert Elite*
_gile
Posts: 2,125
Registered: ‎04-29-2006
Message 2 of 3 (161 Views)

Re : RunCommand 2015 not working

06-04-2014 08:35 AM in reply to: cjacobi

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
Valued Contributor
cjacobi
Posts: 55
Registered: ‎11-12-2012
Message 3 of 3 (143 Views)

Re : RunCommand 2015 not working

06-04-2014 10:58 AM 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!

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.