Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lengthen from midpoint

39 REPLIES 39
SOLVED
Reply
Message 1 of 40
jeroendewind
5649 Views, 39 Replies

Lengthen from midpoint

Hello,

 

Is there a way to use the lengthen command in a way that the midpoint stays the same?

 

Sometimes you want to use lengthen and use it as an extention. Then there's no problem.

But also sometimes I want to make a (poly)line a cetrain lenght, while its already placed on the right position.

 

Thanks

39 REPLIES 39
Message 2 of 40
imadHabash
in reply to: jeroendewind

Hi,

 

>>  I want to make a (poly)line a cetrain lenght, while its already placed on the right position. <<

it will be great if we have an image that describe your issue because there are many tricks that we can follow depending on the issue? BUT i can give you an idea that it may help from using Parametric (Fix option ) .

 

 

Regards,
 

Imad Habash

EESignature

Message 3 of 40
steven-g
in reply to: jeroendewind

It's going to depend on what you can see and we can't, but wouldn't scale work, you can pick the mid point as the base point and then use the reference option, to give the old and new values either as numbers or picking points

Message 4 of 40
Vinayv4v
in reply to: jeroendewind

HELLO,

 

Do you mean extend to both sides. A Lisp may do your job

 

dex.JPG

2 sides extended by 10mm.

DEX > Specify length > Choose objects.

Double Extend Lisp

Command DEX From Lee Mac:

 

http://www.lee-mac.com/doubleextend.html

Cheers,

Vinay Vijayakumaran

Message 5 of 40
jeroendewind
in reply to: Vinayv4v

Thanks all, but it's not exactly what I'm looking for. I'll try to expain:

Most of the time, I want to give a line a certain length, so I use lengthen and then total to turn (for example) a 7140 line into a 9000 line (see file 1 and 2). That will work then the left or right side is fixed as in the example. 

But sometimes I want to do the same trick, but then with the midpoint fixed (see file 3)

 

I know I can use lengthen and delta, but then I have to extend both sides with the same amount I have to calculate.

It would be nice to be able to use lengthen and total and then click in the middle or something.

 

Thanks

Message 6 of 40
imadHabash
in reply to: jeroendewind

Hi,

 

for this steel bars i usually draw a circle from the mid point with proper needed diameter . 

Imad Habash

EESignature

Message 7 of 40
Kent1Cooper
in reply to: jeroendewind

If they're always straight  things as in your images [whether Lines or Polylines of any variety or Blocks or...], you can use SCALE, give it the midpoint as the base, and use the Reference option -- pick the ends for the Reference length, and give it the desired total length.  A routine could probably be written to automate that for you.

 

EDIT:  By the way, this has come up before.  Some Searching will likely find other solutions, too.

Kent Cooper, AIA
Message 8 of 40
jeroendewind
in reply to: Kent1Cooper


@Kent1Cooper wrote:

If they're always straight  things as in your images [whether Lines or Polylines of any variety or Blocks or...], you can use SCALE, give it the midpoint as the base, and use the Reference option -- pick the ends for the Reference length, and give it the desired total length.  A routine could probably be written to automate that for you.

 

EDIT:  By the way, this has come up before.  Some Searching will likely find other solutions, too.


I found it and tried it, also Vinayv4v posted it in this thread.


@Vinayv4v wrote:

HELLO,

 

Do you mean extend to both sides. A Lisp may do your job

 

[image]

 

 

2 sides extended by 10mm.

DEX > Specify length > Choose objects.

Double Extend Lisp

Command DEX From Lee Mac:

 

http://www.lee-mac.com/doubleextend.html


The solution I'm looking for looks like this Lisp, but it's still different.

This Lisp is usefull because you can select multiple objects in 1 command, but that's not really necessary for me. If you use DEX isntead of the lengthen delta, you only save 1 mouseclick (select the object instead of select both ends seperatly).

 

The 'problem' is that most of the times I prefer to use total instead of delta because I don't always know the exact amount that needs to be added (especially with lines who have decimal numbers).

 

Don't know how hard it is to adjust a LIPS, because it's allmost what I'm looking for, except I want to give the new length as input instead of the extention.

Message 9 of 40

If I understand you correctly you're talking about straight polylines / lines. In this case you can use scale and set the base point as the middlepoint of your polyline. 

Message 10 of 40

Kent

Thank you for that.

I have exactly the same problem.

