kitch Posted October 2, 2009 Posted October 2, 2009 I wish to modifiy this lisp function it's to draw a drain.. when i use thins function it asks.. for a scale and DIA size of train... so if i put down 300 it draws 300mm drain to scale... But i with to multiple the 300 by a chosen factor.. so example if i select 300 then i want it to ask me wha ti want to multiply it to.. example 2 then it will draw a 600mm drain... this posible? Lisp function attached thank you so much for your help kitch.LSP Quote
CALCAD Posted October 2, 2009 Posted October 2, 2009 kitch, try this. Besides adding the multiplier, I also removed an extra "" in the TEXT command at the end of the program. Hope this works. This program appears to be a work in progress. The 'reset' function is never called, the variables should be localized and an error trap would be nice. Oh, and 'T' should not be used as an ordinary variable. It should be considered a reserved symbol. ; file kitch.LSP (defun reset () (setvar "cmdecho" 0) (setvar "angbase" angb_org) (setvar "angdir" angd_org) ) (DEFUN C:kitch () (if (= sc nil) (setq sc (getreal "\nWhat is Drawing Scale ?: "))) ;SET SYSTEM VARIABLES (setq angb_org (getvar "angbase")) (setq angd_org (getvar "angdir")) (setvar "angbase" 0) (setvar "angdir" 0) ;SET LAYER (if (not (tblsearch "layer" "PR-SWD")) (command "layer" "m" "PR-SWD" "c" "7" "" "") (command "layer" "s" "PR-SWD" "")) (setq diam (getint "\nEnter Diameter:<300> ")) (if (= diam nil) (setq diam 300)) (setq mf (getreal "\nMultiply by Factor:<1> ")) (if (= mf nil) (setq mf 1.0) ) (setq diam (* diam mf)) (setq txtdia (rtos diam 2 0)) (setq txtdia (strcat txtdia "%%c")) (setq dh (/ diam 2000.0)) (setq pt1 (getpoint "\nFrom : ")) (setq pt2 (getpoint PT1 "\nTo : ")) (command "LINE" pt1 pt2 "u" "") (setq brg1 (angle pt1 pt2)) (setq hpi (/ pi 2)) (setq d12 (distance pt1 pt2)) (setq pt3 (polar pt1 (+ brg1 hpi) dh)) (setq pt4 (polar pt2 (+ brg1 hpi) dh)) (setq pt5 (polar pt1 (- brg1 hpi) dh)) (setq pt6 (polar pt2 (- brg1 hpi) dh)) ; now put pts 3,4,5,6 (command "LINE" pt3 pt4 "") (command "LINE" pt5 pt6 "") ; parallel lines now drawn ; routine to set N as number of pline segments. (setq N (fix (/ d12 3) )) (setq remd (- d12 (* N 3))) (setq a 1) (setq t (/ diam 1000.0)) (setvar "tracewid" diam) (while (<= a N) (command "TRACE" t pt1 (polar pt1 brg1 1.50) "") (setq pt1 (polar pt1 brg1 3.00)) (setq a (+ 1 a)) ) ; endwhile (if (<= 1.50 remd) (command "TRACE" "" pt1 (polar pt1 brg1 1.50) "") (command "TRACE" "" pt1 pt2 "") ) ;PLACE THE TEXT (setq txta brg1) (if (and (> brg1 (/ pi 2))(< brg1 (* pi 1.5))) (setq brg1 ( - brg1 pi))) (setq txta (/ (* brg1 180) pi)) (setq p7 (getpoint "\nPosition of text ?: ")) (setq txth (* 0.0025 sc)) ;(command "text" "m" p7 txth txta txtdia "") - extra "" ? (command "text" "m" p7 txth txta txtdia) ;endif ; done ) Quote
kitch Posted October 4, 2009 Author Posted October 4, 2009 Thank you so much..... it work perfectly you have jsut saved me so much times... Thank you so much... very happy Quote
CALCAD Posted October 4, 2009 Posted October 4, 2009 You're welcome. I'm very glad it's working for you. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.