Lengthen from midpoint

Lengthen from midpoint

jeroendewind
Enthusiast Enthusiast
8,294 Views
39 Replies
Message 1 of 40

Lengthen from midpoint

jeroendewind
Enthusiast
Enthusiast

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

0 Likes
Accepted solutions (2)
8,295 Views
39 Replies
Replies (39)
Message 21 of 40

beyoungjr
Advisor
Advisor

Wouldn't this issue be so easy to overcome if Autodesk would just allow calculations to occur when inputting our values, like Inventor does?

 

I have used MasterCAM for CNC programming since 1994 and the single greatest functionality that I have appreciated vs. AutoCAD is the ability to enter arithmetic operations for my values.

 

The OP wishes to extend both ends and @Kent1Cooper appropriately suggests SCALE with a reference length and final length.  If a user wanted to just use the math after selecting the midpoint he/she could avoid any of the options and just type the formula, letting ACAD work it out and the result would be perfect.

 

I've seen SO MANY examples of this functionality but Autodesk never went that direction.  They do have the popup calculator but that extra steps where other application allow the math directly on the input line or field.

 

Maybe it's time for an "IDEA"?  Come to think of it I may have already put it in the Wish List long ago???

 

Cheers,

Blaine

 


Blaine Young
Senior Engineering Technician, US Army

0 Likes
Message 22 of 40

MikeKovacik4928
Advisor
Advisor

I agree with you totally.

Some of the inventor functionality in AutoCAD would be fantastic!

However, I suppose,  what would be the point of  having 2 different softwares then?

Who knows? I don't know really know what Autodesk's take on that one is.

 

Also, it seems as if autocad does not have an "idea" forum like inventor does.

 

Most of these related issues can be solved with a lisp program, it seems.

 

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

 

0 Likes
Message 23 of 40

Kent1Cooper
Consultant
Consultant
Accepted solution

@jeroendewind wrote:

.... 

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

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


Back to the original question, and I finally worked out a universal routine, that works on multiple objects, and of various different kinds, including Polylines that are not straight-line-single-segment, and Arcs and even partial Ellipses.  It does use the Lengthen command, and I've found that if you give it, for the "pick" of what to Lengthen, a list of the entity name and the point, like what (entsel) returns, then it will Lengthen the correct object even if there's more than just that one at that location -- it prevents "seeing" something else.

 

What remains to be added:

1)  Remembering your total length and offering it as default on subsequent use;

2)  A check on whether the total length requested would make an Arc or a partial Ellipse longer than the corresponding Circle or full/closed Ellipse, which it can't do.

 

 

Kent Cooper, AIA
Message 24 of 40

MikeKovacik4928
Advisor
Advisor

Kent

 

Nice!

thanks

 

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

0 Likes
Message 25 of 40

jeroendewind
Enthusiast
Enthusiast

@Kent1Cooper wrote:

@jeroendewind wrote:

.... 

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

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


Back to the original question, and I finally worked out a universal routine, that works on multiple objects, and of various different kinds, including Polylines that are not straight-line-single-segment, and Arcs and even partial Ellipses.  It does use the Lengthen command, and I've found that if you give it, for the "pick" of what to Lengthen, a list of the entity name and the point, like what (entsel) returns, then it will Lengthen the correct object even if there's more than just that one at that location -- it prevents "seeing" something else.

 

What remains to be added:

1)  Remembering your total length and offering it as default on subsequent use;

2)  A check on whether the total length requested would make an Arc or a partial Ellipse longer than the corresponding Circle or full/closed Ellipse, which it can't do.

 

 


I tried it yesterday and it did not work, maybe it has something to do with a custom UCS? I tried it again today in another *.dwg and it worked perfectly!

Thanks for the help and making the lisp!

 


@MikeKovacik4928 wrote:

Kent

 

Nice!

thanks

 

Michael Kovacik


Thanks for the help in this thread! Nice to get some help from someone with the same problem.

0 Likes
Message 26 of 40

Kent1Cooper
Consultant
Consultant

jeroendewind wrote:


 

I tried it yesterday and it did not work, maybe it has something to do with a custom UCS? I tried it again today in another *.dwg and it worked perfectly!

Thanks for the help and making the lisp!

....


I wouldn't think a different UCS would be the problem, and don't have any better suggestions for a reason it didn't work, but I'm glad it works now -- I hope it continues to.

Kent Cooper, AIA
0 Likes
Message 27 of 40

jeroendewind
Enthusiast
Enthusiast

@Kent1Cooper wrote:

