PDA

View Full Version : Is there a way to trim using Lisp?


boesiii
2006-02-17, 01:44 AM
I have a routine that places text along a polyline at a specified distance for utilities, such as waterlines and gaslines. I would like to trim the line around the text. Is there a way to do this. I am having trouble with it.




(defun rtd (a)
(* (/ a pi) 180.0)
)

(defun dtr (a)
(* (/ a 180.0) pi)
)


(defun c:annotate_utility (/ u_line)
(setq c_osmode (getvar "osmode"))
(setvar "osmode" 0)
(setq u_line (car (entsel "\nSelect Line or Polyline to be Stationed: ")))
(setq u_text (getstring "\nEnter Text (ex: W = Waterline): "))
(setq u_text_dist 25)
(vl-load-com)
(vlax-ename->vla-object u_line)
(setq total_length (vlax-curve-getDistAtPoint u_line (vlax-curve-getEndPoint u_line)))
(setq total_dist u_text_dist)

(while (<= total_dist total_length)
(progn
(setq u_point (vlax-curve-getPointAtDist u_line total_dist))
(setq u_point2 (vlax-curve-getPointAtDist u_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 u_text)
;(command "trim" "l" "" "f" u_point3 u_point4 "" "")
(setq total_dist (+ total_dist u_text_dist))
);progn
);while
(princ "\n******Utiltiy Anno Worked*******")
(princ)
)

[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]

Mike.Perry
2006-02-17, 02:02 PM
I have a routine that places text along a polyline at a specified distance for utilities, such as waterlines and gaslines. I would like to trim the line around the text. Is there a way to do this. I am having trouble with it. Sorry, I haven't added code to it yet.Hi

Suggestion...

Would it not be better to place a Text Object with a TextMask ( Wipeout ) associated with it. Such an approach would eliminate the need to break the Polyline into two separate Ployline Objects.

Just a thought.

Have a good one, Mike

boesiii
2006-02-17, 03:53 PM
I would prefer not use wipeout because some of the PM's complain about not seeing all the background information due to masking.

peter
2006-02-17, 04:57 PM
There is a method called boundingbox that can give you the outline of the text and the intersectwith method to get the intersection of your polyline and the outline of the text object.

Although this is not what this program does, it does demonstrate using the bounding box and intersect with method.


(defun C:BOUNDBOX (/ objItem safPoint1 safPoint2)
(setq objItem (vlax-ename->vla-object (car (entsel "\nSelect block: "))))
(vla-getboundingbox objItem 'safPoint1 'safPoint2)
(vl-cmdf "rectang" (vlax-safearray->list PT1)(vlax-safearray->list PT2))
)

(defun C:INTERSECT ()
(setq obj1 (vlax-EName->vla-Object (car (entsel "\nSelect object #1: ")))
obj2 (vlax-EName->vla-Object (car (entsel "\nSelect object #2: ")))
)
(vlax-Invoke obj1 "IntersectWith" obj2 acExtendNone)
)

kennet.sjoberg
2006-02-17, 05:55 PM
You can also use break like this

(setq Spoint (vlax-curve-getPointAtDist u_line (- total_dist 2.5 )) )
(setq Epoint (vlax-curve-getPointAtDist u_line (+ total_dist 2.5 )) )
(command "._break" u_line Spoint Epoint )
but when you break ( or trim )
one object turns in to 2 . . . and 3 . . and . . .
Who is then the "u_line" ? the one you want to measure or modify ?

: ) Happy Computing !

kennet

rad.77676
2006-02-17, 10:35 PM
My 2 cents:
Is there a specific reason you don't just use complex linetypes?
Rob

boesiii
2006-02-17, 11:11 PM
I use custom linetypes but I would like to have another way to annotate utility lines.