Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Tool Palette Commands with Custom MText Lisp

  1. #1
    Member
    Join Date
    2017-11
    Posts
    6
    Login to Give a bone
    0

    Default Tool Palette Commands with Custom MText Lisp

    I am trying to create some Tools on the Tool Palette where Dtext and Mtext would be created on specific layers (One for Curb Text, One for Building Text, etc.). When I try to use it with a custom Lisp I have set for MText, it never creates the text on the correct layer; it always ends up on the current layer instead. Here is the LISP I am using:

    Code:
    ; Mtext at Viewtwist rotation
    (defun c:mtr()
      (setq twang (-(/ (* (GETVAR "viewtwist") 180.0) PI))
      )
      (initdia)
      (command "mtext" PAUSE "R" twang "J" "TC")
    )
    Any help would be appreciated.

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Tool Palette Commands with Custom MText Lisp

    This is what I've always used
    Mtext at Viewtwist rotation as a macro:
    Code:
    ^C^C_mtext;\r;(/ (* 180 (- (getvar "viewtwist"))) pi);
    Don't know if that will work any different for assigning the correct layer. Tool Palettes aren't my strong suite.

  3. #3
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Tool Palette Commands with Custom MText Lisp

    https://knowledge.autodesk.com/suppo...fic-layer.html
    To draw an object directly in a specific layer without making the layer current

    Insert the command or object as a tool in a tool palette (dimension, hatch, circle, and so on).
    Right-click on the tool. Click Properties.
    In the Tool Properties dialog box, set the layer.
    When you draw the object using the tool in the tool palette, it will be drawn on the layer specified.

    Note: If the layer does not exist in the drawing, it will be created.

  4. #4
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    559
    Login to Give a bone
    0

    Default Re: Tool Palette Commands with Custom MText Lisp

    You need to set the layer 1st
    mtrK mtext kerb layer

    Code:
    ; Mtext at Viewtwist rotation
    (defun c:mtrK()
    (setvar 'clayer "Kerb")
      (setq twang (-(/ (* (GETVAR "viewtwist") 180.0) PI))
      )
      (initdia)
      (command "mtext" PAUSE "R" twang "J" "TC")
    )
    You can via a reactor actually trap command errors and convert them to commands so for me I would type mtxtk this command does not exist but I check the error look at the mtxt bit and pull the k of the end and set the correct layer, then run mtr.

    So final comment much simpler just repeat for each layer required.
    Last edited by BIG-AL; 2017-11-30 at 04:20 AM.

  5. #5
    Member
    Join Date
    2017-11
    Posts
    6
    Login to Give a bone
    0

    Default Re: Tool Palette Commands with Custom MText Lisp

    Thank you for the replies. I tried your Command String, Tom, and it still creates the text in the current layer. I have attached an image of my Tool Properties.

    Big_Al, I would prefer to not have to create a lisp for every layer but instead just edit the Command String and have the Layer be properly set by the Tool. Am I able to do that or am I forced to set the layer in the lisp?
    Attached Images Attached Images

  6. #6
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Tool Palette Commands with Custom MText Lisp

    Looks like it should have placed it on layer V-SITE-DECK-TEXT. What layer was it placed on?

  7. #7
    Member
    Join Date
    2017-11
    Posts
    6
    Login to Give a bone
    0

    Default Re: Tool Palette Commands with Custom MText Lisp

    Whatever the current layer is. So in the picture above the 0 layer. I thought maybe it was something wacky with the 0 layer but it behaved the same way on other layers as well. When you select the command it temporarily changes the layer to V-SITE-DECK-TEXT. But as soon as you make the text box to type in it goes back to the Current Layer.

  8. #8
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    559
    Login to Give a bone
    0

    Default Re: Tool Palette Commands with Custom MText Lisp

    Ok you will still need a button for kerb path road etc but 1 program, I would put the lisp as autoloaded on startup

    Code:
    ; Mtext at Viewtwist rotation
    (defun mtr (curlayer / )
    (setvar 'clayer curlayer)
      (setq twang (-(/ (* (GETVAR "viewtwist") 180.0) PI))
      )
      (initdia)
      (command "mtext" PAUSE "R" twang "J" "TC")
    )
    your buttons
    Code:
    ^c^c^p(mtr "Kerb")
    ^c^c^p(mtr "Road")
    ^c^c^p(mtr "Pipe")
    if you want a keyboard option you will need another lisp as you are changing layer name. Could be as simple as a number of defuns

    Code:
    (defun c:mtrk ()  (mtr "Kerb"))
    (defun c:mtrp ()  (mtr "Pipe"))
    (defun c:mtrr ()  (mtr "Road"))
    Last edited by BIG-AL; 2017-12-01 at 12:37 AM.

  9. #9
    Member
    Join Date
    2017-11
    Posts
    6
    Login to Give a bone
    0

    Default Re: Tool Palette Commands with Custom MText Lisp

    Big-Al, the issue I am having with your button is that it changes my current layer. I want to use the tool function to add text on different layers without changing my current layer.

  10. #10
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Tool Palette Commands with Custom MText Lisp

    Modification of BIG-AL's code should reset the current layer:
    Code:
    ; Mtext at Viewtwist rotation
    (defun mtr (curlayer / clayer)
      (setq clayer(getvar'clayer))
      (setvar 'clayer curlayer)
      (setq twang (-(/ (* (GETVAR "viewtwist") 180.0) PI))
      )
      (initdia)
      (command "mtext" PAUSE "R" twang "J" "TC")
      (setvar 'clayer clayer)
    )
    From home, untested!

Page 1 of 2 12 LastLast

Similar Threads

  1. Hide text in command line when using tool palette commands
    By jpcadconsulting347236 in forum AutoLISP
    Replies: 4
    Last Post: 2014-10-28, 06:00 PM
  2. Custom Tool Palette images
    By FabriCADed in forum AutoCAD Customization
    Replies: 4
    Last Post: 2013-05-28, 01:28 PM
  3. 2012: Add Custom Commands to Tool Palette
    By Darren Allen in forum AutoCAD General
    Replies: 14
    Last Post: 2013-04-02, 04:27 PM
  4. Put sub-assemblies into a Tool Palette or the Custom Tool Catalog?
    By justin.d.ehart in forum AutoCAD Civil 3D - Corridors
    Replies: 1
    Last Post: 2007-06-05, 03:52 PM
  5. Mtext key-in or Palette Text Tool ?
    By tomdillenbeck in forum ACA General
    Replies: 1
    Last Post: 2005-05-11, 11:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •