Results 1 to 5 of 5

Thread: Line with editable text

  1. #1
    Member
    Join Date
    2015-05
    Posts
    2
    Login to Give a bone
    0

    Post Line with editable text

    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...!


    Attached Images Attached Images

  2. #2
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Line with editable text

    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=
    AutomateCAD

  3. #3
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Line with editable text

    A place to start.

    P=

    Code:
    (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)
    Attached Files Attached Files
    AutomateCAD

  4. #4
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    561
    Login to Give a bone
    0

    Default Re: Line with editable text

    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.

  5. #5
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Line with editable text

    Did you try the code, and was it perfect?
    AutomateCAD

Similar Threads

  1. Line Based Family - editable sketch
    By Andrew Dobson in forum Revit Architecture - General
    Replies: 7
    Last Post: 2010-09-06, 10:41 AM
  2. Can View titles have editable text in them
    By anthony.doyle in forum Revit Structure - General
    Replies: 1
    Last Post: 2009-10-25, 11:22 PM
  3. Is it possible to have editable text within a dynamic block?
    By jm.pearson105333 in forum Dynamic Blocks - Technical
    Replies: 4
    Last Post: 2006-02-17, 06:46 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •