Author Topic: Completely clear all running commands  (Read 1540 times)

0 Members and 1 Guest are viewing this topic.

hmspe

  • Bull Frog
  • Posts: 362
Completely clear all running commands
« on: March 15, 2022, 04:15:23 PM »
I'm looking for a way to completely clear the LISP engine state so that there is no active LASTPOINT or other carryover from the last command run.  The intent is to have the LISP engine in the same state as it would be in a fresh instance which had had no commands run.

I'm mostly having a problem with the Move command, which I call from a toolbar using the macro   ^C^C^C_MOVE  .  If there was a previous command run most of the time the first attempt to move entities has the entities relocate to a seemingly arbitrary location far away.  After the first attempt the MOVE command works properly.  I'm running latest Bricscad.  I suspect this has to do with Displacement being the default at the "Enter base point [Displacement]" prompt.  I've tried wrapping the move command in LISP so that (COMMAND) is run several times before move is called.  That doesn't help. 

Thanks in advance for any suggestions.
"Science is the belief in the ignorance of experts." - Richard Feynman

BIGAL

  • Swamp Rat
  • Posts: 1433
  • 40 + years of using Autocad
Re: Completely clear all running commands
« Reply #1 on: March 15, 2022, 08:26:56 PM »
I use Bricscad and no problems but V20 looking at getting v22. In a lisp just sequence, select objects, pt1, pt2.
A man who never made a mistake never made anything

d2010

  • Bull Frog
  • Posts: 326
Re: Completely clear all running commands
« Reply #2 on: March 17, 2022, 01:45:49 PM »
Please you  test two commands, with Osnap=off and Osnap=on
a)(defun dfn_cmd_cancel( / rr cx dx ch) 
b)(defun dfn_cmd_canceld( / $rr cx dx ch) 
---
Code: [Select]
(defun dfn_cmd_canceld( / $rr cx dx ch) 
 (setq;|a000|;
ch (quote INT)
cx (jc_cws12 51 9)
dx (getvar cx)
dx (if (/= (type dx) ch) 0 (boole 1  dx 1))) (progn (while (>  dx 0) (setq;|a000|;
dx (getvar cx)
dx (boole 1  dx 1)) (setq;|a17361304|;
$rr (command "")))) (setq;|a13625|;
$rr (getvar (jc_cws12 60 8))) (terpri)
$rr)

JohnK

  • Administrator
  • Seagull
  • Posts: 10659
Re: Completely clear all running commands
« Reply #3 on: March 17, 2022, 02:30:07 PM »
I'm sorry but that code does not make any sense.

This should cancel any active command.

Code - Auto/Visual Lisp: [Select]
  1. (defun cmd_cancel () (command) (command) (princ))
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

baitang36

  • Bull Frog
  • Posts: 213
Re: Completely clear all running commands
« Reply #4 on: March 17, 2022, 08:13:57 PM »
I'm looking for a way to completely clear the LISP engine state so that there is no active LASTPOINT or other carryover from the last command run.  The intent is to have the LISP engine in the same state as it would be in a fresh instance which had had no commands run.

I'm mostly having a problem with the Move command, which I call from a toolbar using the macro   ^C^C^C_MOVE  .  If there was a previous command run most of the time the first attempt to move entities has the entities relocate to a seemingly arbitrary location far away.  After the first attempt the MOVE command works properly.  I'm running latest Bricscad.  I suspect this has to do with Displacement being the default at the "Enter base point [Displacement]" prompt.  I've tried wrapping the move command in LISP so that (COMMAND) is run several times before move is called.  That doesn't help. 

Thanks in advance for any suggestions.
try this inip.fas
(load "d:/inip.fas")


hmspe

  • Bull Frog
  • Posts: 362
Re: Completely clear all running commands
« Reply #5 on: April 15, 2022, 12:56:10 PM »
Thanks for the replies.

@John - That's one of the first things I tried.  The ^C^C^C in the macro should do the same thing, but I also tried calling lisp functions that ran either
Code - Auto/Visual Lisp: [Select]
  1.   (while (< 0 (getvar "cmdactive")) (command))
  2.  

or that called
Code - Auto/Visual Lisp: [Select]
several times before calling the MOVE command.  Neither fixed the problem.  This seems to be associated with the
Code - Auto/Visual Lisp: [Select]
  1. Enter base point [Displacement] <Displacement>:
prompt that comes right after selecting entities to move.  Could be that my muscle memory is slipping, or it could be that there's key bounce or something in Bricscad that gets out of sync.  I'll try coding around the default.

@batang36 - Thanks.
"Science is the belief in the ignorance of experts." - Richard Feynman

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2149
  • class keyThumper<T>:ILazy<T>
Re: Completely clear all running commands
« Reply #6 on: April 15, 2022, 06:22:17 PM »
I'm looking for a way to completely clear the LISP engine state so that there is no active LASTPOINT or other carryover from the last command run.  The intent is to have the LISP engine in the same state as it would be in a fresh instance which had had no commands run.

I'm mostly having a problem with the Move command, which I call from a toolbar using the macro   ^C^C^C_MOVE  .  If there was a previous command run most of the time the first attempt to move entities has the entities relocate to a seemingly arbitrary location far away.  After the first attempt the MOVE command works properly.  I'm running latest Bricscad.  I suspect this has to do with Displacement being the default at the "Enter base point [Displacement]" prompt.  I've tried wrapping the move command in LISP so that (COMMAND) is run several times before move is called.  That doesn't help. 

Thanks in advance for any suggestions.
try this inip.fas
(load "d:/inip.fas")


Hi baitang36
Could you please post your solution in it's .lsp source , not as .fas
Regards,
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Completely clear all running commands
« Reply #7 on: April 17, 2022, 02:42:43 AM »
Try using:
Code: [Select]
(command nil)

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8789
  • AKA Daniel
Re: Completely clear all running commands
« Reply #8 on: April 17, 2022, 04:01:25 AM »
LASTPOINT is a system variable, it’s not stored in the lisp engine, but globally for all languages … right?
maybe extend your macro to reset it before calling move?

 
« Last Edit: April 17, 2022, 04:05:41 AM by It's Alive! »

baitang36

  • Bull Frog
  • Posts: 213
Re: Completely clear all running commands
« Reply #9 on: April 17, 2022, 07:11:07 AM »
try this inip.fas
(load "d:/inip.fas")

Hi baitang36
Could you please post your solution in it's .lsp source , not as .fas
Regards,
source is simple
(init:AUTOLISP-package)
But you can't run it. Because this function is a reserved function that is not written to the public document. It can only be used in FAS, not in LSP.
This function can restore all system functions to the original state. For example, if you redefine a system function, such as print, your definition will be invalidated after executing this function
« Last Edit: April 17, 2022, 07:19:17 AM by baitang36 »