I use polylines with a certain global width and colour and certain linetype and linetype scale to represent tube bracings.

They end up at any arbitrary length when I put them in position and then I have to lengthen them to 

the nearest standard cut tube length, from the midpoint.

At the moment I am drawing a circle of the same diameter as the length, from the midpoint, 

and then extending the polyline each end to the circle, and then deleting the circle afterwards.

 

Your method is 8 steps and almost as long as my method 9 steps, so there is not much difference,

and they are both just as time consuming.

If a lisp could be written automating either one of the methods to 1 or 2 steps, that would really be 

useful. Any takers out there from you lispers?

 

Michael Kovacik
AutoCAD 2d & 3d (29 yrs)& Inventor (7 yrs)
Manufacturing (30 yrs) Draughtsman
Autodesk Product Design Suite Ultimate 2018
Johannesburg, South Africa


Autocd 2018, Inventor Pro 2018

(Impossible only means you haven't
found the solution yet)

Message 11 of 40
parkr4st
in reply to: MikeKovacik4928

lengthen  DElta option; snap at one end of the line and then the  point where it goes to get the distance  and click on the other end of the original line 

 

does that work?

Message 12 of 40
MikeKovacik4928
in reply to: parkr4st

You are missing the point. We are trying to lengthen an equal amount both sides without having to calculate the delta amount,

an only work on the total length. We don't want to be using our calculator.

We are looking for a single command to make a total length, but from the midpoint NOT from one end or the other.

 

"I know I can use lengthen and delta, but then I have to extend both sides with the same amount I have to calculate.

It would be nice to be able to use lengthen and total and then click in the middle or something." see quote from the original author of this post.

 

Michael Kovacik
AutoCAD 2d & 3d (29 yrs)& Inventor (7 yrs)
Manufacturing (30 yrs) Draughtsman/Designer
Autodesk Product Design Suite Ultimate 2018
Johannesburg, South Africa

 

Autocad 2018, Inventor Pro 2018

 

Impossible only means you haven't found
the solution yet

 

Message 13 of 40


@jeroendewind wrote:

.......

But also sometimes I want to make a (poly)line a cetrain lenght, while its already placed on the right position.

Thanks


Something like this may work

;:Ranjit Singh
;;9/1/17
(defun c:somefunc  (/ adoc del ss1 tot)
  (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
  (setq ss1 (ssget '((0 . "line,lwpolyline"))))
  (and ss1
       (setq tot (getdist "\nSpecify total length: "))
       (mapcar '(lambda (x)
                  (setq del (/ (- tot (getpropertyvalue x "Length")) 2.0))
                  (command-s "._lengthen"
                             (vlax-curve-getstartpoint x)
                             "_delta"
                             del
                             (vlax-curve-getstartpoint x)
                             (vlax-curve-getendpoint x)
                             ""))
               (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1)))))
  (vla-endundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object)))))

Total_Length_eq_ex_2_ends.gif

 

Message 14 of 40
Kent1Cooper
in reply to: jeroendewind

One thing I would worry about with using Lengthen and its Delta option, and having the routine pick the ends, is that it might sometimes "see" some other object.

 

Here's my take on it, for Lines and single-line-segment LWPolylines only.  It uses Scale, and if the object is a Polyline, it re-assigns its original global width to undo the changing of that in the Scale command.

 