@jeroendewind wrote:


 

I tried it yesterday and it did not work, maybe it has something to do with a custom UCS? I tried it again today in another *.dwg and it worked perfectly!

Thanks for the help and making the lisp!

....


I wouldn't think a different UCS would be the problem, and don't have any better suggestions for a reason it didn't work, but I'm glad it works now -- I hope it continues to.


I don't want to be ungratefull, but it actuallty doesn't work at the moment (since the *.dwg I'm using has a 'turned' UCS.

 

Example in the attachments:

Screenshot 4 has a polyline and normal line of 2000mm who intersect in both midpoints.

When I have the UCS on 'As deel 3 (as 42-50)' it makes the lines 5000 but not with the fixed midpoint. (screenshot 5)

When I set the UCS on 'World' it works like it's supposed to (screenshot 7)

 

Both on the same *.dwg

 

 

0 Likes
Message 28 of 40

Kent1Cooper
Consultant
Consultant

@jeroendewind wrote:

@Kent1Cooper wrote:

....

I wouldn't think a different UCS would be the problem, and don't have any better suggestions for a reason it didn't work, but I'm glad it works now -- I hope it continues to.


... it actuallty doesn't work at the moment (since the *.dwg I'm using has a 'turned' UCS. .... 


I'm not where I can test it right now, but I see how a UCS difference would make a difference.  Try wrapping the (vlax...) endpoint-finding functions in (trans) functions, like this:

 

(trans (vlax-curve-getStartPoint ent) 0 1)

 

[or whatever variable I used for the entity name].

Kent Cooper, AIA
0 Likes
Message 29 of 40

jeroendewind
Enthusiast
Enthusiast

@Kent1Cooper wrote:

@jeroendewind wrote:

@Kent1Cooper wrote:

....

I wouldn't think a different UCS would be the problem, and don't have any better suggestions for a reason it didn't work, but I'm glad it works now -- I hope it continues to.


... it actuallty doesn't work at the moment (since the *.dwg I'm using has a 'turned' UCS. .... 


I'm not where I can test it right now, but I see how a UCS difference would make a difference.  Try wrapping the (vlax...) endpoint-finding functions in (trans) functions, like this:

 

(trans (vlax-curve-getStartPoint ent) 0 1)

 

[or whatever variable I used for the entity name].


 

Turn:

 

          (command "_.lengthen" ; then
            "_delta" (/ (- *LTMlength (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))) 2)
            (list ent (vlax-curve-getStartPoint ent))
            (list ent (vlax-curve-getEndPoint ent))

Into:

          (command "_.lengthen" ; then
            "_delta" (/ (- *LTMlength (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))) 2)
            (list ent (trans (vlax-curve-getStartPoint ent)) 2)
            (list ent (trans (vlax-curve-getEndPoint ent)) 2)

Like that?

0 Likes
Message 30 of 40

Kent1Cooper
Consultant
Consultant
Accepted solution

@jeroendewind wrote:
.... 

Turn:

 

          (command "_.lengthen" ; then
            "_delta" (/ (- *LTMlength (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))) 2)
            (list ent (vlax-curve-getStartPoint ent))
            (list ent (vlax-curve-getEndPoint ent))

Into:

          (command "_.lengthen" ; then
            "_delta" (/ (- *LTMlength (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))) 2)
            (list ent (trans (vlax-curve-getStartPoint ent)) 2)
            (list ent (trans (vlax-curve-getEndPoint ent)) 2)

Like that?


I can't imagine where those 2's came from....

 

(command "_.lengthen" ; then
            "_delta" (/ (- *LTMlength (vlax-curve-getDistAtParam ent (vlax-curve-getEndParam ent))) 2)
            (list ent (trans (vlax-curve-getStartPoint ent) 0 1))
            (list ent (trans (vlax-curve-getEndPoint ent) 0 1))

Kent Cooper, AIA
0 Likes
Message 31 of 40

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

....

What remains to be added:

1)  Remembering your total length and offering it as default on subsequent use;

2)  A check on whether the total length requested would make an Arc or a partial Ellipse longer than the corresponding Circle or full/closed Ellipse, which it can't do.


Attached is a more developed version of LengthenTotalMid.lsp / LTM command, with those things incorporated. I found some really interesting things in the process, for example: a "heavy" Polyline [whether 2D or 3D] can be Lengthened with the delta option, and if you make it longer  that way, everything is as you would expect, but if you make it shorter  that way, it gets a new entity name!  See comments at the top of and within the file.

Kent Cooper, AIA
Message 32 of 40

