Author Topic: Merging two routines  (Read 2140 times)

0 Members and 1 Guest are viewing this topic.

bman

  • Guest
Merging two routines
« on: October 03, 2005, 12:05:09 PM »
Where do I incorporate this routine:
Code: [Select]
(defun c:DTBL_SIMPLEX60 ( / inspnt txtht)
(command "-style"
"simplex0" ; name of text style
"simplex" ; font name
"0" ; height of text
"1" ; width factor
"0" ; obliquing angle
"" ; text backwards
"" ; text upside-down
)
(while (> (getvar "CMDACTIVE") 0)(command "")) ; Vertical
(prompt "\nCurrent Style set to Simplex ")
(setq inspnt (getpoint"\nPick point for text: "))
(setq txtht (* 0.06 (getvar "dimscale")))
(command "dtext"
inspnt
txtht
)
(princ)
)

into this routine:
Code: [Select]
(defun c:inv (/ elev run slope ang end_elev conv oldsnap clay)
(defun get_num (/ num elst ent)
    (while
      (not (cond ((setq   num
          (getreal
            "\n*** Enter a starting elevation: <Enter to pick text>"
          )
        )
        num
       )
       ((setq   ent
          (entsel
            "\n>>--> Select starting elevation: <Enter to type number>"
          )
        )
        (setq elst (entget (car ent)))
        (if (wcmatch (cdr (assoc 0 elst)) "*TEXT")
          (if   (> (setq num (atof (cdr (assoc 1 elst)))) 0)
            num
          )
        )
       )
      )
      )
    )
    num
  )
  ;;;
  (defun getx (object prop)
    (if   (= (type object) 'ename)
      (setq object (vlax-ename->vla-object object))
    )
    (vlax-get object prop)
  )
  ;;;
  (defun entlen   (obj)
    (if   (= (type obj) 'ename)
      (setq obj (vlax-ename->vla-object obj))
    )
    (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj))
  )
  ;;;
  (defun Radian->Degrees (nbrOfRadians) (* 180.0 (/ nbrOfRadians pi)))
  ;;;
  (setq usercmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq oldsnap (getvar "osmode"))
  (setq clay (getvar "clayer"))
  (setq elev (get_num))
  (prompt "\nSelect point: ")
  (setvar "osmode" 0)
  (setvar "osmode" 545)
  (command "_.pline")
  (while (> (getvar "cmdactive") 0) (command pause))
  (setq run (entlen (entlast)))
  (initget 1)
  (setq slope (getreal "\nEnter slope (in percentage): "))
  (initget 1)
  (setq ang (Radian->Degrees (getangle "\nPick text angle: ")))
  (prompt "\nSelect insertion point of slope text: ")
  (if (> (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))) 0)
    (command "_text" "j" "bc" pause ang (strcat (rtos slope 2 2) "%"))
    (command "_text"
        "j"
        "bc"
        pause
        ""
        ang
        (strcat (rtos slope 2 2) "%")
    )
  )
  (setq conv (/ slope 100))
  (setq end_elev (+ (* conv run) elev))
(setq ang (Radian->Degrees (getangle "\nPick text angle: ")))
  (prompt "\nSelect insertion point of Elev: ")
  (if (> (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))) 0)
    (command "_text" "j" "Tc" pause ang (strcat (rtos end_elev 2 2)))
    (command "_text"
        "j"
        "Tc"
        pause
        ""
        ang
        (strcat (rtos end_elev 2 2))
    )
  )
  (setvar "CMDECHO" usercmd)
  (setvar "osmode" oldsnap)
  (princ)
)
(prompt "nInvert Loaded, enter INV to run.")
(princ)

SMadsen

  • Guest
Re: Merging two routines
« Reply #1 on: October 04, 2005, 04:48:33 AM »
I believe you meant to say, "I have a routine that does [this and this] and a routine that does [that and that]. The problem is I want [this and this] to do [that and that] by doing [this and that]. How do I ..... ?"

whdjr

  • Guest
Re: Merging two routines
« Reply #2 on: October 04, 2005, 07:40:30 AM »
 :lmao: :lmao:

bman

  • Guest
Re: Merging two routines
« Reply #3 on: October 04, 2005, 07:52:23 AM »
Ok...let me see if I can better explain. The INV routine calculates & labels an invert based on user slope & the DTBL_SIMPLEX60 routine sets the current text style & issues the Dtext command. I'm trying to incorporate a portion of the DTBL_SIMPLEX60 routine that sets the current style into the INV routine prior to labeling the invert/ slope. Where do I issue the style command within the iNV routine?

bman

  • Guest
Re: Merging two routines
« Reply #4 on: October 04, 2005, 08:02:47 AM »
Nevermind...i forgot to add the TXTHT local variable

Code: [Select]
(defun c:inv (/ elev run slope ang end_elev conv oldsnap clay txtht)
(command "-style"
"simplex0" ; name of text style
"simplex" ; font name
"0" ; height of text
"1" ; width factor
"0" ; obliquing angle
"" ; text backwards
"" ; text upside-down
)
(while (> (getvar "CMDACTIVE") 0)(command "")) ; Vertical
(setq txtht (* 0.08 (getvar "dimscale")))
(setvar "textsize" txtht)
(defun get_num (/ num elst ent)
    (while
      (not (cond ((setq   num
          (getreal
            "\n*** Enter a starting elevation: <Enter to pick text>"
          )
        )
        num
       )
       ((setq   ent
          (entsel
            "\n>>--> Select starting elevation: <Enter to type number>"
          )
        )
        (setq elst (entget (car ent)))
        (if (wcmatch (cdr (assoc 0 elst)) "*TEXT")
          (if   (> (setq num (atof (cdr (assoc 1 elst)))) 0)
            num
          )
        )
       )
      )
      )
    )
    num
  )
  ;;;
  (defun getx (object prop)
    (if   (= (type object) 'ename)
      (setq object (vlax-ename->vla-object object))
    )
    (vlax-get object prop)
  )
  ;;;
  (defun entlen   (obj)
    (if   (= (type obj) 'ename)
      (setq obj (vlax-ename->vla-object obj))
    )
    (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj))
  )
  ;;;
  (defun Radian->Degrees (nbrOfRadians) (* 180.0 (/ nbrOfRadians pi)))
  ;;;
  (setq usercmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq oldsnap (getvar "osmode"))
  (setq clay (getvar "clayer"))
  (setq elev (get_num))
  (prompt "\nSelect point: ")
  (setvar "osmode" 0)
  (setvar "osmode" 545)
  (command "_.pline")
  (while (> (getvar "cmdactive") 0) (command pause))
  (setq run (entlen (entlast)))
  (initget 1)
  (setq slope (getreal "\nEnter slope (in percentage): "))
  (initget 1)
  (setq ang (Radian->Degrees (getangle "\nPick text angle: ")))
  (prompt "\nSelect insertion point of slope text: ")
  (if (> (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))) 0)
    (command "_text" "j" "bc" pause ang (strcat (rtos slope 2 2) "%"))
    (command "_text"
        "j"
        "bc"
        pause
        ""
        ang
        (strcat (rtos slope 2 2) "%")
    )
  )
  (setq conv (/ slope 100))
  (setq end_elev (+ (* conv run) elev))
(setq ang (Radian->Degrees (getangle "\nPick text angle: ")))
  (prompt "\nSelect insertion point of Elev: ")
  (if (> (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))) 0)
    (command "_text" "j" "Tc" pause ang (strcat (rtos end_elev 2 2)))
    (command "_text"
        "j"
        "Tc"
        pause
        ""
        ang
        (strcat (rtos end_elev 2 2))
    )
  )
  (setvar "CMDECHO" usercmd)
  (setvar "osmode" oldsnap)
  (princ)
)
(prompt "nInvert Loaded, enter INV to run.")
(princ)