Author Topic: Open drawing for a limited time  (Read 13413 times)

0 Members and 1 Guest are viewing this topic.

nivuahc

  • Guest
Re: Open drawing for a limited time
« Reply #15 on: September 13, 2006, 12:29:24 PM »
I, for the life of me, can not figure out why you'd be using a timer if you are going to go in and edit the drawing anyway.  Using a timer just limits the amount of time you can do something, plus unless you have the program set up to resume the timer after your done editing I don't see how the program can be running the timer and you editing the drawing at the same time.

Now if you are having the program do everything for you, once again you don't need a timer as you can have it fire off the rest of the code once you've done your edits.

Can you explain what you are trying to accomplish w/ the program?

Actually, he's trying to accomplish something for me. I'll attempt to explain it here, hopefully in better detail than I did in my previous post in the Lisp forum.

A friend of mine is an artist. He does a lot of 3D work. He's your typical starving artist and he has a gallery show coming up soon with some of his sculptures and various other art work.

He wanted to setup a touch screen display with some of his 3D models on view for gallery patrons to interact with. He wants to have a list of drawings created, the first one opened, the 3DOrbit command invoked, then stopped after a period of 5 minutes or so, then the next drawing opened, etc.

The only interface available to the patrons will be the touch screen. They cannot hit the [ESC] key or right-click to cancel the 3DOrbit command.

I've got this (mostly) figured out with Lisp already, it's just the cancelling of the 3DOrbit command that's causing the hangup.

3DOrbit isn't an editing command (per se) as much as it's a viewing command. AutoCAD will see it as an edit because the view has changed... but it won't be saved and the patrons won't actually be editing anything.


T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing for a limited time
« Reply #16 on: September 13, 2006, 12:34:57 PM »
I still believe that you won't be able to do it with just lisp, as it won't be able to check anything while the 3dorbit command is in use.  That is why I think you need a timer event, but I can't figure out how to cancel the command when the time ends.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

nivuahc

  • Guest
Re: Open drawing for a limited time
« Reply #17 on: September 13, 2006, 12:42:38 PM »
I may just bang something out with AutoIt for the time being. I'm still curious to figure out a (native to AutoCAD) solution for this though. :)

Greg B

  • Seagull
  • Posts: 12417
  • Tell me a Joke!
Re: Open drawing for a limited time
« Reply #18 on: September 13, 2006, 12:48:06 PM »
I want to apologize to both Tim and Chuck for my post.  I should have read Chucks other post cause I know it was mentioned.  Thanks to both of you for clearing it up for me.

Question....Can't you set up the timer to halt and resume on mouse movement?  Then set up a timer for when the mouse is moving and when it is not?  Have those to work together to get your 5 minutes or whatever you need for metric time? ^-^

nivuahc

  • Guest
Re: Open drawing for a limited time
« Reply #19 on: September 13, 2006, 12:56:00 PM »
It's not a timer issue, from what I can see. It's a "cancel the 3DOrbit command" issue (again, from what I can see).

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing for a limited time
« Reply #20 on: September 13, 2006, 01:13:30 PM »
I want to apologize to both Tim and Chuck for my post.  I should have read Chucks other post cause I know it was mentioned.  Thanks to both of you for clearing it up for me.

Question....Can't you set up the timer to halt and resume on mouse movement?  Then set up a timer for when the mouse is moving and when it is not?  Have those to work together to get your 5 minutes or whatever you need for metric time? ^-^
No problem Greg, and I have to agree with Chuck.
It's not a timer issue, from what I can see. It's a "cancel the 3DOrbit command" issue (again, from what I can see).
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Greg B

  • Seagull
  • Posts: 12417
  • Tell me a Joke!
Re: Open drawing for a limited time
« Reply #21 on: September 13, 2006, 01:15:47 PM »
Why should this be a problem if the timer is running down.  Once it hits it's mark it should cancel the orbit command and close the drawing and open the new one.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing for a limited time
« Reply #22 on: September 13, 2006, 01:33:14 PM »
Why should this be a problem if the timer is running down.  Once it hits it's mark it should cancel the orbit command and close the drawing and open the new one.
That is the problem.  I can't seem to figure out how to cancel the command.  It looks like I need to use the ObjectARX code for 'PostCommand' but I don't know how to impliment it in C#.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Open drawing for a limited time
« Reply #23 on: September 13, 2006, 02:37:58 PM »
Have you tried with: sendStringToExecute()  ?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing for a limited time
« Reply #24 on: September 13, 2006, 02:48:03 PM »
Have you tried with: sendStringToExecute()  ?
That is how I call the 3dorbit command.  I found a way to get it to work.  I have to import something, and then I can call 'acedPostCommand' and it will cancel the command.  Found code by Tony T to do it.
Code: [Select]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedPostCommand@@YAHPBD@Z")]
extern static public int acedPostCommand(string cmd);

Then I call it like

