See the top rated post in this thread. Click here

Results 1 to 10 of 10

Thread: Balloon Lisp

  1. #1
    Member
    Join Date
    2007-10
    Posts
    3
    Login to Give a bone
    0

    Default Balloon Lisp

    I'm trying to update the old balloon lisp to incorporate turning off ortho and osnap and turn them back to their original state after the routine finishes. It's not working for me for some reason. I'd also like it to make the arrow and line one piece like the qleader but I have no idea how to do that. And I'd like it to use the osnap "nearest" as the default pick point if that's possible.

    I know there's a much newer Ballons lisp routine that is much more advanced and I may use that one once in a while if I need the balloon to be a polygon but this one is much faster to use.


    Code:
    (defun c:b () 
      (setq *CMD* (getvar "cmdecho")
            *ORT* (getvar "orthomode")
            *OSM* (getvar "osmode")
      )
      (setvar "cmdecho" 0)
      (setvar "orthomode" 0)
      (setvar "osmode" 0)
    (setq ds (getvar "dimscale"))
    (initget 1) (setq p1 (getpoint "\nFrom point: "))
    (command "_nea")
    (initget 1) (setq p2 (getpoint p1 "\nTo point: "))
    (if (<= (car p2) (car p1)) (setq b (* -0.375 ds))
    (setq b (* 0.375 ds)))
    (setq p3 (list (+ (car p2)(/ b 4)) (cadr p2)))
    (setq p4 (list (+ (car p3) (/ b 2)) (cadr p3)))
    (command "dim1" "leader" p1 p2 p3 ^C^C)
    (command "circle" p4 (/ (abs b) 2))
    (initget 1) (setq c (getstring t "\nText for bubble: "))
    (command "text" "m" p4 (* 0.094 ds) 0 c) (princ))
      (setvar "orthomode" *ORT*)
      (setvar "osmode" *OSM*)
      (setvar "cmdecho" *CMD*)
    Any help is greatly appreciated! TIA

    Scott
    Last edited by Opie; 2007-10-17 at 01:36 PM. Reason: [CODE] tags added

  2. #2
    AUGI Addict madcadder's Avatar
    Join Date
    2000-11
    Location
    Too far from the beach
    Posts
    1,054
    Login to Give a bone
    0

    Default Re: Balloon Lisp

    double check your osmode before running.
    Try doing a setq for each at the beginning.

  3. #3
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Balloon Lisp

    Here you go Scott. You should also make your variables local, I will leave that to you, but let us know if you need help there.
    Code:
    (defun c:b ()
    (setq
    	*CMD* (getvar "cmdecho")
    	*ORT* (getvar "orthomode")
    	*OSM* (getvar "osmode")
    )
    (setvar "cmdecho" 0)
    (setvar "orthomode" 0)
    (setvar "osmode" 512)
    (setq ds (getvar "dimscale"))
    (initget 1)
    (setq p1 (getpoint "\nFrom point: "))
    (initget 1)
    (setq p2 (getpoint p1 "\nTo point: "))
    (if (<= (car p2) (car p1))
    	(setq b (* -0.375 ds))
    	(setq b (* 0.375 ds))
    )
    (setq p3 (list (+ (car p2)(/ b 4)) (cadr p2)))
    (setq p4 (list (+ (car p3) (/ b 2)) (cadr p3)))
    ;(command "dim1" "leader" p1 p2 p3 ^C^C)
    (command "_.leader" p1 p2 p3 "" "" "_n")
    (command "circle" p4 (/ (abs b) 2))
    (initget 1)
    (setq c (getstring t "\nText for bubble: "))
    (command "text" "m" p4 (* 0.094 ds) 0 c)
    (setvar "orthomode" *ORT*)
    (setvar "osmode" *OSM*)
    (setvar "cmdecho" *CMD*)
    (princ)
    )

  4. #4
    Member
    Join Date
    2007-10
    Posts
    3
    Login to Give a bone
    0

    Default Re: Balloon Lisp

    Thanks a lot Tim! Works like a charm. You'll have to forgive me. I haven't messed with lisp files for years. If you wouldn't mind, could you refresh my memory about how to make my variables local.

    Kindest regards, Scott

  5. #5
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Balloon Lisp

    You're welcome Scott. To make variables local you must put them into the parenthesis that follow the command name, after a forward slash and a space. Example (not using your code).
    Code:
    (defun c:Test ()
    
    (setq a "This is a test.")
    )
    In this code, the variable 'a' is set to a string, and after the code is finished it will still be floating around Acad (in the current drawing) for use in other routines, but if you do
    Code:
    (defun c:Test (/ a)
    
    (setq a "This is a test 2.")
    )
    'a' will not hold it's value out side of the routine, and it will not inherit the value from the other variable 'a' floating around in Acad.

    Hope that makes sense.

  6. #6
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    1

    Default Re: Balloon Lisp

    You should turn off osmode during the commands else it may snap to a hearby object.
    Code:
    (defun c:b ()
      (setq *CMD* (getvar "cmdecho")
            *ORT* (getvar "orthomode")
            *OSM* (getvar "osmode")
      )
      (setvar "cmdecho" 0)
      (setvar "orthomode" 0)
      (setvar "osmode" 512)
      (setq ds (getvar "dimscale"))
      (initget 1)
      (setq p1 (getpoint "\nFrom point: "))
      (initget 1)
      (setq p2 (getpoint p1 "\nTo point: "))
      (if (<= (car p2) (car p1))
        (setq b (* -0.375 ds))
        (setq b (* 0.375 ds))
      )
      (setq p3 (list (+ (car p2) (/ b 4)) (cadr p2)))
      (setq p4 (list (+ (car p3) (/ b 2)) (cadr p3)))
      (command "_.leader" "_non" p1 "_non" p2 "_non" p3 "" "" "_n")
      (command "circle" "_non" p4 (/ (abs b) 2))
      (initget 1)
      (setq c (getstring t "\nText for bubble: "))
      (command "text" "m" "_non" p4 (* 0.094 ds) 0 c)
      (setvar "orthomode" *ORT*)
      (setvar "osmode" *OSM*)
      (setvar "cmdecho" *CMD*)
      (princ)
    )

  7. #7
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Balloon Lisp

    Good catch Alan.

    Do you like seeing how many things you can find wrong in the code I post??



  8. #8
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Balloon Lisp

    Not at all. Just that I've been burnt so many times with those osnaps in my own code. I know you almost never use the COMMAND so you don't have to worry about it.

  9. #9
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Balloon Lisp

    Yea, it has been a long time since I used command in a new lisp. My old ones always turned them off, so I never would run into those problems.

  10. #10
    Member
    Join Date
    2007-10
    Posts
    3
    Login to Give a bone
    0

    Default Re: Balloon Lisp

    Thanks again. Good info from both of you!

Similar Threads

  1. Balloon
    By Wish List System in forum Inventor Wish List
    Replies: 2
    Last Post: 2013-10-29, 10:58 AM
  2. Balloon problem
    By martin.mccaffrey in forum Inventor - General
    Replies: 0
    Last Post: 2010-07-20, 01:26 PM
  3. Balloon Notification
    By dxarhoulakos in forum AutoCAD Customization
    Replies: 0
    Last Post: 2008-01-18, 03:43 PM
  4. Balloon Notifications
    By JasonSelf in forum AutoLISP
    Replies: 0
    Last Post: 2007-10-19, 04:08 PM
  5. Looking for a Balloon routine
    By kvannguyen in forum AutoLISP
    Replies: 2
    Last Post: 2005-10-27, 07:54 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
  •