Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

lisp routines made for civil now need for architecture

1 REPLY 1
Reply
Message 1 of 2
Anonymous
681 Views, 1 Reply

lisp routines made for civil now need for architecture

So this is my dilema, I used to work at a civil engineering firm where i wrote several lisp programs for doing grading. Most of which would calculate elevations in feet and/or slope in percent grade.  for example i have a program that has you pick 2 points in the drawing with z values and it labels the percent grade betwen them and asks for a new point and it creates a point at the calculated slope and labels the new point elevation. so now i work at an architecture firm where we draw everything in inches. Is there a slick way i can modify my programs to output the correct elevations and grade percentages. it currently spits out elevations 12 times what they are and the slopes are correct but not as percent grade. I realize that i could try and modify the code so that it multiplies or divides by twelve for certain variables, but i am wondering if there is a better way about it.  here is one of the routines i am talking about:

 

;fg4.......Give this program two points and it will calculate the slope between them and
; allow you to pick ADDITIONAL points along this line. Sets Autocad point object at locations picked. By Mike Roberts

(defun C:FG4 (/ ITEM1 ITEM2 xval1 xval2 yval1 yval2 ydist xdist odist el1 el2 eldif answer newtext newy newx newdist eldif1 newcords answer1 newel item3 xval3 yval3 ydist3 xdist3 ztx)

(setq osnapset (getvar "OSMODE"));saves osnap variables
(setvar "OSMODE" 0);turns osnap off for program
(setq precision (getvar "LUPREC"));saves present precision variable
(setvar "LUPREC" 2);sets precision to 2 decimal places for this program

(setq ITEM1 (getpoint "\nSelect the first POINT with a Z: "))
(setq xval1 (car item1));get x of 1st POINT
(setq ITEM2 (getpoint ITEM1 "\nSelect the second POINT with a Z: "))
(setq xval2 (car item2));get x of 2nd POINT
(setq yval1 (cadr item1));y of 1st POINT for future newtext location
(setq yval2 (cadr item2))
(setq Ydist (- Yval1 Yval2))
(setq Xdist (- xval1 xval2))
(setq odist (sqrt (+ (* Xdist Xdist) (* Ydist Ydist))))
(setq el1 (caddr item1))
(setq el2 (caddr item2))
(setq eldif (- el2 el1))
(setq answer (* 100.0 (/ eldif odist)));divide rise by run & multiply by 100
(setq newtext (strcat (rtos answer) "%"))
(princ "\n The grade between the two points is ")
(princ newtext )
(setq newy (/ (+ yval1 yval2) 2.0))
(setq newx (/ (+ xval1 xval2) 2.0))
(setq newcords (list newx newy 0))
(command "text" newcords "" "" newtext)
(initget 64)

(repeat 200
(setq ITEM3 (getpoint item1 "\nCalc new elevation at what point?: "))
(setq xval3 (car item3));get x of 3rd point
(setq yval3 (cadr item3));y of 3rd point for FG location
(setq Ydist3 (- Yval1 Yval3))
(setq Xdist3 (- xval1 xval3))
(setq newdist (sqrt (+ (* Xdist3 Xdist3) (* Ydist3 Ydist3))))

(setq newcords3 (polar item1 (angle item1 item2) newdist))

(setq newx3 (car newcords3));get x of this new POINT
(setq newy3 (cadr newcords3));get y of this new POINT


(setq answer1 (/ answer 100.0))
(setq eldif1 (* answer1 newdist))
(setq newel (+ el1 eldif1))
(setq ztx (rtos newel 2 2))
(setq newcords3 (list newx3 newy3 newel))
(princ "\n The new elevation is ")
(princ ztx)

(command "text" newcords3 "" "" ztx)
(command "point" newcords3)
)
(setvar "LUPREC" precision)
(setvar "OSMODE" osnapset);sets osnap back to the way it was
(PRINC)
)

 

Thanks for any help.  mike

1 REPLY 1
Message 2 of 2
scot-65
in reply to: Anonymous

Try setting LUNITS to 2 since you are in Architectural of 4.

 

The percent slope has no units associated with it - it's simply a ratio

and would not matter what discipline you are working in.

 

???


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost