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

Document CloseAndDiscard In 2013

18 REPLIES 18
SOLVED
Reply
Message 1 of 19
Hugh_Compton
2245 Views, 18 Replies

Document CloseAndDiscard In 2013

 

The Doc.CloseAndDiscard() method on documents returns message of ' not a member of 'Autodesk.AutoCAD.ApplicationServices.Document'. 

 

How do we close a dwg file in AutoCAD 2013?

 

Thanks

18 REPLIES 18
Message 2 of 19

DocumentExtension.CloseAndDiscard
P.S.: Also read ObjectARX for AutoCAD 2013 Docs: Managed Class Reference -> Migration Guide->.NET Migration Guide

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 3 of 19
Hugh_Compton
in reply to: Hugh_Compton

 

Works great, thanks.

Message 4 of 19

more clearly, it's DocumentExtension.CloseAndDiscard(doc)

 


just in case anyone would expect it to be an extension method, like i did

Message 5 of 19
jeff
in reply to: matus.brlit

It is a extension method

 

public static void CloseAndDiscard(this Document doc)
{
    CloseInternal(doc, true, null);
}

 

You can also find your answers @ TheSwamp
Message 6 of 19
matus.brlit
in reply to: jeff

I checked it and you're right, but I am using VB.net. And there it isn't an extension method.

 

Taken from MSDN:

 

Notice that the extension method definition is marked with the extension attribute <Extension()>. Marking the module in which the method is defined is optional, but each extension method must be marked. System.Runtime.CompilerServices must be imported in order to access the extension attribute.

Extension methods can be declared only within modules.

 

 

Message 7 of 19
jeff
in reply to: matus.brlit

With C# you import the namespace and VB you import the module, but it still is a extension method.

You can also find your answers @ TheSwamp
Message 8 of 19
matus.brlit
in reply to: jeff

I am importing 

 

Imports Autodesk.AutoCAD.ApplicationServices.DocumentExtension

which is a class. I couldn't find the module I am supposed to import in VB. Do you know where I can find it?

Message 9 of 19

In AutoCAD 2013 class Autodesk.AutoCAD.ApplicationServices.DocumentExtension is in acmgd.dll

 

08-03-2013 11-08-47.png

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

Message 10 of 19

I know that, Alexander. I was asking about the module for VB.

Message 11 of 19
jeff
in reply to: matus.brlit

Not sure what your asking

 

Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.ApplicationServices.DocumentExtension

<Assembly: CommandClass(GetType(AutoCAD_VB_plug_in1.MyCommands))> 
Namespace AutoCAD_VB_plug_in1

    Public Class MyCommands


        <CommandMethod("MyCommand")> _
        Public Sub MyCommand()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            doc.CloseAndDiscard()

        End Sub


    End Class

End Namespace

 

You can also find your answers @ TheSwamp
Message 12 of 19

The doc you quote relate to defining/implementing extension methods in VB, not consumign them from VB.

 

There does seem to be a problem with consumig those methods as extension methods in VB.NET, and it may have something to do with the fact that both containing type and the methods themselves require the ExtensionAttribute.

 

Message 13 of 19


@matus.brlit wrote:

I know that, Alexander. I was asking about the module for VB.


 

There is no module to import.

 

You are looking at docs that relate to defining extension methods in VB.NET, not consuming extension methods from an assembly.

 

You should only have to import the namespace containing the type that exposes the extension methods, but as I mentioned in my other reply, there seems to be a problem there, as when I tried with the required assembly reference and namespace import, the VB code compiler couldn't find the extension method.

 

 

Message 14 of 19

@DiningPhilosopher: Exactly, that's what I am trying to say. It doesn't work as extension method for VB. I quoted the docs for defining the extension method, because I wanted to point out, that there might be a problem. If you reference the same class from VB and C# it's not compatible.

 

@Jeff: This is what I would expect, but it doesn't work for me.

Message 15 of 19
jeff
in reply to: matus.brlit

In the last example,

CloseAndDiscard does not show up in intellisense but it does build for me.

You can also find your answers @ TheSwamp
Message 16 of 19
matus.brlit
in reply to: jeff

@Jeff: Thanks, it's really just missing intellisense that confused me.

Message 17 of 19
jeff
in reply to: matus.brlit

In a VB project if I reference a fully managed assembly written in C# with extension methods all I have to do is import the namespace and shows up in intellisense and what not.

Don't know?

You can also find your answers @ TheSwamp
Message 18 of 19
matus.brlit
in reply to: jeff

Do you mean, that it usually works? Or that it works for you with this particular case too?

Message 19 of 19
jeff
in reply to: matus.brlit

Sorry,

I just was referring to a library of extension methods written in C# that I referenced into new VB project to test quickly.

You can also find your answers @ TheSwamp

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