Results 1 to 4 of 4

Thread: balloon with leader

  1. #1
    Member
    Join Date
    2020-01
    Posts
    2
    Login to Give a bone
    0

    Default balloon with leader

    Dear All,

    Below is a lisp of balloon with leader, Could someone please help me: no matter which layer i use i would like to make leader color yellow, circle color white and text inside circle color red. they are all under same layer.

    Thanks so much

    Quoc Nguyen

    Code:
    ;|
      	1. Removed all references to layer changing,
    	so that the current layer can be utilized.
    	2. Used DIMSCALE instead of TEXTSIZE, for
    	those who use 0 text height
    	3. Added Osmode, for those who use running osnap
    	4. Added DIMASZ, for those who have custom arrow sizes
    	5. Used LEADER instead of DIM LEADER, single entity
    	6. Removed all references to changing an entities color,
    	one of my Cardinal Rules.
    |;
    (defun ERR (s)
      (if (/= s "Function cancelled\n")
        (if (= s "quit / exit abort")
    	    (princ)
            (alert (strcat "           >> Error << \n"))
        )
      )
      (setvar "cecolor" "bylayer")
    ;  (command "layer" "s" cl "")
    ;  (setvar "textsize" oldTS)
    ;  (setvar "dimblk" arwtype)
      (setvar "orthomode" om)
      (setvar "osmode" os)
      (setvar "regenmode" 1)
      (setvar "cmdecho" 1)
      (setq *error* olderr)
      (princ)
    ) 
    
    (defun input_integer (a b / c)
       (setq a (strcat a " <"(rtos b 2 0)"> "))
       (setq c (getint a))
       (if (/= c NIL)
          (setq b c)
          (setq b b)
       )
    )
    (setq incr 1)
    (defun item (ent)
       (cdr(car(entget(ent))))
    )
    
    ;Main function
    (defun c:balloon ()
       (setq olderr *error* *error* err)
       (setvar "cmdecho" 0)
       (setvar "regenmode" 0)
       (setq om (getvar "orthomode"))
       (setvar "orthomode" 0)
       (setq os (getvar "osmode"))
       (setvar "osmode" 0)
       (setq cl (getvar "clayer"))
       (setq arsize (getvar "dimasz"))
    
    ;   (setvar "dimasz" 0.125) 
    ; JT - Custom arrow size defined by Dim Lisp routines.
    (cond ((= #dwgsz "11x17")(setvar "dimasz" 0.075))((= #dwgsz "24x36")(setvar "dimasz" 0.125)))
    
    ;Define and set layer for entities
    ;Change layer name and color below
    ;   (if (not (tblsearch "LAYER" "dim"))
    ;    (command "layer" "m" "dim" "c" "5" "dim" "")
    ;   )
    ;(command "layer" "s" "dim" "")
    ;(setq arwtype (getvar "dimblk"))
    ;(setvar "dimblk" ".")
    
    ;Edit the line below to change circle radius
    (setq rad (* (getvar "dimscale") 0.125))
    d
    (setq oldts (getvar "textsize"))
    
    ;Edit the line below to change text height
    ;(setq ts (*(getvar "textsize")0.1))
    ;JT - Use dimscale instead - not all text has a textsize
    (setq ts (* (getvar "dimscale") 0.1))
    (setq x (getpoint "\nStart point of Arrow: ")
          y (getpoint x "\nCenter of Balloon: ")
          dis (distance x y)
          ang (angle x y)
          yy (polar x ang (- dis rad))); get leader angle, length of leader to edge of circle
    
    ; JT - Draws the leader as a single entity
    (command "leader" x yy "" "" "n")
    
    ;Draws the leader as separate entities
    ;(command "dim" "leader" x yy)
    (command)
    ;Used to exit DIM command line
    ;(command "exit")
    ;Create new layer for circle and text
    ;(if (not (tblsearch "LAYER" "dim-ct"))
    ;(command "layer" "m" "dim-ct" "c" "7" "dim-ct" "")
    ;)
    ;(command "layer" "s" "dim-ct" "")
    ; JT - Cardinal Rule: never change entity color, only change layer color
    ;      Make a new layer with color 7 if you need different pen widths
    ;(setvar "cecolor" "7")
    (command "circle" y rad)
    (clnu)
    (princ)
    )
    
    (defun clnu (/ num pt)
       (setq incr (input_integer "\nEnter number: "  incr))
    ;JT - Cardinal Rule: never change entity color, only change layer color
    ;     Make a new layer with color 7 if you need different pen widths
    ;   (setvar "cecolor" "7")
       (command "text" "m" y ts "0" (itoa incr))
       (setq incr (+ incr 1))
       (setvar "cecolor" "bylayer")
       (command "layer" "s" cl "")
    ; JT - Text size and dimblk not needed
    ;   (setvar "textsize" oldts)
    ;   (setvar "dimblk" arwtype)
    ; JT - resets custom arrow size
       (setvar "dimasz" arsize)
       (setvar "orthomode" om)
       (setvar "osmode" os)
       (setvar "regenmode" 1)
       (setvar "cmdecho" 1)
    (setq *error* olderr)
    )
    (princ)
    Last edited by Opie; 2020-01-23 at 05:39 PM. Reason: [code] tags added

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

    Default Re: balloon with leader

    You need to Wrap Code tags around any code you post. No clue what that smiley face represents.

    Clicking the [Go Advanced] button at the bottom puts a toolbar at the top and the # icon in that toolbar places code tags around selected text for you or simply paste your code inside.

  3. #3
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Default Re: balloon with leader

    I'm not sure what some of the stuff in here is for, it looks like the original code is telling you NOT to override layer colors and such but anywho.. this is what I came up with to do what you were asking:
    Code:
    (defun ERR (s)
      (if (/= s "Function cancelled\n")
        (if (= s "quit / exit abort")
    	    (princ)
            (alert (strcat "           >> Error << \n"))
        )
      )
      (setvar "cecolor" "bylayer")
    ;  (command "layer" "s" cl "")
    ;  (setvar "textsize" oldTS)
    ;  (setvar "dimblk" arwtype)
      (setvar "orthomode" om)
      (setvar "osmode" os)
      (setvar "regenmode" 1)
      (setvar "cmdecho" 1)
      (setq *error* olderr)
      (princ)
    ) 
    
    (defun input_integer (a b / c)
       (setq a (strcat a " <"(rtos b 2 0)"> "))
       (setq c (getint a))
       (if (/= c NIL)
          (setq b c)
          (setq b b)
       )
    )
    (setq incr 1)
    (defun item (ent)
       (cdr(car(entget(ent))))
    )
    
    ;Main function
    (defun c:balloon ()
       (setq olderr *error* *error* err)
     (setq dclr (getvar "dimclrd")) ;;;;< I ADDED TO GET THIS VARIABLE (DIM AND LEADER COLOR SETTINGS)
     (setvar "dimclrd" 2) ;;;;< I ADDED TO SET TO COLOR 2
       (setvar "cmdecho" 0)
       (setvar "regenmode" 0)
       (setq om (getvar "orthomode"))
       (setvar "orthomode" 0)
       (setq os (getvar "osmode"))
       (setvar "osmode" 0)
       (setq cl (getvar "clayer"))
       (setq arsize (getvar "dimasz")) 
    
    ;   (setvar "dimasz" 0.125) 
    ; JT - Custom arrow size defined by Dim Lisp routines.
    (cond ((= #dwgsz "11x17")(setvar "dimasz" 0.075))((= #dwgsz "24x36")(setvar "dimasz" 0.125)))
    
    ;Define and set layer for entities
    ;Change layer name and color below
    ;   (if (not (tblsearch "LAYER" "dim"))
    ;    (command "layer" "m" "dim" "c" "5" "dim" "")
    ;   )
    ;(command "layer" "s" "dim" "")
    ;(setq arwtype (getvar "dimblk"))
    ;(setvar "dimblk" ".")
    
    ;Edit the line below to change circle radius
    (setq rad (* (getvar "dimscale") 0.125))
    d
    (setq oldts (getvar "textsize"))
    
    
    (setq ts (* (getvar "dimscale") 0.1))
    (setq x (getpoint "\nStart point of Arrow: ")
          y (getpoint x "\nCenter of Balloon: ")
          dis (distance x y)
          ang (angle x y)
          yy (polar x ang (- dis rad))); get leader angle, length of leader to edge of circle
    
    ; JT - Draws the leader as a single entity
    (command "leader" x yy "" "" "n")
    
    
    
    (command "circle" y rad)
    (command "chprop" "l" "" "c" "7" "") ;;;;< I ADDED A CHANGE PROP HERE AFTER CREATING THE CIRCLE
    (clnu)
    (princ)
    )
    
    (defun clnu (/ num pt)
       (setq incr (input_integer "\nEnter number: "  incr))
    
       (command "text" "m" y ts "0" (itoa incr))
       (setq incr (+ incr 1))
       (command "chprop" "l" "" "c" "1" "");;;;< I ADDED A CHANGE PROP HERE AFTER CREATING THE TEXT
       (setvar "cecolor" "bylayer")
       (command "layer" "s" cl "")
    
       (setvar "dimasz" arsize)
       (setvar "orthomode" om)
       (setvar "osmode" os)
       (setvar "regenmode" 1)
       (setvar "cmdecho" 1)
      (setvar "dimclrd" dclr) ;;;;< I ADDED TO RESET DIM AND LEADER COLOR SETTINGS
    (setq *error* olderr)
    )
    (princ)

  4. #4
    Member
    Join Date
    2020-01
    Posts
    2
    Login to Give a bone
    0

    Default Re: balloon with leader

    Thanks Ted

    Quoc Nguyen

Similar Threads

  1. Balloon Leader and Text problems
    By Geoffrey Wheeler in forum AutoCAD Map 3D - General
    Replies: 1
    Last Post: 2009-02-14, 02:49 PM
  2. Replies: 5
    Last Post: 2007-03-13, 02:21 PM
  3. Balloon Leader... anyone?
    By nickeshaffer in forum AutoCAD General
    Replies: 10
    Last Post: 2006-06-09, 06:30 PM
  4. Leader with Balloon
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2006-03-26, 01:17 AM
  5. Automatic Leader lines avoiding other leader lines
    By neilcheshire in forum AutoCAD General
    Replies: 3
    Last Post: 2004-10-06, 11:33 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
  •