.NET

Reply
Mentor
Hugh_Compton
Posts: 711
Registered: ‎04-21-2006
Message 1 of 19 (1,163 Views)
Accepted Solution

Document CloseAndDiscard In 2013

1163 Views, 18 Replies
04-25-2012 04:27 AM

 

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

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

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

 

In the last example,

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

Moderator
Alexander.Rivilis
Posts: 1,446
Registered: ‎04-09-2008
Message 2 of 19 (1,160 Views)

Re: Document CloseAndDiscard In 2013

04-25-2012 06:05 AM in reply to: Hugh_Compton
DocumentExtension.CloseAndDiscard
P.S.: Also read ObjectARX for AutoCAD 2013 Docs: Managed Class Reference -> Migration Guide->.NET Migration Guide

Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Mentor
Hugh_Compton
Posts: 711
Registered: ‎04-21-2006
Message 3 of 19 (1,152 Views)

Re: Document CloseAndDiscard In 2013

04-25-2012 06:41 AM in reply to: Hugh_Compton

 

Works great, thanks.

Mentor
matus.brlit
Posts: 246
Registered: ‎03-11-2008
Message 4 of 19 (838 Views)

Re: Document CloseAndDiscard In 2013

03-01-2013 06:16 AM in reply to: Alexander.Rivilis

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

 


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

Valued Mentor
jeff
Posts: 335
Registered: ‎05-12-2009
Message 5 of 19 (830 Views)

Re: Document CloseAndDiscard In 2013

03-01-2013 10:06 AM 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
Mentor
matus.brlit
Posts: 246
Registered: ‎03-11-2008
Message 6 of 19 (803 Views)

Re: Document CloseAndDiscard In 2013

03-03-2013 11:07 PM 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.

 

 

Valued Mentor
jeff
Posts: 335
Registered: ‎05-12-2009
Message 7 of 19 (788 Views)

Re: Document CloseAndDiscard In 2013

03-04-2013 05:49 AM 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
Mentor
matus.brlit
Posts: 246
Registered: ‎03-11-2008
Message 8 of 19 (757 Views)

Re: Document CloseAndDiscard In 2013

03-07-2013 10:26 PM 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?

Moderator
Alexander.Rivilis
Posts: 1,446
Registered: ‎04-09-2008
Message 9 of 19 (752 Views)

Re: Document CloseAndDiscard In 2013

03-08-2013 01:07 AM in reply to: matus.brlit

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

 

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


Пожалуйста не забывайте про Утвердить в качестве решения! Утвердить в качестве решения и Give Kudos!Баллы
Please remember to Accept Solution! Accept as Solution and Give Kudos!Kudos

Mentor
matus.brlit
Posts: 246
Registered: ‎03-11-2008
Message 10 of 19 (747 Views)

Re: Document CloseAndDiscard In 2013

03-08-2013 01:14 AM in reply to: Alexander.Rivilis

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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!