.NET

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

Document CloseAndDiscard In 2013

1116 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,417
Registered: ‎04-09-2008
Message 2 of 19 (1,113 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: 709
Registered: ‎04-21-2006
Message 3 of 19 (1,105 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 (791 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: 330
Registered: ‎05-12-2009
Message 5 of 19 (783 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 (756 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: 330
Registered: ‎05-12-2009
Message 7 of 19 (741 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 (710 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,417
Registered: ‎04-09-2008
Message 9 of 19 (705 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 (700 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.

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.