Autolisp to specify layer to draw revcloud on

Autolisp to specify layer to draw revcloud on

Anonymous
Not applicable
1,366 Views
8 Replies
Message 1 of 9

Autolisp to specify layer to draw revcloud on

Anonymous
Not applicable

I tried writing a routine that will specify the layer to draw the revcloud on and then return to the previous layer.

The problem I'm having is that when the routine ends the current layer doesn't revert back to the previous layer.

What am I missing?

 

Larry

0 Likes
1,367 Views
8 Replies
Replies (8)
Message 2 of 9

ВeekeeCZ
Consultant
Consultant

Post the code, we'll tell you.

BTW the ToolPalette does not fit into your workflow?

0 Likes
Message 3 of 9

Anonymous
Not applicable

sorry, I planned on posting and forgot...

 

(DEFUN C:BDREVCLOUD()
(SETVAR "CMDECHO" 0)
(SETQ OLDLAY(GETVAR "CLAYER"))
(SETQ REVLYR "M-REVCLOUD")
(SETQ TS(TBLSEARCH "LAYER" REVLYR))
(IF(NULL TS)
(COMMAND "LAYER" "M" REVLYR "C" "White" "" "L" "Continuous" "" "LW" "Default" "" ""))
(SETVAR "CLAYER" REVLYR)
(COMMAND "_.REVCLOUD")
(SETVAR "CLAYER" OLDLAY)
(PRINC))

0 Likes
Message 4 of 9

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

...
(COMMAND "_.REVCLOUD")

(while (> (getvar 'cmdactive) 0) (command pause)); keep waiting for User input until command is finished
(SETVAR "CLAYER" OLDLAY)
(PRINC))


 

Kent Cooper, AIA
0 Likes
Message 5 of 9

ВeekeeCZ
Consultant
Consultant

Your program returned the previous layer back to soon, even BEFORE a revcloud was created. Kent revealed you the solution.

 

Other issue is that your did not get the ECHO back on.

No error hander... if you break REVCLOUD command by ESC, nothing gets back.

Localize your variable, you can prevent some errors.

 

See the spoiler, your code could be much simpler - if you realize what -LAYER MAKE does.

 

Spoiler
(defun C:BDREVCLOUD ( / *error* oldlay oldecho)

  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled, quit / exit abort, console break"))
      (princ (strcat "\nError: " errmsg)))
  (setvar 'clayer oldlay) ; turn sysvar back in case of error or break by ESC.
  (setvar 'cmdecho oldecho)
  (princ)
  )
  
  (setq oldecho (getvar 'cmdecho) 
	oldlay (getvar 'clayer))

  (setvar 'cmdecho 0)

  (command "_.LAYER" "_M" "M-REVCLOUD" "") ; create the layer if needed, makes it current; white, contunuous... all is default, not need to specify
  (setvar 'cmdecho 1)
  (command "_.REVCLOUD")
  (while (> (getvar 'cmdactive) 0) (command PAUSE))

  (setvar 'clayer oldlay)
  (setvar 'cmdecho oldecho) ; turn the echo back on!
  (princ)
)

 

Edit: Dunno how to solve your missing options. But if you use TollPalette - there is no such an issue.

Edit2: The issue is because of the ECHO is turned off. We need to set it back at right time. I fixed the spoiler code.

0 Likes
Message 6 of 9

Anonymous
Not applicable

I had tried just (command pause) but obviously that didn't do the trick

What you suggested worked as expected, but I lose the line of options in the command

 

typing _REVCLOUD you get two lines of text on the text screen:

     Minimum arc length: 8"   Maximum arc length: 8"   Style: Normal   Type: Rectangular
     Specify first corner point or [Arc length/Object/Rectangular/Polygonal/Freehand/Style/Modify] <Object>:

 

but once I added (while (> (getvar 'cmdactive) 0) (command pause)) this is all I get:

     Minimum arc length: 8"   Maximum arc length: 8"   Style: Normal   Type: Freehand

 

The line of options is missing

 

any idea?

0 Likes
Message 7 of 9

Anonymous
Not applicable

turning CMDECHO on restored the missing line of options but the options are from an older version of REVCLOUD

I get these options now:

     Specify start point or [Arc length/Object/Style] <Object>:

instead of these:

     Specify first corner point or [Arc length/Object/Rectangular/Polygonal/Freehand/Style/Modify] <Object>:

 

0 Likes
Message 8 of 9

ВeekeeCZ
Consultant
Consultant

I have 2015 so can't test it.

 

Try to add this line

(initcommandversion)

before (command "revcould")

 

Spoiler
(defun C:BDREVCLOUD ( / *error* oldlay oldecho)

  (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled, quit / exit abort, console break"))
      (princ (strcat "\nError: " errmsg)))
  (setvar 'clayer oldlay) ; turn sysvar back in case of error or break by ESC.
  (setvar 'cmdecho oldecho)
  (princ)
  )
  
  (setq oldecho (getvar 'cmdecho) 
	oldlay (getvar 'clayer))

  (setvar 'cmdecho 0)

  (command "_.LAYER" "_M" "M-REVCLOUD" "") ; create the layer if needed, makes it current; white, contunuous... all is default, not need to specify
  (setvar 'cmdecho 1)
  (initcommandversion)
  (command "_.REVCLOUD")
  (while (> (getvar 'cmdactive) 0) (command PAUSE))

  (setvar 'clayer oldlay)
  (setvar 'cmdecho oldecho) ; turn the echo back on!
  (princ)
)

 

 

0 Likes
Message 9 of 9

Anonymous
Not applicable

That was it. Works perfectly now

Thanks very much for the help

 

Larry

0 Likes