Tool Pallette command not adding object to Layer defined in tool properties

Tool Pallette command not adding object to Layer defined in tool properties

jquade
Participant Participant
726 Views
8 Replies
Message 1 of 9

Tool Pallette command not adding object to Layer defined in tool properties

jquade
Participant
Participant

I'm editing a Tool Palette command for revision clouds. I started with dragging the Rectangular Revision Cloud command from the CUI to the tool palette. I set the tool properties Layer to "Revisions".

 

The command string is: ^C^C_^Rrevcloud _R 

 

Users requested the Arc Length be set to 0.2. I thought this would be easy, but it hasn't been. I'm setting the arc length to 0.2 x dimscale. I tried many different scenarios to get something that works as shown below.

 

Revised the command string to: ^C^C^R(setq REVARC (getvar "DIMSCALE"));revcloud;_A;(* 0.2 REVARC);_R

 

But now the object is not added to the layer "Revisions" anymore. Also, what does the ^R in the command string do?

 

Regards,

Jack

 

AutoCAD 2023

Windows 10

0 Likes
Accepted solutions (1)
727 Views
8 Replies
Replies (8)
Message 2 of 9

scot-65
Advisor
Advisor
Try this:
^C^C_layer;t;Revisions;m;Revisions;;_revcloud;_Arc;(* (getvar 'dimscale) 0.2);_R;\\

Semicolons are [Enter], so are spaces " ". Use semicolons when possible, especially at the end of the string.
Backslash is pause for user specified point.
Having a LISP expression in the command string may not make the General section behave as expected (not verified).
If you use the on/off method for layer display, modify the line above accordingly.

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

Message 3 of 9

Rick_Tolleshaug_TSC
Advocate
Advocate
Accepted solution

^R = "Turns command versioning on or off. Command versioning is required for some commands to ensure the

command macro written in an older release works properly in the latest release."

 

I can confirm that setting "Layer" in tool palettes properties does not work. "Linetype" works, but not "Layer". I don't use this palette but looks like a bug to me. You'll have to set layer in the macro.

 

Regarding arc length...

System Variables [starting AutoCAD 2021 using command version 3 (initcommandversion 3)]:

REVCLOUDAPPROXARCLEN - variable controlling arc length, adds arc length property to cloud entity as extended data (xdata)

REVCLOUDARCVARIANCE - 0-OFF, 1-ON (OFF results in uniform arc lengths)

 

Try macro below:

 

^C^C^P(initcommandversion 3)(setvar "revcloudapproxarclen" (* (getvar "dimscale") 0.2))(setvar "revcloudarcvariance" 0)(setvar "clayer" "Revisions")(princ) ^P_revcloud _R

 

The above assumes layer "Revisions" is already defined in the drawing. If you would like to have layer created on-the-fly, other than by executing "Layer" command within macro, add lisp function below to a startup file (acaddoc.lsp or <menu>.mnl) and replace (setvar "clayer" "Revisions") in macro with (mklyr "Revisions" 7 nil T).

 

(vl-load-com)
;; Args: nam <layer name>, clr <color>, ltp <linetype, nil="Continuous">, cur <set as current>
(defun mklyr ( nam clr ltp cur )
  (or (not ltp)(tblsearch "ltype" ltp)
    (vla-load
      (vla-get-Linetypes
        (vla-get-activedocument
          (vlax-get-acad-object)))
      ltp "acad.lin"
    )
  )
  (or (tblsearch "layer" nam)
    (entmake
      (list
        '(0 . "LAYER")'(100 . "AcDbSymbolTableRecord")'(100 . "AcDbLayerTableRecord")'(70 . 0)
        (cons 2 nam) (cons 62 clr) (cons 6 (cond (ltp)("Continuous")))
      )
    )
  )
  (if cur (setvar "clayer" nam))
  (princ)
)

 

Finally, ^R is not needed here. And if you ever adopt annotative scale you'll want to replace (getvar "dimscale") with (/ 1.0 (getvar "cannoscalevalue")).

0 Likes
Message 4 of 9

jquade
Participant
Participant

Rick,

 

Thank you for your detailed response. The command string you provided works. But now that I know there are system variables for setting the arc length and variance, I have decided to set those in the acaddoc.lsp file. This way, I can use the original macro in the tool palette to start the command and add the object to the correct layer. Changing the layer in the macro does not set it back to the original value when the command is finished. I know there are many ways all this could be done, but you provided the information I needed.

 

You added a ^P in your macro. What does the ^P do? And where can I find a list of all of the ^ options? I searched and cannot find anything.

 

Jack

0 Likes
Message 5 of 9

Kent1Cooper
Consultant
Consultant

@jquade wrote:

.... You added a ^P in your macro. What does the ^P do? And where can I find a list of all of the ^ options? ....


It toggles menu echoing.  The complete list is >here<.

Kent Cooper, AIA
Message 6 of 9

Rick_Tolleshaug_TSC
Advocate
Advocate

@Kent1Cooper provided answer. You'll typically use two ^P in a macro - first toggles off menu echo so lisp code does not show at command prompt, second toggles on menu echo so command shows.

 

Returning to previous current layer cannot be done (or not very easily) using default macro, you'd have to define a lisp command for revcloud. 

Message 7 of 9

Kent1Cooper
Consultant
Consultant

@Rick_Tolleshaug_TSC wrote:

.... Returning to previous current layer cannot be done (or not very easily) using default macro.... 


Wouldn't the LAYERP command handle that easily enough?

Kent Cooper, AIA
0 Likes
Message 8 of 9

pendean
Community Legend
Community Legend

@Kent1Cooper wrote:

...Wouldn't the LAYERP command handle that easily enough?


LAYERP can get it wrong if your do any sort of unintended layer manipulation between what you want to go back to and where you are at now.

 

I find using a 'temp" layerstate snapshot as my go-back-to point a more consistent workflow.

Message 9 of 9

Rick_Tolleshaug_TSC
Advocate
Advocate

Need to distinguish between resetting current layer through user input versus auto reset at conclusion of a command initiated from menu via simple macro that changed current layer. I was talking of the latter.

0 Likes