Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

copy text in a straight line and paste it along with a curve

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Anonymous
2835 Views, 6 Replies

copy text in a straight line and paste it along with a curve

I have a line and text with it in specific intervals in a straight line. 

Is there any way to paste it along with a curve with the same specific intervals.

 

profileprofileasbuiltasbuilt  

6 REPLIES 6
Message 2 of 7
ВeekeeCZ
in reply to: Anonymous

Pretty sure you can find plenty of lisps on web which do that for you in one step.

Or you can use the tools you already have - ARRAYPATH to copy text along a curve, EXPLODE it, then change the text using the TCOUNT from express tools.

Message 3 of 7
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

I have a line and text with it in specific intervals in a straight line. 

Is there any way to paste it along with a curve with the same specific intervals.


If you're talking about already-drawn Text objects with different content that is not in some regular increment in value as in your images, that you want to re-arrange along a different-shaped route, I don't think ARRAYPATH and TCOUNT are really going to help.

 

I can imagine a way to do what you're after, but questions arise:

Will the curve always be an Arc, or might it sometimes be something more irregular, such as a Spline, or a Polyline of arc segments that might be of different radii and/or reverse direction of curvature, or a Polyline including possibly arc and  line segments?

 

Will the curve always be exactly the same length as the Line?  If not, should the Text objects be positioned at the same actual spacings along the curve as along the Line, or at the same proportional  distances along its length, so that the overall "fit" of them collectively is the same?  If the same actual spacings, what should the routine do if the curve is shorter?  Omit the ones past the end?  If it's longer, should the first one have the same relationship to the start of the curve as to the start of the Line, and leave excess curve length beyond the last one, or should they be centered along the curve, or...?

 

One problem I see is at the ends.  The way I'm picturing doing this would rely on the location along the path of a perpendicular projection from the Text's insertion point to the path, and that would need to fall on  the path for it to work.  On the assumption that the Text objects are Middle [if they're Text, not Mtext] or Middle-Center or Middle-Left justified, in your Line-based image, that projection from the left-most one's insertion point lies on  the Line, but in the Arc-based one, it would be off the end.  At the other end, in both arrangements it would be off the end.  But if the curve is always an Arc entity  specifically, or a Polyline of a single arc segment, a different approach might be possible that would allow that [that's why I asked about the kind of object the curve might be].

 

If the curve is an Arc, and the Line was drawn from left to right, your images are what would result of going from what AutoCAD considers the "start" to the "end" of each.  But if the sequence along an Arc should proceed in a clockwise  direction instead, or the Line was drawn from right to left, that would complicate things.  Should the User be asked to specify which direction should be used along each object, i.e. which end is the "start" of each for purposes of the desired result, even if that's not what AutoCAD considers its "start"?

Kent Cooper, AIA
Message 4 of 7
Anonymous
in reply to: Kent1Cooper

  1. The objects will always be a line or polyline (Arcs).
  2. The curve will always have the same length as the Line.
  3. The text spacing will always be same (current 10 m).
  4. There will always be a text at the end.
  5. Its text and are middle. mtext are no used.
  6. The text line is always from left to right and the line/polylines are from start to end.

 

Message 5 of 7
Anonymous
in reply to: Kent1Cooper

is there any way we can do this

Message 6 of 7
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

.... One problem I see is at the ends.  The way I'm picturing doing this would rely on the location along the path of a perpendicular projection from the Text's insertion point to the path, and that would need to fall on  the path for it to work.  .... in your Line-based image, that projection from the left-most one's insertion point lies on  the Line, but in the Arc-based one, it would be off the end.  At the other end, in both arrangements it would be off the end.  ....


With an alteration  to that caveat -- namely, that if a Text/Mtext object's projection perpendicular to the path falls off the end, the result may sometimes be somewhat different from what you want, though it should still "work" -- try this out [minimally tested]:

 

(vl-load-com)
(defun ang (path pt)
  (strcat (rtos (angle '(0 0 0) (vlax-curve-getFirstDeriv path (vlax-curve-getParamAtPoint path pt))) 2 8) "r")
); defun -- ang
(defun C:CTOP ; = Copy Text to Other Path
  (/ tss path1 path2 osm n txt pt1 pt2)
  (prompt "\nFor Text/Mtext objects to copy to follow other Path,")
  (if
    (and
      (setq tss (ssget ":L" '((0 . "*TEXT"))))
      (setq path1 (car (entsel "\nReference Path at original locations: ")))      
      (wcmatch (cdr (assoc 0 (entget path1))) "LINE,ARC,CIRCLE,*POLYLINE,ELLIPSE,SPLINE")
      (setq path2 (car (entsel "\nNew Path to copy to: ")))
      (wcmatch (cdr (assoc 0 (entget path2))) "LINE,ARC,CIRCLE,*POLYLINE,ELLIPSE,SPLINE")
    ); and
    (progn ; then
      (setq osm (getvar 'osmode))
      (setvar 'osmode 0)
      (repeat (setq n (sslength tss))
        (setq
          txt (ssname tss (setq n (1- n)))
          pt1 (vlax-curve-getClosestPointTo path1 (cdr (assoc 10 (entget txt))))
        ); setq
        (command
          "_.copy" txt "" pt1
          (setq pt2 (vlax-curve-getPointAtDist path2 (vlax-curve-getDistAtPoint path1 pt1)))
          "_.rotate" "_last" "" pt2
          "_reference" (ang path1 pt1) (ang path2 pt2)
        ); command
      ); repeat
      (setvar 'osmode osm)
    ); progn
  ); if
  (princ)
); defun -- C:CTOP

 

It should work with any kind of path for either the source or the target, not just Lines and Arcs.  And it should work with paths of different lengths, though again, if the target path is shorter than the source path, the results for Text/Mtext objects that fall past its length may be different from what you expect.

 

Also, it works in what AutoCAD considers the direction from start to end of each object, which for an Arc may not be the way it was drawn, and for many other object types will not be apparent at all visibly.  If it gives the wrong result when Lines or Polylines or Splines are involved, use REVERSE on one of them and do it again.

 

It works only in the World Coordinate System, and could use all the usual bells and whistles that it doesn't have yet.

Kent Cooper, AIA
Message 7 of 7
Anonymous
in reply to: Kent1Cooper

 

It works perfectly for me. For text coming in perpendicular, i split the lines.

this has saved a lot of my time.

 

thank you

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report