Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help adding text to string

Status
Not open for further replies.

vbcad

Technical User
Jul 12, 2002
159
US
I have downloaded a routine for doing arc dimensions in acad 2002. it works for what we need it to do but i would like to add the text (ARC LENGTH) after the numeric value. Also i would like to retrieve the units settings and reset them back after the routine runs. below is the code:

Code:
;arcdim.lsp   Arc Length   (c)1998, Paul Standing

;MEASURES THE LINEAR LENGTH OF ARCS AND DIMENSIONS THE ARC TO THE
        (defun dtr (x)
        (* pi (/ x 180.00))
        )
        
        (defun rtd (y)
        (/ (* 180 y) pi)
        )
        
       (defun right ()
         (setq ang1 (angle ep cen)
              ang2 (angle ep1 cen)
              ang (- ang1 ang2)
              arclen (abs(* rad ang))
         )
        )
       
        (defun left ()
        (setq ang (- a1 a2))
        (setq arclen (abs(* rad ang)))
        )

;_______________________________________________________________________        

        (defun C:arcdim (/ ang1 ang2 ang arclen rad pick_pt pick_ang 
        cen pick_pt extpt1 extpt2 extpt3 extpt4 ep a1 a2 ep1 e6 e7 ent4 temp_pt1
        temp_pt2 temp_pt3 temp_pt4 e1 e2 e3 e4 text_ang th txt1 txt e5 ep1a epa
        ep1a1 epa1 search type)
        (setvar "cmdecho" 0)
	(command "-units" "5" "32" "1" "2" "0" "n" "")
        (setvar "blipmode" 0)
        (setq cn (entsel "\nSelect arc to dimension: "))
        (setq dn (car cn))
        (setq aw (entget dn))
        (setq type (cdr(assoc 0 aw)))
     (if (= type "ARC")
          (progn 
        (setq a1 (cdr (assoc 50 aw)))
        (setq a2 (cdr (assoc 51 aw)))
        (setq cen (cdr (assoc 10 aw))
              rad (cdr (assoc 40 aw)))
        (setq ep (polar cen (cdr (assoc 50 aw)) rad)
              ep1 (polar cen (cdr (assoc 51 aw)) rad))
                  (if (< a1 a2) (left)
                      (right)
                   )
         (prompt "\nEnter dimension location: ")
         (command "dim" "angular" "" cen ep ep1 pause (rtos arclen) "" "exit")
 
            )
        (prompt "\nThe Selected entity was not an arc ")
    )
    (setvar "clayer" "0")
    (setvar "cmdecho" 1)
    ;(setvar "blipmode" 1)

                         (princ)
)
        (princ "\nType arcdim to envoke the command: ")
 
To add "ARC LENGTH" modify the following line:

(command "dim" "angular" "" cen ep ep1 pause (rtos arclen) "" "exit")

to:

Code:
(command "dim" "angular" "" cen ep ep1 pause (strcat (rtos arclen) " ARC LENGTH") "" "exit")

To save user units settings add the following snippet after the line (setvar "cmdecho" 0)

Code:
(setq UsrAunits (getvar "AUNITS")
      UsrAuprec (getvar "AUPREC")
      UsrLunits (getvar "LUNITS")
      UsrLuprec (getvar "LUPREC")
      UsrAngdir (getvar "ANGDIR")
)

And to restore settings, add the following lines just before the line (setvar "cmdecho" 1):

Code:
(setvar "AUNITS" UsrAunits) 
(setvar "AUPREC" UsrAuprec)
(setvar "LUNITS" UsrLunits)
(setvar "LUPREC" UsrLuprec)
(setvar "ANGDIR" UsrAngdir)



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top