jeroendewind
Enthusiast
Enthusiast

Thanks again, really helpfull with the addition to memorize the previous input!

0 Likes
Message 33 of 40

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:
Attached is a more developed version of LengthenTotalMid.lsp / LTM command. ....

Further possible developments, if you think them worthwhile, to make it slightly more "universal" --

 

A)  It could be made to accept the selection of open-ended Splines, since those can at least be shortened  with the Lengthen DElta option, though they can't be made longer.  It would have to count any that started out shorter than the desired length among the ones it couldn't adjust.

 

B)  It could be made to accept the selection of Xlines, and turn them into Lines of the desired length, centered around their origin points, either by Breaking or by just drawing the Line and deleting the Xline.

 

C)  It could be made to accept the selection of Rays, and turn them into Lines of the desired length, though presumably keeping their start points rather than centering around their [non-existent, after all] midpoints.

 

Kent Cooper, AIA
0 Likes
Message 34 of 40

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

Further possible developments, if you think them worthwhile, to make it slightly more "universal" --

 

A)  It could be made to accept the selection of open-ended Splines, since those can at least be shortened  with the Lengthen DElta option, though they can't be made longer.  It would have to count any that started out shorter than the desired length among the ones it couldn't adjust.

....


Here's a version with Splines allowed, though [as described] it can process one only when the desired length is shorter  than the current length.

 

I'm still considering the other potential alterations, as well as whether closed Ellipses could just be filtered out, on the assumption that the characteristics of those that could  unintentionally filter out a Polyline  would be so rare in one as to make it not worth worrying about the possibility.

Kent Cooper, AIA
0 Likes
Message 35 of 40

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:
.... I'm still considering the other potential alterations, as well as whether closed Ellipses could just be filtered out, on the assumption that the characteristics of those that could  unintentionally filter out a Polyline  would be so rare in one as to make it not worth worrying about the possibility.

Here's a further-refined version of LengthenTotalMid.lsp, which does filter out closed Ellipses in the selection, but without risking the rare omission of a Polyline, and also adds Xlines to the possibilities [it draws a Line over one, of the specified length centered around the Xline's origin point, and deletes the Xline].  Also, if a Polyline has an arc  segment at an end, which would need to be lengthened to more than full-circle length, that gives an incorrect result, which the routine detects and undoes, and includes it in the report of how many it couldn't make the specified length.

Kent Cooper, AIA
Message 36 of 40

beyoungjr
Advisor
Advisor

Very nice work!

So cool of you to keep after that and post your revision.

Useful little tool to keep around!

 

Thanks Much!

 

Blaine

 


Blaine Young
Senior Engineering Technician, US Army

0 Likes
Message 37 of 40

MikeKovacik4928
Advisor
Advisor

Kent

 

Good Stuff!

I have been using you original lisp some time now on lines.

I have only just spotted your new version.

Now I can use your updated version on arcs.

the type of structural work I do, I am always wanting

to lengthen straight and radiused pipes in situ, by an equal amount each side.

Very Useful tools

 

Michael Kovacik
2d & 3d Autocad and Inventor designer/draughtsman
.
Draughting/Designing (Manufacturing) (31 yrs)
-Drawing Board (3 yrs)
--Cad (28 yrs)
---Cadkey (4 yrs)
---AutoCAD 2d & 3d (16 yrs)
---Inventor (4 yrs)
---Autocad and Inventor Simultaneously (4 years)
---(and recently Autocad/Inventor Customisation)
.
Autodesk Product Design Suite Ultimate 2018
Autocad 2018, Inventor Pro 2018
(personal licensed copy)
.
Johannesburg, South Africa
.
(Impossible only means you haven't
found the solution yet)

0 Likes
Message 38 of 40

Anonymous
Not applicable

Love this lisp.  How would one customize it so that it would work with Pipe or tubing? (CAD mep 2019)

0 Likes
Message 39 of 40

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

Love this lisp.  How would one customize it so that it would work with Pipe or tubing? (CAD mep 2019)


I don't have MEP.  What is the object type for such things [i.e. what is a selected one called at the top of the Properties palette, or as the return of a LIST command]?  If it's something special to MEP, I won't be able to help you, but I'm also a little skeptical that native AutoCAD entity types [such as 3D Solids?] can be accommodated, without using an entirely different approach.

Kent Cooper, AIA
0 Likes
Message 40 of 40

Anonymous
Not applicable

dwestfallL7TQQ_0-1638387393995.png

It would definitely be an MEP part.  Thanks for checking it out though!

0 Likes