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
Solved! Go to Solution.
Solved by Alexander.Rivilis. Go to Solution.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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
more clearly, it's DocumentExtension.CloseAndDiscard(doc)
just in case anyone would expect it to be an extension method, like i did
It is a extension method
public static void CloseAndDiscard(this Document doc) { CloseInternal(doc, true, null); }
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.
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?
In AutoCAD 2013 class Autodesk.AutoCAD.ApplicationServices.DocumentExtension is in acmgd.dll
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | 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
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
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.
@Anonymous 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.
@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.
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?
Sorry,
I just was referring to a library of extension methods written in C# that I referenced into new VB project to test quickly.
Can't find what you're looking for? Ask the community or share your knowledge.