TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: TJAM51 on October 19, 2004, 06:26:22 PM

Title: bALLOON ROUTINE
Post by: TJAM51 on October 19, 2004, 06:26:22 PM
I have the following balloon routine and all works well except when you have to type in the text. I receive the following error message. I am using 2004 architectural desktop.



Enter text:  (at this point I entered the letter A. It did the same with the
                   nymber 1)
Command: A Unknown command "A".  Press F1 for help.



ROUTINE

;;;This file allows the user to draw Balloon references
;;;to call out items in a drawing

;;;© Alan Henderson 2000

;;; type "BAL1" to insert a single item balloon.
;;; type "BAL2" to insert an assembly item balloon.
;;; A single item balloon is defined by a single circle around the text
;;; An assembly balloon is defined by a double circle around the text

;;;SINGLE ITEM BALLOON*********************************************
(defun C:BAL1 ()

  (setq   old_lay   (getvar "clayer")
   size   (getvar "textsize")
  )
  (setvar "orthomode" 0)
  (command "layer" "set" "text" "")
  (prompt
    "\nPlease ensure you have selected the text height!..... \n"
  )
  (princ)

;;;Draws the leader & Attaches the line to the leader
  (command "leader" pause pause "" "" "n")
  (setq pt1 (getvar "lastpoint"))
  (setvar "orthomode" 1)
  (command "line" pt1 pause "")
  (setq pt2 (getvar "lastpoint"))

;;;Draws the circle at the line endpoint
  (command "circle" pt2 size)
  (setq cl (entlast))

;;;Trims the line to the circle
  (command "trim" cl "" pt2 "")

;;;Put the text at the circle centre
  (setq t1 (getstring "\nEnter Item number:"))
  (command "text" "J" "MC" pt2 size "" t1)
  (command "layer" "set" old_lay "")
)

;;;ASSEMBLY BALLOON**************************************************
(defun C:BAL2 ()

  (setq   old_lay   (getvar "clayer")
   size   (getvar "textsize")
  )
  (setvar "orthomode" 0)
  (command "layer" "set" "text" "")
  (prompt
    "\nPlease ensure you have selected the text height!..... \n"
  )
  (princ)

;;;Draws the leader & Attaches the line to the leader
  (command "leader" pause pause "" "" "n") ;Draws the leader
  (setq pt1 (getvar "lastpoint"))
  (setvar "orthomode" 1)
  (command "line" pt1 pause "")
  (setq pt2 (getvar "lastpoint"))

;;;Draws the circle at the line endpoint
  (command "circle" pt2 size)
  (setq cl (entlast))

;;;Copies & offsets the second circle & trim the line to the circle
  (command "copy" cl "" pt2 pt2)
  (setq cl2 (entlast))
  (command "scale" cl2 "" pt2 "1.2")
  (command "trim" cl2 "" pt2 "")

;;;Puts the text at the circle centre
  (setq t2 (getstring "\nEnter Item number:"))
  (command "text" "J" "MC" pt2 size "" t2)
 
  (command "layer" "set" old_lay "")

[/b]
Title: bALLOON ROUTINE
Post by: Keith™ on October 19, 2004, 06:39:30 PM
I would suspect that it is in conjuntion with the text command being used....but it looks ok though .... perhaps a setting with the particular text you are using? Some text style definitions if they are predefined, will cause the text command to utilize a different number of prompts. When this occurs the problem you mention crops its head up....

have you tried looking at the one here (http://www.theswamp.org/phpBB2/viewtopic.php?p=24441#24441)?
Title: bALLOON ROUTINE
Post by: CAB on October 19, 2004, 07:10:34 PM
TJ
Keith has a much better routine, but the text height requires that you
test for zero size.
I added that but you will still have problems with the circle from time to time.
Code: [Select]
;;;This file allows the user to draw Balloon references
;;;to call out items in a drawing

;;;© Alan Henderson 2000

;;; type "BAL1" to insert a single item balloon.
;;; type "BAL2" to insert an assembly item balloon.
;;; A single item balloon is defined by a single circle around the text
;;; An assembly balloon is defined by a double circle around the text

;;;SINGLE ITEM BALLOON*********************************************
(defun c:bal1 ()

  (setq old_lay (getvar "clayer")
        size    (getvar "textsize")
  )
  (setvar "orthomode" 0)
  (command "layer" "set" "text" "")
  (prompt
    "\nPlease ensure you have selected the text height!..... \n"
  )
  (princ)

;;;Draws the leader & Attaches the line to the leader
  (command "leader" pause pause "" "" "n")
  (setq pt1 (getvar "lastpoint"))
  (setvar "orthomode" 1)
  (command "line" pt1 pause "")
  (setq pt2 (getvar "lastpoint"))

;;;Draws the circle at the line endpoint
  (command "circle" pt2 size)
  (setq cl (entlast))

;;;Trims the line to the circle
  (command "trim" cl "" pt2 "")

;;;Put the text at the circle centre
  (setq t1 (getstring "\nEnter Item number:"))
  ;; If text height is undefined (signified by 0 in the table)
  (if (= (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))) 0)
    ;; Draw the text using the current text height (textsize)
    (command "text" "mc" pt2 size "" t1)
    ;; Otherwise use the defined text height
    (command "text" "mc" pt2 "" t1)
  ) ; endif
  (command "layer" "set" old_lay "")
)

