View Full Version : Line with editable text
engr.azher699528
2015-05-01, 12:42 AM
Hi
I want to create a custom line with pre-defined text in start, middle and end of line as shown in image.
The text should be editable and 3 times per line segment as shown in attachment. Please help...! :?:
http://forums.augi.com/attachment.php?attachmentid=99552&stc=1http://forums.augi.com/attachment.php?attachmentid=99553&stc=1
peter
2015-05-02, 02:48 AM
This appears to be polylines not lines...
It is relatively straight forward using vlax-curve functions to get the length of a polyline (half length) start and end too.
1. What I would do is create the linework.
2. Select the line and enter the three parts of the text.
(The routine would insert and locate the text)
3. Be able to edit the text.
4. Be able to change the length of the line work and have the text move.
5. This could be done with reactors, but is easier with just doing it with command.
P=
peter
2015-05-02, 04:34 PM
A place to start.
P=
(defun C:Line3Text (/ lstSublist objPline strLeft strMiddle strRight)
(vl-cmdf "pline" pause)
(while (= (getvar "cmdactive") 1)(vl-cmdf pause))
(setq objPLine (vlax-ename->vla-object (entlast)))
(setq strLeft "Left") ; (getstring "\nEnter Left Text: " T))
(setq strMiddle "Middle") ; (getstring "\nEnter Middle Text: " T))
(setq strRight "Right") ; (getstring "\nEnter Right Text: " T))
(setq sngTextHeight (getvar "textheight"))
(setq lstSublist (textposition objPline "L"))
(vl-cmdf "text" "j" "ml" (car lstSublist) (getvar "textsize") (* 180 (/ (cadr lstSublist) pi)) strLeft)
(setq lstSublist (textposition objPline "M"))
(vl-cmdf "text" "j" "mc" (car lstSublist) (getvar "textsize") (* 180 (/ (cadr lstSublist) pi)) strMiddle)
(setq lstSublist (textposition objPline "R"))
(vl-cmdf "text" "j" "mr" (car lstSublist) (getvar "textsize") (* 180 (/ (cadr lstSublist) pi)) strRight)
)
(defun TextAngle (objPline sngDistance / lstPoint1 lstPoint2)
(setq sngLocal 0.001)
(if (equal sngDistance 0.0 0.0001)
(setq sngDistance (+ sngDistance (* sngLocal 2.0)))
(if (equal sngDistance (plinelength objPline) 0.0001)
(setq sngDistance (- sngDistance (* sngLocal 2.0)))
)
)
(if (and
(setq lstPoint1 (vlax-curve-getpointatdist objPline (- sngDistance sngLocal)))
(setq lstPoint2 (vlax-curve-getpointatdist objPline (+ sngDistance sngLocal)))
)
(angle lstPoint1 lstPoint2)
)
)
(defun TextPoint (objPline sngDistance / lstPoint sngAngle )
(if (and
(setq lstPoint (vlax-curve-getpointatdist objPline sngDistance))
(setq sngAngle (textangle objPline sngDistance))
(setq sngAngle (+ (/ pi 2.0) sngAngle))
)
(setq lstPoint (polar lstPoint sngAngle (* (getvar "textsize") 1)))
)
)
(defun TextPosition (objPline strPosition / lstPoint sngAngle sngLength)
(setq sngLength (plinelength objPline))
(cond ((= strPosition "L")
(setq lstPoint (textpoint objPline 0.0))
(setq sngAngle (textangle objPline 0.0))
)
((= strPosition "M")
(setq lstPoint (textpoint objPline (/ sngLength 2.0)))
(setq sngAngle (textangle objPline (/ sngLength 2.0)))
)
((= strPosition "R")
(setq lstPoint (textpoint objPline (- sngLength 0.00001)))
(setq sngAngle (textangle objPline (- sngLength 0.00001)))
)
)
(if (and
lstPoint
sngAngle
)
(list lstPoint sngAngle)
)
)
(defun PlineLength (objPline)
(vlax-curve-getdistatparam objPline (vlax-curve-getendparam objPline))
)
(vl-load-com)
BIG-AL
2015-06-01, 03:00 AM
This same question was asked at Cadtutor some time ago and the answer was as you have implied Peter, it can be done, is it perfect maybe.
peter
2015-06-01, 04:52 PM
Did you try the code, and was it perfect?
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.