Author Topic: Easy Mathmactics.  (Read 3606 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Easy Mathmactics.
« on: February 06, 2006, 07:53:09 AM »
I have a stupid question. Is there a way to do the following:

You have a dialop box or something ( You put in a number. Ex. 800.00 )
Then you put in other numbers which subtract from the 800.00 number.
and then it places it in a MTEXT in the dwg.

heres what it might look like

Insert the No. = 800.00
Insert value 1 = 5.00
Insert value 2 = 6.00
Insert Value 3 = 4.00
etc.

Then it places the calced values into a mtext in the dwgs. then attach a leader to what is pointing too.

So the end result looks like this:

T.C. = 800.00 --------------------------> (LEADER)
INV 1 = 755.00
INV 2 = 754.00
INV 3 = 756.00



Thats it!

Thanks for the advise and help
Civil3D 2020

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Easy Mathmactics.
« Reply #1 on: February 06, 2006, 09:06:55 AM »
wHAT ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Easy Mathmactics.
« Reply #2 on: February 06, 2006, 09:27:14 AM »
Well  I am looking for something to do the calculations and place it into a block or a mtext. Rather than taking a number subtracting it and then retypeing it into a mtext for labeling.

we do this so we can give the measures of depths of structures on our surveys... plus it would save lots of time when you do this.

I hope that clears some things up..

thxs
Civil3D 2020

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Easy Mathmactics.
« Reply #3 on: February 06, 2006, 10:00:13 AM »
There is probably a dozen ways to do this .

You could probably do something esoteric like this so that the value is on the ClipBoard .. and can be pasted anywhere ie Ctrl V in the Leader Mtext editor..

.. could then be used for Edits too ..
Code: [Select]
(defun C:toCB (/)
  (setq val (getreal "\nBase STARTING Value "))
  (while (setq subtract (getreal "\nValue to subtract ")) (setq val (- val subtract)))
  (dos_clipboard (rtos val))
)

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Easy Mathmactics.
« Reply #4 on: February 06, 2006, 11:49:36 AM »
For dos_clipboard in Kerry's example code you might need DOSLib
TheSwamp.org  (serving the CAD community since 2003)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Easy Mathmactics.
« Reply #5 on: February 06, 2006, 12:04:52 PM »
Maybe something like
Code: [Select]
(defun c:InverseLeader (/ BaseNum Str cnt tmpNum)

(if (setq BaseNum (getdist "\n Base height: "))
 (progn
  (setq Str (strcat "T.C. = " (rtos BaseNum 2 3)))
  (setq cnt 1)
  (while (setq tmpNum (getdist (strcat "\n Inverse " (itoa cnt) " amount: ")))
   (setq Str (strcat Str "\\PINV " (itoa cnt) " = " (rtos (- BaseNum tmpNum) 2 3)))
   (setq cnt (1+ cnt))
  )
  (command "_.leader" pause pause "" Str "")
 )
)
(princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Easy Mathmactics.
« Reply #6 on: February 06, 2006, 12:18:09 PM »
This is thrown together form parts of other routines.
It worked for me but No guaranties.
Could use more error checking & lots of cleanup. :)

PS, I like Tim's routine, but I'll post mine anyway.

Code: [Select]
;;  CAB  02/06/06

;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;;     L e a d e r   R o u t i n e       
;;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

(defun c:elevled (/ p1 p2 p3 txtent)
  ;; error function & Routine Exit
  (defun *error* (msg)
    (if
      (not
        (member
            msg
           '("console break" "Function cancelled" "quit / exit abort" "")
        )
      )
       (princ (strcat "\nError: " msg))
    ) ; endif
    ;;reset all variables here
    (and tmpline (entdel tmpline))
    (and usrorm (setvar "orthomode" usrorm))
    (and useros (setvar "osmode" useros))
    (and usercmd (setvar "CMDECHO" usercmd))
    (setq usrorm nil
          useros nil
          usercmd nil
          tmpline nil)
  ) ;end error function


  (vl-load-com)
  (setq usercmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq usrorm (getvar "orthomode"))
  (setvar "orthomode" 0)
  (if (and (setq p1 (getpoint "\nPick start point of leader."))
           (setq useros (getvar "osmode"))
           (setvar "osmode" 0)
           (setq p2 (getpoint p1 "\nPick next point of leader.")))
      (progn
(command ".line" p1 p2 "")
        (setq tmpline (entlast))
(setvar "orthomode" 1)
(setq p3 (getpoint p2 "\nPick end of leader."))
(entdel tmpline) ; delete line
        (setq tmpline nil)
        (setq txtent (Get_Elev (if p3 p3 p2)))
        (if txtent ;  create leader
            (Makeldr p1 p2 p3 (entlast))
        )
      )
  )

  (*error* "")   
  (princ)
)
(princ)

(defun makeldr (p1 p2 p3 txt / coords1 coords2 ldr1 ldr2 space)
  (vl-load-com)
  (setq txt (vlax-ename->vla-object txt))
  (setq coords1 (append p1 p2))
  (if p3
    (setq coords1 (append coords1 p3))
  )
  (setq space (vla-objectidtoobject
                (vla-get-activedocument
                  (vlax-get-acad-object)
                )
                (vla-get-ownerid txt)
              )
  )
  (setq ldr1 (vlax-invoke space "addleader" coords1 txt aclinewitharrow))
  (vla-put-verticaltextposition ldr1 0)
  (princ)
)


(defun Get_elev (pt / txt cnt elev val)
  (or *base* (setq *base* 100.0))
  (setq val (getdist (strcat "\nEnter *base* Elevation: <" (rtos *base* 2 2) ">")))
  (setq *base* (if val val *base*)
        txt (strcat "T.C.  = " (rtos *base* 2 2) "\\P")
        cnt 1)
  (While (setq elev (getdist "\nEnter Offset to *base* Elevation:"))
    (setq txt  (strcat txt "INV " (itoa cnt) " = " (rtos (- *base* elev) 2 2)"\\P")
          cnt (1+ cnt)
    )
  )
  (entmake (list
   '(0 . "MTEXT")
   '(100 . "AcDbEntity")
   '(100 . "AcDbMText")
   (cons 10 pt) ; insert point
   (cons 7 (getvar "TextStyle")) ; Current Style
   (cons 40 (getvar "TextSize")) ; Current height
   (cons 41 0)  ; 0 Width = no wrap
   (cons 71 1)  ; 1=Top Left Attachment point
                   (cons 1 txt) ; Text String
)
        )
)


(princ);  load quietly
« Last Edit: February 06, 2006, 01:22:24 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Easy Mathmactics.
« Reply #7 on: February 06, 2006, 12:26:53 PM »
Quote
You have a dialop box or something ( You put in a number. Ex. 800.00 )
Then you put in other numbers which subtract from the 800.00 number.
and then it places it in a MTEXT in the dwg.

I definitely need to learn to read questions differently.  :-)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Easy Mathmactics.
« Reply #8 on: February 06, 2006, 12:30:47 PM »
Quote
You have a dialop box or something ( You put in a number. Ex. 800.00 )
Then you put in other numbers which subtract from the 800.00 number.
and then it places it in a MTEXT in the dwg.

I thought the "something" gave full licence to any solution. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Easy Mathmactics.
« Reply #9 on: February 06, 2006, 01:14:36 PM »
VERRY CLOSE CAB!!!!

the values and everything work. i guess the only thing missing is it takeing the inv measurements and it automatically subtracts the value from the tc and places that value in the mtext.

Nice!
Civil3D 2020

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Easy Mathmactics.
« Reply #10 on: February 06, 2006, 01:23:12 PM »
OK I changed it.
But I think Tim's works as well.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

t-bear

  • Guest
Re: Easy Mathmactics.
« Reply #11 on: February 06, 2006, 01:35:35 PM »
Tims works a treat too....

BTW...

800-5=795..not 755
800-6=794..not 754
800-4=796..not 756

...had me going there...............

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Easy Mathmactics.
« Reply #12 on: February 06, 2006, 02:01:28 PM »
THANKS GUYS!
Civil3D 2020

CADaver

  • Guest
Re: Easy Mathmactics.
« Reply #13 on: February 16, 2006, 11:40:50 PM »
Check This thread, be sure to go all the way down to CAB's tweaked function.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Easy Mathmactics.
« Reply #14 on: February 17, 2006, 08:19:37 AM »
Wow, had forgotten all about that routine. Old age I guess.
That's my story & I'm sticken to it. :)

Direct Link
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.