.NET

Reply
Active Contributor
huaxiamengqing
Posts: 35
Registered: ‎05-23-2012
Message 1 of 6 (238 Views)

About Document.CloseAndDiscard()

238 Views, 5 Replies
08-10-2012 07:02 AM

Hi,Everyone. The other day,I come into a trouble about Document.closeAnddiscard() . I used it to shut the active document, But,it always prompt that CAD was busy. Are you clear about what i say. eager for some help,Thank you all.

*Expert Elite*
norman.yuan
Posts: 1,049
Registered: ‎04-27-2009
Message 2 of 6 (233 Views)

Re: About Document.CloseAndDiscard()

08-10-2012 07:59 AM in reply to: huaxiamengqing

You need to set CommandFlags.Session in your command method where your code gets started from.

Active Contributor
huaxiamengqing
Posts: 35
Registered: ‎05-23-2012
Message 3 of 6 (206 Views)

Re: About Document.CloseAndDiscard()

08-11-2012 10:16 PM in reply to: norman.yuan
Can you show me some simple code?
Valued Mentor
KerryBrown
Posts: 276
Registered: ‎11-29-2008
Message 4 of 6 (200 Views)

Re: About Document.CloseAndDiscard()

08-12-2012 01:13 AM in reply to: huaxiamengqing

Perhaps

http://lmgtfy.com/?q=CommandFlags.Session

//-------------------------------------------------------

Everything will work just as you expect it to, unless your expectations are incorrect.

class keyThumper<T> : Lazy<T>;      another  Swamper

Active Contributor
huaxiamengqing
Posts: 35
Registered: ‎05-23-2012
Message 5 of 6 (176 Views)

Re: About Document.CloseAndDiscard()

08-12-2012 09:35 PM in reply to: KerryBrown

Sorry,It's hard for me to Search code from the English pages. In our country few people use CADnet so the information is few with Chinese language. In a word, My english is not very good. Thank you for your help.

*Expert Elite*
norman.yuan
Posts: 1,049
Registered: ‎04-27-2009
Message 6 of 6 (162 Views)

Re: About Document.CloseAndDiscard()

08-13-2012 06:56 AM in reply to: huaxiamengqing

Something like this:

 

public class MyClass

{

    [CommandMethod("MyOpenClose", CommandFlags.Session]

    public static void OpenFileForSomething()

    {

        DocumentCollection docMng=Application.DocumentManager;

        Document dwg=docMng.Open("C:\MyFolder\MyDrawing.dwg", true);

        DoSomethingWithTheDrawing(dwg);

        dwg.CloseAndDiscard();

    }

}

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!