;;;ASSEMBLY BALLOON**************************************************
(defun c:bal2 ()

  (setq old_lay (getvar "clayer")
        size    (getvar "textsize")
  )
  (setvar "orthomode" 0)
  (command "layer" "set" "text" "")
  (prompt
    "\nPlease ensure you have selected the text height!..... \n"
  )
  (princ)

;;;Draws the leader & Attaches the line to the leader
  (command "leader" pause pause "" "" "n") ;Draws the leader
  (setq pt1 (getvar "lastpoint"))
  (setvar "orthomode" 1)
  (command "line" pt1 pause "")
  (setq pt2 (getvar "lastpoint"))

;;;Draws the circle at the line endpoint
  (command "circle" pt2 size)
  (setq cl (entlast))

;;Copies & offsets the second circle & trim the line to the circle
  (command "copy" cl "" pt2 pt2)
  (setq cl2 (entlast))
  (command "scale" cl2 "" pt2 "1.2")
  (command "trim" cl2 "" pt2 "")

;;Puts the text at the circle centre
  (setq t2 (getstring "\nEnter Item number:"))

  ;; If text height is undefined (signified by 0 in the table)
  (if (= (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))) 0)
    ;; Draw the text using the current text height (textsize)
    (command "text" "mc" pt2 size "" t2)
    ;; Otherwise use the defined text height
    (command "text" "mc" pt2 "" t2)
  ) ; endif
  (command "layer" "set" old_lay "")
)
Title: bALLOON ROUTINE
Post by: hendie on October 20, 2004, 08:03:00 AM
oh no.. another old embarrassing moment  :oops:
Title: bALLOON ROUTINE
Post by: daron on October 20, 2004, 08:06:49 AM
Want a vba version of the same program, written by the same person?
Title: bALLOON ROUTINE
Post by: hendie on October 20, 2004, 08:14:56 AM
:horror:



Daron, I don't think that ever got finished.. did it ?
Keith & I were talking about that one just the other day. You're right, the VBA version is much better, having more error control etc but as far as I can remember, the project got kind of halted due to other work
Title: bALLOON ROUTINE
Post by: daron on October 20, 2004, 08:24:40 AM
Yeah. I'm not sure if it did get finished. At the same time, I've come to learn that different browsers in the same family are bothersome. My version of Mozilla 1.6 views everything as I wrote it, but firefox hides the submit button on the original screen to my page and doesn't give a scroll bar, as well it does the same in the content areas. I haven't had much time to play with it since moving. I'd like to get that going again sometime.
Title: bALLOON ROUTINE
Post by: TJAM51 on October 20, 2004, 11:05:31 AM
I tried the routine dimbal that is dialog driven. I am seeking a way to draw a simple balloon or even a hex that is based on the dimscale.
Title: bALLOON ROUTINE
Post by: hendie on October 20, 2004, 11:10:33 AM
you mention you're using ADT 2004 ~ this was written way back in 2000 ~ for Acad 2000 ~ have the text prompts changed ?
(or perhaps your text style ~as Keith mentioned)

for a quick test, check your current text style and change the height to 0 then run the lisp again ~what happens ?
Title: bALLOON ROUTINE
Post by: TJAM51 on October 20, 2004, 11:12:43 AM
I may have not ben clear...sorry...I am using ADT2004.
Title: bALLOON ROUTINE
Post by: CAB on October 20, 2004, 12:13:03 PM
Quote from: TJAM51
I tried the routine dimbal that is dialog driven. I am seeking a way to draw a simple balloon or even a hex that is based on the dimscale.
I think if you make this mod it will work for you.
Code: [Select]
(setq dsc (getvar "dimscale"))
(setq cad_dim_asz (*(getvar "dimasz")dsc))   ;Arrow size (in drawing units)
(setq cad_dim_tsz (*(getvar "dimtxt")dsc))   ;Text size (in drawing units)
Title: bALLOON ROUTINE
Post by: megamike on October 20, 2004, 02:13:45 PM
If you are using ADT, why not use the leader routines already there under the "documentation" content?
They work! :wink:
Title: bALLOON ROUTINE
Post by: TJAM51 on October 20, 2004, 03:26:24 PM
If you are using ADT, why not use the leader routines already there under the "documentation" content?






I am not sure of this. Does this offer balloons?


Thanks
Title: bALLOON ROUTINE
Post by: megamike on October 20, 2004, 03:34:24 PM
TJAM51 wrote:

Quote
I am not sure of this. Does this offer balloons?


Yes, balloons, squares, diamonds, hex, of just text, all with your choice of splined or straight leaders.
Check it out in the "Documentation" content under "leaders".