CivilTechSource Posted 19 hours ago Posted 19 hours ago Hi I found this Forward Visibility Lips online but it was drawing the forward vis line slightly wrong so I have modified it now. It works okay, but when I was debugging it at the end of the routine it would through an error message (See image). The lisp however does complete everything as required apart from setting Layer 0 at the end. I am looking to address that error. (vl-load-com) (defun C:CTS-ForwardVis () ;Set the Layer for the New Polylines (if (not (tblsearch "LAYER" "CTS-Forward Visibility")) (command "-LAYER" "_M" "CTS-Forward Visibility" "_C" "True" "255,100,0" "CTS-Forward Visibility" "" "")) (command "clayer" "" "CTS-Forward Visibility" "") ; Predefined variables (setq ForwardVisDistance 15.0) ; Default forward visibility distance (setq inc 2.0) ; Default increment/resolution ; Prompt user to accept/change defaults (initget "Yes No") (if (= (getkword (strcat "\nUse default settings? [Yes/No] <Yes>: ")) "No") (progn (setq ForwardVisDistance (getdist (strcat "\nEnter default visibility distance <" (rtos ForwardVisDistance 2 2) ">: "))) (setq inc (getdist (strcat "\nEnter default increment/resolution <" (rtos inc 2 2) ">: "))) ) ) (princ (strcat"\nSelect Polyline:")) (while (not (setq js (ssget "_+.:E:S" (list (cons 0 "*POLYLINE,ARC,SPLINE") (cons 67 (if (eq (getvar "CVPORT") 2) 0 1)) (cons 410 (if (eq (getvar "CVPORT") 2) "Model" (getvar "CTAB"))) (cons -4 "<NOT") (cons -4 "&") (cons 70 112) (cons -4 "NOT>") ) ) ) ) ) ;----- Assign the Selected Polyline to a VLA-Object and get its Length and other properties (setq SelPline (vlax-ename->vla-object (ssname js 0)) SelPline_Length (vlax-curve-getDistAtParam SelPline (vlax-curve-getEndParam SelPline)) Counter 0.0 SPoint nil EPoint nil ) ;----- Check Forward Visi Distance and Increment against the Length of the Selected Polyline (while (>= ForwardVisDistance SelPline_Length) (if (>= ForwardVisDistance SelPline_Length) (princ "\nDistance execeded length of Selected Polyline")) ) (while (>= inc SelPline_Length) (if (>= inc SelPline_Length) (princ "\nDistance execeded length of Selected Polyline")) ) ;----- Function to create Forward Visibility Polylines (while (< Counter SelPline_Length) (setq EPoint (vlax-curve-getPointAtDist SelPline (+ Counter ForwardVisDistance))) (setq SPoint (vlax-curve-getPointAtDist SelPline Counter)) (entmake (append '( (0 . "LWPOLYLINE") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "CTS-Forward Visibility") (62 . 256) (6 . "ByLayer") (370 . -2) (100 . "AcDbPolyline") (90 . 2) ) (list (cons 10 SPoint)) (list (cons 10 EPoint)) '((210 0.0 0.0 1.0)) ) ) (setq SPoint (vlax-curve-getPointAtDist SelPline (+ Counter inc))) (setq Counter (+ Counter inc)) ) (command "clayer" "" "0" "") ) Thank you!! Quote
Steven P Posted 18 hours ago Posted 18 hours ago Sounds like on the last run through the while loop SPoint is having an error... if you look at (setq SPoint (vlax-curve-getPointAtDist SelPline (+ Counter inc))) - do you need this line since at the start of the next loop you are setting SPoint again and before it is used. 1 Quote
GLAVCVS Posted 16 hours ago Posted 16 hours ago Hi Like @Stevenp, I can't verify exactly what this is about either: I'm not in front of a PC. But it looks like the last SPoint is 'nil' because '(+ Counter ForwardVisDistance)' is a number greater than the length of 'selPline'. There are a few lines of code that are unnecessary, but they don't prevent your routine from working, so just try changing (while (< Counter SelPline_Length) to (while (and (setq EPoint (vlax-curve-getPointAtDist SelPline (+ Counter ForwardVisDistance))) (setq SPoint (vlax-curve-getPointAtDist SelPline Counter))) It looks like you used AI to do this, but you should still be able to remove the excess code after making these changes. 1 1 Quote
BIGAL Posted 11 hours ago Posted 11 hours ago Ignoring the code for the moment, "Civil Site Design" has check site lines and it checks against the terrain model and the vertical alignment, not just a 2D answer. Looks at the drivers eye height and target height which is part of the check for us here in AUS. 1 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.