Reverse the direction of a line

How to reverse the direction of a line, so start becomes end and vice versa. It makes a difference when editing a line's length in Properties - which end moves.

Comments

  • Michael Mayer
    edited July 2023
    In VW properties window you would have a little check box window
    where you can adjust the origin center of lines for changes.
    So for a line you will get a Symbol with Left/Middle/Right checkboxes.

    Hard to click the small radio buttons but an often used feature.

    And the Symbol will adapt to the direction or angle of the Line in drawing window.
    And there are also Symbols for more complex shapes like Rectangles and such,
    which may offer 9 radio box options.

    And of course in properties there is a button to switch directions of certain Elements.
    Not only for Lines but also important for Walls and such.
    (for inserted Window orientation, Composition orientation, length changes ....)




    Currently no Bricscad available,
    but I had the same situation in the past and AFAIR I had found a way to change
    the direction of a Line somehow. I am not sure.
  • OK, tested it anyway.

    Hovering the cursor over the Line,
    QUAD will show a lengthen dynamically.

    If I get that correctly,
    depending on which half of the line hovering your cursor,
    it will extend from (?) that line endpoint.
    (the opposite half of the line will stay)

    EDIT :
    That doesn't seem to work for me.
    I may use it the wrong way.
  • OK,

    I found a way for me.

    - double click the line (=> edit mode)
    - grab the handle on the end to extend
    - Enter overall length number in DYNDIM
  • I would rotate the line 180 degrees about its midpoint.
  • I was waiting for someone to point out a command for that, but no luck.
    I'm missing something in MM's method - doesn't reverse it in situ?
    AA's soinds gd, tho multi-step - but doesn't work! Afterwards entering a new length in Properties, it's still the same end that extends. Do modification commands result in the entity's deep-code description being rewritten anew, or is it still the same old entity description but with modifications recorded?
    Unfortunately Lisps are a bridge too far me at present.
  • Michael Mayer
    edited July 2023
    I think I remembered wrong.
    I do not find a way to reverse a Line direction.


    But for changing a Line length from any desired end,
    Lengthen Dynamically Tool from Quad works for me know.
    Depending on which end/half of Line where you are hovering
    to make the Quad appear - that will be the end from where
    you extend no matter which side the Lines Start Point is.

    So you can change the Line Length to whatever direction you want.
    The only downside for me is that DYNDIM will only show/use the
    delta length you extend !
    (And that after Entering the number the command is still active
    and asks for things that I do not understand - but a right mouse
    click will end and accept the result anyway)

    So you need to know the length of your line and do some math
    how much you need to add for your desired final length.

    So for me and my keep it simple stupid brain,
    the most intuitive way is still :
    - (single) click Line
    - click desired end handle
    - pull it out
    - Enter desired new Length in DynDim

    (Actually I use dynamic grid and input new length graphically)
  • Yeah I just recently discovered the Lengthen tool as acessed via Quad - a godsend. Before that, the method of MM's penult para was more work.

    I agree, in Acad and early Brics, typing the length to extend was default, but that's now hard to achieve, at cost of other useful features, as it prefers to take typing as the final length.

    Still no way to simply reverse a line's direction insitu. I'm using a bunch of vertical lines as depth measurement below a datum, and editing each one's length, time and again, in Properties - no snap/pull/lock-to-polar, just type the number from spreadsheet into Properties. Unfortunately I placed most of them by copy/pasting a line which had been created by 1st click bottom, 2nd click top, so now it's the top end that extends/retracts when I edit the length in Properties.
  • Anthony Apostolaros
    edited July 2023

    .... Still no way to simply reverse a line's direction in situ. I'm using a bunch of vertical lines as depth measurement below a datum, and editing each one's length .... it's the top end that extends/retracts when I edit the length in Properties.

    In my v17, rotating a line 180° reverses the values of its Start point and End point properties. Doesn't it do that in yours?

    Or are you saying that changing the Length property alters the top point regardless of whether that's the Start point or the End point? That would be eerie. I can't test it, since Length is a Read-Only property in v17.

    .... AA's sounds gd, tho multi-step ....

    Rotating a line 180° is probably less convenient for you than it is for me. I just have to press F7 twice, each press issuing the attached custom command.

    But what about mirroring the line about its midpoint? For vertical lines, that should be easy even without any custom commands.
  • In my v17, rotating a line 180° reverses the values of its Start point and End point properties. Doesn't it do that in yours?

    I'll try it again.

    Or are you saying that changing the Length property alters the top point regardless of whether that's the Start point or the End point? That would be eerie.

    No, it lengthens which ever is the End point. Just that most of mine have End point at the top, and spinning it 180o hasn't seemed to change that.

  • Ok bottom line way to work out which end automatically, say for some lisp where want a value for use with lengthen.

    I just posted this at Autodesk\forums its like 30 years old code. Pick an object near an end. For lengthen probably dont swap.

    Example
    (defun swapends (ent / obj)
    (setq pt3 (cadr ent))
    (setq obj (vlax-ename->vla-object (car ent)))
    (setq start (vlax-curve-getstartPoint obj))
    (setq end (vlax-curve-getEndPoint obj))
    (setq d1 (distance pt3 end))
    (setq d2 (distance pt3 start))
    (if (< d1 d2)
    (progn
    (setq temp end)
    (setq end start)
    (setq start temp)
    )
    )
    (princ)
    )

  • Alan, does (vla-put-length) or (vlax-put-property object 'Length) work in newer versions? They don't work in v17, and an Ax/VBA dump of a Line tells me that Length is read-only. But I thought that might have changed, since apparently it's now possible to edit Length in the Properties panel.
  • Anthony Apostolaros
    edited July 2023

    I was waiting for someone to point out a command for that, but no luck. ....

    Tom, I just remembered that the direction of a polyline can be reversed by the Pedit command. I use it when I want to change the direction of a polyline that has an arrow linetype. Maybe you can use that?

    You'd have to convert your lines to polylines. Do you mind doing that? At least temporarily? Pedit will do it for you, by default. You just have to press Enter to accept it, and then R for Reverse. You could always change them back to lines afterward, with the Explode command. Both Pedit and Explode operate on a whole selection set at once, so it would be the quickest way to do what you want.

    If not, there are lisp-based custom commands that reverse the direction of lines as well as polylines, here and here. You start the command and then click on each line you want reversed. But I think you said you don't like Lisp.

    *ARROWS,Arrows -> -> ->
    A,2,[ZIG,ltypeshp.shx,r=-90,x=-0.25,y=0.25,s=0.25],-.3
  • To reverse a line you can right-click on the midpoint grip and select Scale, then enter -1.
  • Tom Foster
    edited July 2023

    apparently it's now possible to edit Length in the Properties panel.

    Ah - so this is a recent introduction - thanks Brics - invaluable.

  • Tom Foster
    edited July 2023
    Anthony and Owen, those are both great solutions, thanks.
    Owen's is very clever, quickest and best for reversing one line at a time but can't be used in a batch.
    Anthony's is ideal for selecting a batch to reverse in one go.
  • ALANH
    edited July 2023
    Autocad has "Reverse" not sure if this has been added into Bricscad V23, so yes use the Pedit R method in my code. Just use Pedit method knowing it will work in both.

    Flipline.lsp come to mind pick line and rotates 180 based on midpoint.

    Re lengthen sounds good but will have a look when get V23.

    (defun c:f180 ( / ent)
    (setq ent (car (entsel "\nPick a line ")))
    (setq start (cdr (assoc 10 (entget ent))))
    (setq end (cdr (assoc 11 (entget ent))))
    (setq mp (mapcar '* (mapcar '+ start end) '(0.5 0.5)))
    (command "rotate" ent "" mp 180)
    (princ)
    )
    (c:f180)
  • ALANH said:

    .... lengthen sounds good but will have a look when get V23. ....

    The Lengthen command works in my v17. I didn't know about it until this thread. It's pretty neat.

    It alters whichever end of the line I pick after specifying the new Total length or the Percent or Increment change, or after selecting the DYnamic option. If I use the DYnamic option and pick the Start end, it temporarily reverses the line so that I'm actually dragging the End point. I learned that by using it on a line with the Arrows linetype.

    : LENGTHEN
    Edit length: DYnamic/Increment/Percent/Total/<Select entity to list length>: