strange behavior from lisp.

strange behavior from lisp.

Anonymous
Not applicable
1,034 Views
6 Replies
Message 1 of 7

strange behavior from lisp.

Anonymous
Not applicable

So I wrote a lisp routine which turns layers on and off and brings them to the foreground in order, it's a one press button which sets the draworder for our xrefs. The lisp routine is fine, I think, it is as follows - 

 

(defun C:FY (/ BT TP)     ;DEFINES FY TO RUN COMMAND SETS BT AND TP AS LOCAL VARIABLES
 (setq bt (getvar "extmin")    ;SET BT UPPER RIGHT CORNER
       tp (getvar "extmax")    ;SET TP LOWER RIGHT CORNER
 )        ;_  end setq    
 (COMMAND "-LAYER" "OFF" "*" "Y" "")  ;TURNS ALL LAYERS OFF.
 (COMMAND "-LAYER" "ON" "S-WALLOV" "")   ;TURNS ON S-WALLOV
 (COMMAND "_DRAWORDER" "W" BT TP "" "F" "") ;SETS THE DRAW ORDER FOR S-WALLOV ON TOP.
 (COMMAND "-LAYER" "OFF" "*" "Y" "")  ;TURNS ALL LAYERS OFF.
 (COMMAND "-LAYER" "ON" "S-WALLUN" "")   ;TURNS ON S-WALLUN
 (COMMAND "_DRAWORDER" "W" BT TP "" "F" "") ;SETS THE DRAW ORDER FOR S-WALLUN ON TOP.
 (COMMAND "-LAYER" "ON" "*" "")   ;TURNS ALL LAYERS ON.
 (COMMAND "-LAYER" "OFF" "*" "Y" "")  ;TURNS ALL LAYERS OFF.
 (COMMAND "-LAYER" "ON" "S-MARKING" "")   ;TURNS ON S-MARKING
 (COMMAND "_DRAWORDER" "W" BT TP "" "F" "") ;SETS THE DRAW ORDER FOR S-MARKING ON TOP.  
 (COMMAND "-LAYER" "OFF" "*" "Y" "")  ;TURNS ALL LAYERS OFF.
 (COMMAND "-LAYER" "ON" "*HATCH*" "")   ;TURNS ON HATCH
 (COMMAND "_DRAWORDER" "W" BT TP "" "B" "") ;SETS THE DRAW ORDER FOR ALL HATCH ON BACK.
 (COMMAND "-LAYER" "ON" "*" "")   ;TURNS ALL LAYERS ON.
 (COMMAND "_REGENALL")    ;REGENS VIEW
 (PRINC)      ;ENDS
)
 

could probably be better but its the first routine ive written. Anyway the problem comes when I use my macro, I have this lisp in my startup suite so it loads on autocad startup, but when I press my button macro it seems to add in a right click on every line of the lisp routine, but if I type fy in the command line it runs perfectly. The problem occurs when I use the macro to run the lisp routine.

 

The macro is simply -          

^C^C(C:FY)

 

any suggestions? 
                                 

 

 

0 Likes
1,035 Views
6 Replies
Replies (6)
Message 2 of 7

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... when I press my button macro it seems to add in a right click on every line of the lisp routine, but if I type fy in the command line it runs perfectly. .... 


I don't see anything obvious.  What's the indication that it's "add[ing] in a right click on every line"?  Can you post a command-line history when you run it from the macro?

 

[There's a way to find everything on a given Layer without turning all others off, which could shorten this considerably, but we can get into that later....]

Kent Cooper, AIA
0 Likes
Message 3 of 7

paullimapa
Mentor
Mentor

Would there be a difference if you change the macro to:

^C^CFY;

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 7

cadffm
Consultant
Consultant
Please tell me in which version the draworder command an extra enter after your FRONT input, thx

"_DRAWORDER" "W" BT TP "" "F" "" < this "" last enter.

Can anybody give me the textscr log sequence/part

Sebastian

0 Likes
Message 5 of 7

Kent1Cooper
Consultant
Consultant

@cadffm wrote:
.... an extra enter after your FRONT input....
...

That's the should-have-been-obvious-to-me answer, I'll bet!  [But I haven't tested it.]

Kent Cooper, AIA
0 Likes
Message 6 of 7

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

.... There's a way to find everything on a given Layer without turning all others off, which could shorten this considerably....

That's by way of (ssget) searching the entire drawing, filtering by Layer.  Not only does it avoid the Layer isolations, but there's no need for Zooming, or any variables, and you can do as many commands in one (command) function as you like.  Try this [untested]:

 

(defun C:FY ()
  (command
    "_.layer" "_on" "*" "" ; just in case
    "_.DRAWORDER" (ssget "_X" (list '(8 . "S-WALLOV") (cons 410 (getvar 'ctab)))) "" "F"
    "_.DRAWORDER" (ssget "_X" (list '(8 . "S-WALLUN") (cons 410 (getvar 'ctab)))) "" "F"
    "_.DRAWORDER" (ssget "_X" (list '(8 . "S-MARKING") (cons 410 (getvar 'ctab)))) "" "F"
    "_.DRAWORDER" (ssget "_X" (list '(8 . "*HATCH*") (cons 410 (getvar 'ctab)))) "" "B"
    "_.REGENALL"
  ); command
  (princ)
); defun

It only finds things on the given Layer in the current space, in case you might have them in different Layouts.  That element of the (ssget) filter list could probably be eliminated, since the DRAWORDER command will only "see" things in the current space, anyway.  That should make it reducible to:

 

(defun C:FY ()
  (command
    "_.layer" "_on" "*" "" ; just in case
    "_.DRAWORDER" (ssget "_X" '((8 . "S-WALLOV"))) "" "F"
    "_.DRAWORDER" (ssget "_X" '((8 . "S-WALLUN"))) "" "F"
    "_.DRAWORDER" (ssget "_X" '((8 . "S-MARKING"))) "" "F"
    "_.DRAWORDER" (ssget "_X" '((8 . "*HATCH*"))) "" "B"
    "_.REGENALL"
  ); command
  (princ)
); defun
Kent Cooper, AIA
0 Likes
Message 7 of 7

Anonymous
Not applicable

@Kent1Cooper wrote:

@Anonymous wrote:

... when I press my button macro it seems to add in a right click on every line of the lisp routine, but if I type fy in the command line it runs perfectly. .... 


I don't see anything obvious.  What's the indication that it's "add[ing] in a right click on every line"?  Can you post a command-line history when you run it from the macro?

 

[There's a way to find everything on a given Layer without turning all others off, which could shorten this considerably, but we can get into that later....]


I should have said it's not right click it's enter, and I can see it happening when I do a line command before pressing the macro, the macro will cancel and attempt to draw a line, but will run fine still if I type it form command line. If I type CUI before running the macro it will pop up the window once per line but again no problem when typing the command I set. I will try get some logs when I am back at work. 

 

0 Likes