- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
All,
I'm currently trying to write a LISP function that does the following:
-prompts user to select a Feature Line
-prompts user to select a starting and ending point along that Feature Line
-prompts the user to enter a keyword determining which calculation formula to use (from a list of four, based on the TR-55 Hydrology manual)
-calculates the flow time based on the above
-returns the segment length, segment slope, and flow time at the Command Line
I've written up some code (see below) and get an error: too few arguments. Can someone take a look and see what I'm doing wrong? I'm not a good programmer so apologies in advance...
*ninja edit: the original problem (too few arguments) was because I foolishly didn't specify for the user to actually select a point. Added (getpoint) to the vlax-curve-getclosestpointto lines.
Now however I'm getting an error "no function definition: get2ddistancebetweenpoints. I know this is function exists, but I must be calling it wrong. Any help?
(defun c:conctime ( / sel obj compoint1 compoint2 seglen z1 z2 slope ftype segtime rdlen rdslope rdtime)
(vl-load-com)
(princ "\nSelect Feature Line: ")
(setq sel (ssget "+.:s" '((0 . "AECC_FEATURE_LINE"))))
(if sel
(progn
(setq obj (vlax-ename->vla-object (ssname sel 0)))
(princ "\nSelect Start Point: ")
(setq compoint1 (vlax-curve-getClosestPointTo obj))
(princ "\nSelect End Point: ")
(setq compoint2 (vlax-curve-getClosestPointTo obj))
(setq seglen (vlax-curve-get2dDistanceBetweenPoints compoint1 compoint2))
(setq z1 (caddr compoint1))
(setq z2 (caddr compoint2))
(setq slope (abs (/ (- z1 z2) seglen)))
(initget 1 "Sheet Unpaved Paved Channel")
(setq ftype (getkword " [Sheet/Unpaved/Paved/Channel]: "))
(cond ((= ftype "Sheet")
(setq segtime (* 60 (/ (* 0.007 (expt (* 0.3 seglen) 0.8)) (* 1.8276 (expt slope 0.4)))))
)
((= ftype "Unpaved")
(setq segtime (/ seglen (* 60 (* 16.1345 (expt slope 0.5)))))
)
((= ftype "Paved")
(setq segtime (/ seglen (* 60 (* 20.3282 (expt slope 0.5)))))
)
((=ftype "Channel")
(setq segtime (/ seglen 360))
)
)
(setq rdlen (rtos seglen 2 2))
(setq rdslope (rtos slope 2 2))
(setq rdtime (rtos segtime 2 2))
(princ rdlen)
(terpri)
(princ rdslope)
(terpri)
(princ rdtime)
(princ)
)
)
)
Solved! Go to Solution.