Author Topic: Check if Command is Running  (Read 4580 times)

0 Members and 1 Guest are viewing this topic.

cmwade77

  • Swamp Rat
  • Posts: 1443
Check if Command is Running
« on: February 09, 2011, 04:43:06 PM »
Ok, I have looked, but have not found the answer yet, I need to know three things:
1. How do I check if a command is already running?
2. If a command is already running, is it the array command?
3. How do I cancel it if it is?

I am creating a tool palette, so it is possible that a command is already running, but it is also possible that I will need to not cancel the command, but interact with this command while it is running, so I do need to know how to do both things separately.
« Last Edit: February 09, 2011, 04:48:02 PM by cmwade77 »

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: Check if Command is Running
« Reply #1 on: February 09, 2011, 04:54:08 PM »
As a starting point, take a look at CMDACTIVE.
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Check if Command is Running
« Reply #2 on: February 09, 2011, 04:58:40 PM »
Ok, that tells me if a command is running....now I need to know if it is the array command or not. And how to cancel the running command via LISP.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Check if Command is Running
« Reply #3 on: February 09, 2011, 05:01:09 PM »
If you redefine the ARRAY command, you can set a marker.
Vault Professional 2023     +     AEC Collection

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Check if Command is Running
« Reply #4 on: February 09, 2011, 05:01:30 PM »
Code: [Select]
(getvar 'CMDNAMES)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Check if Command is Running
« Reply #5 on: February 09, 2011, 05:10:38 PM »
That will do the trick for that....now for the life of me, I can't seem to figure out how to cancel an active command by using LISP.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Check if Command is Running
« Reply #6 on: February 09, 2011, 05:15:25 PM »
Code: [Select]
(command) ... (command)

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Check if Command is Running
« Reply #7 on: February 09, 2011, 05:34:37 PM »
Thank you Lee, I knew it had to be something simple like that.

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Check if Command is Running
« Reply #8 on: July 22, 2011, 11:57:57 AM »
Code: [Select]
(command) ... (command)
Ok, so I am trying to use this to cancel drawing a pline, but it doesn't seem to work, please see my code below:
Code: [Select]
  (setq pt1 (getpoint "\nSelect the first point: "))
  (cond
(pt1
  (vla-StartUndoMark *ACAD_DOC*)
  (command "._pline" pt1)
  (setq ct 0)
  (princ "\n")
  (while pt1
(setq pt1 (getpoint pt1 "Select the next point (press enter to close):"))
(cond
  (pt1
(command pt1)
(setq ct (+ ct1))
  )
  (T
(cond
  ((= ct 0)
(princ "\nCommand Canceled.\n")
(command)(command)
  )
  ((= ct 1)
(princ "\nObject invalid.")
(command)(command)
(vla-EndUndoMark *ACAD_DOC*)
(command "._undo")
  )
  (T
(command "_C")
  )
)
  )
)
  )
Any ideas?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Check if Command is Running
« Reply #9 on: July 22, 2011, 12:25:07 PM »
Why not:

Code: [Select]
(command "_.pline")
(while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause))

chlh_jd

  • Guest
Re: Check if Command is Running
« Reply #10 on: July 22, 2011, 01:15:55 PM »
Hi all , just for fun
Code: [Select]
(defun c:tar (/ pt1 pt2 len str en) 
  (and
    (setq pt1 (getpoint "first point: "))
    (setq pt2 (getpoint pt1 ">Second point: "))
    (progn
      (setq len (distance pt1 pt2))
      (command "pline" pt1 "w" 0 (* 1.8 len) pt2)
      (command "w" (* 0.4 len) (* 1.3 len) "a")
      (command pause)
      (princ "\nNextpoint<Print Enter for end>: ")
    )
  )   
  (princ)
)
and following ...
Code: [Select]
(defun c:tar (/ pt1 pt2 len str en) 
  (and
    (setq pt1 (getpoint "first point: "))
    (setq pt2 (getpoint pt1 ">Second point: "))
    (progn
      (setq len (distance pt1 pt2))
      (command "pline" pt1 "w" 0 (* 1.8 len) pt2)
      (command "w" (* 0.4 len) (* 1.3 len) "a")
      (command pause)
      (princ "\nendpoint: ")
    )
  ) 
 (command "") 
  (princ)
)

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Check if Command is Running
« Reply #11 on: July 22, 2011, 01:57:27 PM »
Why not:

Code: [Select]
(command "_.pline")
(while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause))
Grr...I hate when I over think the problem, that helps a lot, thank you.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Check if Command is Running
« Reply #12 on: July 22, 2011, 02:05:32 PM »
Grr...I hate when I over think the problem, that helps a lot, thank you.

We've all been there  :wink:  You're welcome.

efernal

  • Bull Frog
  • Posts: 206
Re: Check if Command is Running
« Reply #13 on: July 22, 2011, 02:19:01 PM »
Code: [Select]
(DEFUN c:test (/ cn p1 p2)
  (IF (SETQ p1 (GETPOINT "\n-> Initial point : "))
    (IF (SETQ p2 (GETPOINT p1 "\n-> Second point : "))
      (PROGN (SETQ cn 2)
             (COMMAND "_.PLINE")
             (COMMAND "_NON" p1 "_NON" p2)
             (WHILE (SETQ p1 (GETPOINT p2 "\r-> Another point or ENTER for finish : "))
               (COMMAND "_NON" p1)
               (SETQ p2 p1
                     cn (1+ cn)
               )
             )
             (IF (> cn 2)
               (COMMAND "_CLOSE")
               (COMMAND nil)
             )
      )
      (PRINC "\n-> No second point...")
    )
    (PRINC "\n-> First point not given...")
  )
  (PRINC)
)
e.fernal

cmwade77

  • Swamp Rat
  • Posts: 1443
Re: Check if Command is Running
« Reply #14 on: July 22, 2011, 03:01:57 PM »
Why not:

Code: [Select]
(command "_.pline")
(while (= 1 (logand 1 (getvar 'CMDACTIVE))) (command pause))
This is working great, but I need to get the last point picked, any ideas?