Calculator that works with mtext
I'm looking for a calculator type utility that will run in AutoCAD to be used to automatically add the findings to mtext.
I would use it when creating metal roof panel drawings. Need to be able to select a line (roof panel) multiply that number (length) by the slope factor and have the answer be able to display as mtext. A calculator type utility would be perfect. Be able to store the slope factor in memory, input the panel length and select an mtext to output the answer. Being able to automatically add a suffix everytime would be a wonderful bonus.
Hoping someone may have heard of something like this. Thanks.
RE: Calculator that works with mtext
"QuickCalc" command in 06+
RE: Calculator that works with mtext
Quickcalc will not work when in mtext; this is currently a wish in the AutoCAD Wish List Forum.
RE: Calculator that works with mtext
Quote:
Originally Posted by prichardson
"QuickCalc" command in 06+
Figures. We're still stuck with '05. Trying to get us upgraded but management....yada yada yada. Thanks for the help.
RE: Calculator that works with mtext
Quote:
Originally Posted by BrenBren
Quickcalc will not work when in mtext; this is currently a wish in the AutoCAD Wish List Forum.
AH! Caught between posts. Hopefully someone will have heard of a lisp or VBA routine that could help me out. Thanks for your input, greatly appreciated.
RE: Calculator that works with mtext
Quote:
Originally Posted by BrenBren
Quickcalc will not work when in mtext; this is currently a wish in the AutoCAD Wish List Forum.
Thanks,
Sorry for the bad info, I didn't realize it didn't work
work with MTEXT. I should have tried first.
RE: Calculator that works with mtext
In your MText are only a number? or the number is part of something bigger?
If it has only The number is easier to program something.
RE: Calculator that works with mtext
Quote:
Originally Posted by intergrupocr
In your MText are only a number? or the number is part of something bigger?
If it has only The number is easier to program something.
We would use it to add mtext for panel lengths. Usually the callouts on the drawings look something like this : 1 @ 24'-6". The suffix is almost always "1 @". To get the 24'-6" number I'd multiply the panel (line) length on the drawing and multiply it by a slope factor (3:12 slope = 1.0308 slope factor, etc). Sometimes I need to add or subtract a few inches to make up for panel hems, setbacks at the ridge or extensions at the eave. For a drawing with several hundred different panel lengths, it's time consuming, monotonous and extremely boring. Anything to speed up the task would be wonderful.
RE: Calculator that works with mtext
Try this code
Code:
(DEFUN C:CALMTEXT (/ myline mymtext mylinedata mydist mytextdata newtext)
(setq myline nil
mymtext nil)
(setq myline (selectObject "LINE" nil))
(if (= nil myline)
(progn ;no Line Selected
(alert "No Line Selected")
)
(progn ;a Line was seected
(setq myLineData (entget myline)) ;get the data for the line
(setq myMtext (selectobject "MTEXT" nil))
(if (= nil myMtext)
(progn ;No Mytext Selected
(alert "No Mytext Selected")
)
(progn ;Mytext was Selected
(if (= nil myslope);if slope not set get slope
(setq myslope (getreal "\nEnter Slope"))
)
(setq mydist (distance (cdr (assoc 10 myLineData))
(cdr (assoc 11 myLineData))))
(setq mydist (* mydist myslope))
(setq mypfix (getstring "\nPrefix String"));get a Prefis string put
(setq mysFix (getstring "\nSuffix String"));Get a suffix string
(setq newText (strcat mypfix (rtos mydist 2 2) mysfix));can change mode or precision
(setq myTextdata (entget mymtext))
(setq mytextdata
(subst (cons 1 newtext)
(assoc 1 mytextdata)
mytextdata))
(entmod mytextdata)
)
)
)
)
)
;;Function Selectobject
;;ObjectType uper case name of Object to Select
;;Exp "LINE" "MTEXT"
;;Alertflag not nil to show alerts
;; nil to show alerts
;;retrun the entityname of the selected entity
;; or nil if no enity Selected
(DEFUN SelectObject (ObjectType AlertFlag / myline myLineData)
(setq myline nil)
(setq myline (car (entsel (strcat "\nSelect a " ObjectType))))
(if (= nil myline)
(progn ;no Object Selected
(if AlertFlag
(alert "No Objec Select"))
)
(progn ;a Object was seected
(setq myLineData (cdr (assoc 0 (entget myline))))
;get the data for the line
(if (/= myLineData ObjectType)
(progn ;Object not a line
(if AlertFlag
(progn
(alert (strcat "You Did Not Select a " ObjectType))
(setq myline nil))
)
)
(progn ;Object was type Objectype
)
)
)
)
(setq myline myline)
)
RE: Calculator that works with mtext
Quote:
Originally Posted by jwanstaett
Try this code
WOW. Very Cool and Groovy! Thanks! I do have a few observations, though.
- Won't let me put a space in the suffix or prefix (1 @ xx'-x")
- Uses decimal units, can this be adjusted to architectural?
- Only allows you to input the slope factor once. The second time it's run, it skips that question. I have multiple slopes on one drawing. If it would ask you again but give you the option of using the last slope number input.
- Is there any way to be able to add or subtract a number from the final output before changing the mtext? (want to add or subtract a couple inches from the final number).
This routine is pretty friggin' cool. Thanks for the help, it's very greatly appreciated!