(vl-load-com)
(defun C:TLM ; = Total Length with Midpoint kept in place
  (/ tl ent etype wid obj)
  (if
    (and
      (setq tl (getdist "\nTotal Length desired: "))
      (setq ent (car (entsel "\nSelect Line or single-line-segment Polyline: ")))
      (wcmatch (setq etype (cdr (assoc 0 (setq edata (entget ent))))) "LINE,LWPOLYLINE")
      (or
        (= etype "LINE")
        (and
          (not (vlax-curve-isClosed ent))
          (= (vlax-curve-getEndParam ent) 1.0); single-segment
          (member '(42 . 0.0) edata); line segment [not arc]
          (setq wid (cdr (assoc 43 edata))); constant width
        ); and
      ); or
    ); and
    (progn ; then
      (command ; then
        "_.scale" ent "" "_none"
        (mapcar '/ (mapcar '+ (vlax-curve-getStartPoint ent) (vlax-curve-getEndPoint ent)) '(2 2 2))
        (/ tl (vla-get-Length (setq obj (vlax-ename->vla-object ent)))); new length
      ); command
      (if (= etype "LWPOLYLINE") (vla-put-ConstantWidth obj wid)); restore original width
    ); progn
  ); if
  (princ)
); defun

 

It could be made to allow multiple selection, to work with other-than-LW Polylines, to notify you if you picked the wrong kind of thing or missed, remember your last length and offer it as default the next time, etc., and of course could use *error* handling and all that stuff.

Kent Cooper, AIA
Message 15 of 40
Ranjit_Singh1
in reply to: Kent1Cooper


@Kent1Cooper wrote:

One thing I would worry about with using Lengthen and its Delta option, and having the routine pick the ends, is that it might sometimes "see" some other object. 


@Kent1Cooper, the advantage of lengthen as opposed to scale is that it will work with straight as well as angular polylines and even when it has arcs. But you bring up a good point. That is an inherent flaw in "LENGTHEN". Even after you select the object it will "see" other objects at the selection point. One work around is to isolate the object. This, however, could be very memory intensive depending on the drawing. Anyways, here it is

;:Ranjit Singh
;;9/1/17
(defun c:somefunc  (/ adoc del ss1 tot)
  (vla-startundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
  (setq ss1 (ssget '((0 . "line,lwpolyline"))))
  (and ss1
       (setq tot (getdist "\nSpecify total length: "))
       (mapcar '(lambda (x)
                  (command-s "._isolateobjects" x "")
                  (setq del (/ (- tot (getpropertyvalue x "Length")) 2.0))
                  (command-s "._lengthen" x "_delta" del (vlax-curve-getstartpoint x) (vlax-curve-getendpoint x) "")
                  (command-s "._unisolateobjects"))
               (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1)))))
  (vla-endundomark (setq adoc (vla-get-activedocument (vlax-get-acad-object)))))

Total_Length_eq_ex_2_ends_v2.gif

 

Message 16 of 40


Your lisp doesn't seem to work for me.
I load it, I get the above error message.

Command: APPLOAD
TLM.lsp successfully loaded.
Command: ; error: malformed list on input
Command:

 

I type in TLM at the command line,it doesn't recognise.

What am I doing wrong.
See attached lisp which I copy/pasted from your post

 

Michael Kovacik
AutoCAD 2d & 3d (29 yrs)& Inventor (7 yrs)
Manufacturing (30 yrs) Draughtsman/Designer
Autodesk Product Design Suite Ultimate 2018
Johannesburg, South Africa

 

Autocad 2018, Inventor Pro 2018

 

Impossible only means you haven't found
the solution yet

Message 17 of 40

I copy/pasted your lisp into notepad, with a .lsp extension.
See attached


I loaded it into autocad using appload.
It seems to load with no error messages.


However when I type in somefunc at the command line
it doesn't recongise it.

What am I doing wrong.

 

Command: APPLOAD
somefunc.lsp successfully loaded.
Command:
Command:
Command: somefunc
Unknown command "SOMEFUNC".  Press F1 for help.

 

Michael Kovacik
AutoCAD 2d & 3d (29 yrs)& Inventor (7 yrs)
Manufacturing (30 yrs) Draughtsman/Designer
Autodesk Product Design Suite Ultimate 2018
Johannesburg, South Africa

 

Autocad 2018, Inventor Pro 2018

 

Impossible only means you haven't found
the solution yet

Message 18 of 40


@MikeKovacik4928 wrote:


Your lisp doesn't seem to work for me.
I load it, I get the above error message.

Command: APPLOAD
TLM.lsp successfully loaded.
Command: ; error: malformed list on input.....



As attached, that's all one line of code.  It can't be that way -- the semicolon near the beginning "comments out" everything that follows it until a new line starts for the operational content.  That new line never starts, it never gets to the closing right parenthesis for the (defun) function which is therefore never completed [that would be the cause of the "malformed list" error], and there's no definition.

Kent Cooper, AIA
Message 19 of 40

Kent

 

I tried copy/paste again. It worked this time, something must have gone wrong on the copy/paste.

That certainly seems to me to have solved the original question, I am certainly going to use it in future

rather than the scale or extend to circle method, much better!

But seeing as I didn't post it, I won't post an "accept as solution", that is up to the original author.

 

Mike

Message 20 of 40

Tried it again and it worked.

Something must have gone wrong on copy/paste previously.

This works for me, just like the other lisp posted,

and would be a solution for me

but I didn't post the original question.

 

Mike

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