boesiii
2006-03-01, 10:12 PM
The program asks the user for the polyline, type of utility and size. Then it annotates the line with the symbol and size, it also trims out the line inside the symbol.
Problems I am having:
1. If the polyline is not inside the screen area it won't work.
2. It does not go through the entire program (sometimes), it will get hung up on a line of code at the end. Acad says there is an "error 2d/3d point nil",
(defun rtd (a)
(* (/ a pi) 180.0)
)
(defun dtr (a)
(* (/ a 180.0) pi)
)
(defun c:annotate_utility (/ utility_line utility_text utility_size scale_factor test_st utility_text_spacing
total_dist u_point u_point2 u_point3 u_point4 u_point5 u_point6 u_point7 u_point8
block_sel c_osmode c_blipmode c_cmdecho)
(setq c_osmode (getvar "osmode"))
(setq c_blipmode (getvar "blipmode"))
(setq c_cmdecho (getvar "cmdecho"))
(setq c_layer (getvar "clayer"))
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(setvar "osmode" 0)
(setq block_sel (ssadd))
(alert "This Command is based on LTSCALE")
(setq utility_line (car (entsel "\nSelect Line or Polyline to be Stationed: ")))
(ssadd utility_line block_sel)
(setq utility_text (strcase (getstring T "\nEnter Text (ex: W = Waterline): ")))
; (if (= utility_text "W")
; (progn
; (if (not (tblsearch "layer" "C-WATR"))
; (command "-layer" "m" "C-WATR" "c" "130" "" ""))
; (command "clayer" "C-WATR")))
(setq utility_size (getstring T "\nEnter Size of Utility: "))
(setq scale_factor (* (getvar "ltscale") 2))
(setq text_st (strcat "L60RS " (rtos scale_factor 2 0)))
(if (not (tblsearch "style" text_st))
(progn
(command "-style" text_st "romans" (* 0.06 scale_factor) "1"
"20" "n" "n" "n"))
(setvar "textstyle" text_st)
)
(setq utility_text_spacing (* scale_factor 0.75))
(vl-load-com)
(vlax-ename->vla-object utility_line)
(setq total_length (vlax-curve-getDistAtPoint utility_line (vlax-curve-getEndPoint utility_line)))
(setq total_dist utility_text_spacing)
(setq u_point (vlax-curve-getPointAtDist utility_line total_dist))
(setq u_point2 (vlax-curve-getPointAtDist utility_line (+ 0.001 total_dist)))
(setq u_ang (rtd (angle u_point u_point2)))
(setq u_point3 (polar u_point (+ u_ang (dtr 90)) 1))
(setq u_point4 (polar u_point (+ u_ang (dtr 270)) 1))
(command "text" "j" "mc" u_point u_ang utility_text)
(ssadd (entlast) block_sel)
(command "trim" "l" "" "f" u_point3 u_point4 "" "")
(ssadd (entlast) block_sel)
(setq size_counter 1)
(setq total_dist (+ total_dist utility_text_spacing))
(while (< total_dist (- total_length 45))
(progn
(princ (strcat "-----" (rtos total_dist 2 1) "---" (rtos total_length 2 1) "----" ))
(setq utility_line2 (entlast))
(vlax-ename->vla-object utility_line2)
(setq u_point5 (vlax-curve-getPointAtDist utility_line2 utility_text_spacing))
(setq u_point6 (vlax-curve-getPointAtDist utility_line2 (+ 0.001 utility_text_spacing)))
;;;;;-----I think this is were it hangs up--------------------
(setq u_ang2 (rtd (angle u_point5 u_point6)))
(setq u_point7 (polar u_point5 (+ u_ang2 (dtr 90)) 1))
(setq u_point8 (polar u_point5 (+ u_ang2 (dtr 270)) 1))
(if (= size_counter 2)
(progn (command "text" "j" "mc" u_point5 u_ang2 utility_size)))
(if (/= size_counter 2)
(progn (command "text" "j" "mc" u_point5 u_ang2 utility_text)))
(command "trim" "l" "" "f" u_point7 u_point8 "" "")
(setq total_dist (+ total_dist utility_text_spacing))
(setq size_counter (1+ size_counter))
(if (= size_counter 5) (setq size_counter 1))
))
;(setq block_name (getvar "date"))
;(command "._-block" block_name "0,0,0" block_sel "" )
;(command "._-insert" block_name "0,0,0" "" "" "" )
(setvar "osmode" c_osmode)
(setvar "blipmode" c_blipmode)
(setvar "cmdecho" c_cmdecho)
(princ "\n******Utiltiy Anno Worked*******")
(princ)
)
Problems I am having:
1. If the polyline is not inside the screen area it won't work.
2. It does not go through the entire program (sometimes), it will get hung up on a line of code at the end. Acad says there is an "error 2d/3d point nil",
(defun rtd (a)
(* (/ a pi) 180.0)
)
(defun dtr (a)
(* (/ a 180.0) pi)
)
(defun c:annotate_utility (/ utility_line utility_text utility_size scale_factor test_st utility_text_spacing
total_dist u_point u_point2 u_point3 u_point4 u_point5 u_point6 u_point7 u_point8
block_sel c_osmode c_blipmode c_cmdecho)
(setq c_osmode (getvar "osmode"))
(setq c_blipmode (getvar "blipmode"))
(setq c_cmdecho (getvar "cmdecho"))
(setq c_layer (getvar "clayer"))
(setvar "cmdecho" 0)
(setvar "blipmode" 0)
(setvar "osmode" 0)
(setq block_sel (ssadd))
(alert "This Command is based on LTSCALE")
(setq utility_line (car (entsel "\nSelect Line or Polyline to be Stationed: ")))
(ssadd utility_line block_sel)
(setq utility_text (strcase (getstring T "\nEnter Text (ex: W = Waterline): ")))
; (if (= utility_text "W")
; (progn
; (if (not (tblsearch "layer" "C-WATR"))
; (command "-layer" "m" "C-WATR" "c" "130" "" ""))
; (command "clayer" "C-WATR")))
(setq utility_size (getstring T "\nEnter Size of Utility: "))
(setq scale_factor (* (getvar "ltscale") 2))
(setq text_st (strcat "L60RS " (rtos scale_factor 2 0)))
(if (not (tblsearch "style" text_st))
(progn
(command "-style" text_st "romans" (* 0.06 scale_factor) "1"
"20" "n" "n" "n"))
(setvar "textstyle" text_st)
)
(setq utility_text_spacing (* scale_factor 0.75))
(vl-load-com)
(vlax-ename->vla-object utility_line)
(setq total_length (vlax-curve-getDistAtPoint utility_line (vlax-curve-getEndPoint utility_line)))
(setq total_dist utility_text_spacing)
(setq u_point (vlax-curve-getPointAtDist utility_line total_dist))
(setq u_point2 (vlax-curve-getPointAtDist utility_line (+ 0.001 total_dist)))
(setq u_ang (rtd (angle u_point u_point2)))
(setq u_point3 (polar u_point (+ u_ang (dtr 90)) 1))
(setq u_point4 (polar u_point (+ u_ang (dtr 270)) 1))
(command "text" "j" "mc" u_point u_ang utility_text)
(ssadd (entlast) block_sel)
(command "trim" "l" "" "f" u_point3 u_point4 "" "")
(ssadd (entlast) block_sel)
(setq size_counter 1)
(setq total_dist (+ total_dist utility_text_spacing))
(while (< total_dist (- total_length 45))
(progn
(princ (strcat "-----" (rtos total_dist 2 1) "---" (rtos total_length 2 1) "----" ))
(setq utility_line2 (entlast))
(vlax-ename->vla-object utility_line2)
(setq u_point5 (vlax-curve-getPointAtDist utility_line2 utility_text_spacing))
(setq u_point6 (vlax-curve-getPointAtDist utility_line2 (+ 0.001 utility_text_spacing)))
;;;;;-----I think this is were it hangs up--------------------
(setq u_ang2 (rtd (angle u_point5 u_point6)))
(setq u_point7 (polar u_point5 (+ u_ang2 (dtr 90)) 1))
(setq u_point8 (polar u_point5 (+ u_ang2 (dtr 270)) 1))
(if (= size_counter 2)
(progn (command "text" "j" "mc" u_point5 u_ang2 utility_size)))
(if (/= size_counter 2)
(progn (command "text" "j" "mc" u_point5 u_ang2 utility_text)))
(command "trim" "l" "" "f" u_point7 u_point8 "" "")
(setq total_dist (+ total_dist utility_text_spacing))
(setq size_counter (1+ size_counter))
(if (= size_counter 5) (setq size_counter 1))
))
;(setq block_name (getvar "date"))
;(command "._-block" block_name "0,0,0" block_sel "" )
;(command "._-insert" block_name "0,0,0" "" "" "" )
(setvar "osmode" c_osmode)
(setvar "blipmode" c_blipmode)
(setvar "cmdecho" c_cmdecho)
(princ "\n******Utiltiy Anno Worked*******")
(princ)
)