HELP PLEASE!!!

HELP PLEASE!!!

Anonymous
Not applicable
1,054 Views
3 Replies
Message 1 of 4

HELP PLEASE!!!

Anonymous
Not applicable

Probably the easiest thing ever. Right now I have this LISP that measures a pline from vertex to vertex and creates a Mtext with the measurement next to each segment. My problem is that right now it is showing the numbers as i.e. 250 and I need it to show it as i.e. 250' because it is a measurement in feet so I am just missing the " ' " .

Thank you for the help.

here is the lisp:

 

(vl-load-com)
(defun c:IS ( / js htx AcDoc Space nw_style n obj ename pr dist_start dist_end pt_start pt_end seg_len alpha nw_obj)
(princ "\nSelect polylines.")
(while
(null
(setq js
(ssget
'(
(0 . "*POLYLINE")
(-4 . "<NOT")
(-4 . "&") (70 . 112)
(-4 . "NOT>")
)
)
)
)
(princ "\nSelect is empty, or isn't POLYLINE!")
)
(initget 6)
(setq htx (getdist (getvar "VIEWCTR") (strcat "\nSpecify height text <" (rtos (getvar "TEXTSIZE")) ">: ")))
(if htx (setvar "TEXTSIZE" htx))
(setq
AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))
Space
(if (= 1 (getvar "CVPORT"))
(vla-get-PaperSpace AcDoc)
(vla-get-ModelSpace AcDoc)
)
)
(cond
((null (tblsearch "LAYER" "POLE"))
(vlax-put (vla-add (vla-get-layers AcDoc) "POLE") 'color 255)
)
)
(cond
((null (tblsearch "STYLE" "TIMES NEW ROMAN"))
(setq nw_style (vla-add (vla-get-textstyles AcDoc) "TIMES NEW ROMAN"))
(mapcar
'(lambda (pr val)
(vlax-put nw_style pr val)
)
(list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag)
(list "romand.shx" 2.5 (/ (* 15.0 pi) 180) 1.0 0.0)
)
)
)
(repeat (setq n (sslength js))
(setq
obj (ssname js (setq n (1- n)))
ename (vlax-ename->vla-object obj)
pr -1
)
(repeat (fix (vlax-curve-getEndParam ename))
(setq
dist_start (vlax-curve-GetDistAtParam ename (setq pr (1+ pr)))
dist_end (vlax-curve-GetDistAtParam ename (1+ pr))
pt_start (vlax-curve-GetPointAtParam ename pr)
pt_end (vlax-curve-GetPointAtParam ename (1+ pr))
seg_len (- dist_end dist_start)
alpha (angle (trans pt_start 0 1) (trans pt_end 0 1))
)
(setq nw_obj
(vla-addMtext Space
(vlax-3d-point (setq pt (polar (vlax-curve-GetPointAtParam ename (+ 0.5 pr)) (+ alpha (* pi 0.5)) (getvar "TEXTSIZE"))))
0.0
(rtos seg_len 2 0)
)
)
(mapcar
'(lambda (pr val)
(vlax-put nw_obj pr val)
)
(list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'StyleName 'Layer 'Rotation)
(list 8 (getvar "TEXTSIZE") 5 pt "TIMES NEW ROMAN" "POLE" alpha)
)
)
)
(prin1)
)

0 Likes
Accepted solutions (1)
1,055 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution
(rtos seg_len 2 0)
->
(strcat (rtos seg_len 2 0) "'")
Message 3 of 4

Anonymous
Not applicable

Thank you for the quick reply BeekeeCZ!!!!!!!

0 Likes
Message 4 of 4

Kent1Cooper
Consultant
Consultant

Another thing you can do is to use something like DIMPOLY.lsp, available >here< [there are others out there, too].  It has some advantages, mainly that the numbers are Dimension text, so for line segments at least, if you Stretch the Polyline somehow, the length values and their rotations will update automatically.  [But depending on the situation, you will sometimes need to adjust the position relative to the Polyline edge.]  It uses the current Dimension Style, so you would need one set up for it, with an appropriate Text size and rounding value, and with both extension lines and both dimension lines suppressed to get the text-only look, but you can make your foot mark part of that as a Suffix, so there's no need to add it by force with (strcat).  See other comments at the top of the file, and in that thread.

Kent Cooper, AIA
0 Likes