acedPostCommand ("CancelCMD");
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing for a limited time
« Reply #25 on: September 13, 2006, 03:10:00 PM »
New problem.  It will cancel the command, and it reconizes the variable 'DocMan', but it won't do anything with it.  So it will stop the command, but it won't close the current drawing.  Here is the code.  Maybe someone can see something that I can't.  Problem portion is the function 'OpenNext'.  I added a message box there, and it will fire it after the command cancels.  I tried to get the current drawing the long way, and that still didn't let me get a reference to it to close it.
Long way:
Code: [Select]
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

Thanks!
Code: [Select]
using System;
using System.Diagnostics;
using System.Timers;
using System.Windows.Forms;
using System.Runtime.InteropServices;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;

using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;

[assembly: CommandClass(typeof(Test.TimeLimitOpenv02))]

namespace Test
{
    /// <summary>
    /// Description of TimeLimitOpen.
    /// </summary>
    public class TimeLimitOpenv02
    {
   
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedPostCommand@@YAHPBD@Z")]
extern static public int acedPostCommand(string cmd);
        public string[] DwgList;
        DocumentCollection DocMan = AcadApp.DocumentManager;
        System.Timers.Timer CountDownTimer;
        int cnt = 1;
        //- Constructor: sets up var's etc for this class before use.
        public TimeLimitOpenv02()
        {
            CountDownTimer = new System.Timers.Timer();
            CountDownTimer.Elapsed += new ElapsedEventHandler(OpenNext);
            CountDownTimer.Interval = 10000;
        }
 
        ~TimeLimitOpenv02() // <-- Destructor, do clean up here.
        {
            CountDownTimer.Elapsed -= new ElapsedEventHandler(OpenNext);
        }
        public void OpenNext(object sender, ElapsedEventArgs e)
        {
        acedPostCommand ("CancelCmd");
            DocMan.MdiActiveDocument.CloseAndDiscard();
            Document NewDoc = DocMan.Open(DwgList[cnt], true);
            DocMan.MdiActiveDocument = NewDoc;
            ++cnt;
            if (cnt > DwgList.Length)
            {
                CountDownTimer.Enabled = false;
                CountDownTimer.Dispose();
            }
            NewDoc.SendStringToExecute ("_.3dorbit\n", false, false, true);
       
        }

        [CommandMethod("TestTimer", CommandFlags.Session)]
        public void Main()
        {
            Autodesk.AutoCAD.Windows.OpenFileDialog Dia =
                new Autodesk.AutoCAD.Windows.OpenFileDialog(
                "Select drawings to update Cloud layer", "", "dwg", "",
                Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple);
            Dia.ShowDialog();
            string[] DwgList = Dia.GetFilenames();
            if (DwgList.Length > 1)
            {
                Document NewDoc = DocMan.Open(DwgList[0], true);
            CountDownTimer.Enabled = true;
                if (NewDoc != DocMan.MdiActiveDocument)
                {
                    DocMan.MdiActiveDocument = NewDoc;
                }
            NewDoc.SendStringToExecute ("_.3dorbit\n", false, false, true);
            }
        }
    }
}
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Open drawing for a limited time
« Reply #26 on: September 13, 2006, 03:13:26 PM »
Have you tried with: sendStringToExecute()  ?
That is how I call the 3dorbit command.  I found a way to get it to work.  I have to import something, and then I can call 'acedPostCommand' and it will cancel the command.  Found code by Tony T to do it.
Code: [Select]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedPostCommand@@YAHPBD@Z")]
extern static public int acedPostCommand(string cmd);

Then I call it like

acedPostCommand ("CancelCMD");

OK...

Here is the arx code, just in case:

Code: [Select]
acDocManager->sendStringToExecute(acDocManager->mdiActiveDocument(), _T("\3\3"), false, false, false);

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing for a limited time
« Reply #27 on: September 13, 2006, 03:16:13 PM »
Have you tried with: sendStringToExecute()  ?
That is how I call the 3dorbit command.  I found a way to get it to work.  I have to import something, and then I can call 'acedPostCommand' and it will cancel the command.  Found code by Tony T to do it.
Code: [Select]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint = "?acedPostCommand@@YAHPBD@Z")]
extern static public int acedPostCommand(string cmd);

Then I call it like

acedPostCommand ("CancelCMD");

OK...

Here is the arx code, just in case:

Code: [Select]
acDocManager->sendStringToExecute(acDocManager->mdiActiveDocument(), _T("\3\3"), false, false, false);
Thanks Luis.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Greg B

  • Seagull
  • Posts: 12417
  • Tell me a Joke!
Re: Open drawing for a limited time
« Reply #28 on: September 13, 2006, 03:28:55 PM »
When it tries to close it does it hang up because it's confiming a change to the drawing and you don't have anything saying no to that?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Open drawing for a limited time
« Reply #29 on: September 13, 2006, 03:36:28 PM »
When it tries to close it does it hang up because it's confiming a change to the drawing and you don't have anything saying no to that?
It shouldn't because I use the 'CloseAndDiscard' method.  It doesn't really hang, as you can continue to do other things, but it won't proceed with the code.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.