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

Polyline segments length

50 REPLIES 50
Reply
Message 1 of 51
Anonymous
2087 Views, 50 Replies

Polyline segments length

I need a routine that will allow you to pick a polyline and then tell me the smallest and the largest segment lengths, or something that will work for the following.

I am working on some master planing and did no do the original layout not we have some design requirements.
I would like to be able to select a ployline that has multiple segments and the routine tell me what the shortest length and the longest lengths are. So the I can verify that we do not have any runs of pipe over a certain length.

Do anyone have anything like that?
Thanks
50 REPLIES 50
Message 2 of 51
Anonymous
in reply to: Anonymous


Hi,

 

The attached function gives you something to start.
Right now, it prints the values of the shortest and the longest segment, but if
you know a little AutoLISP programming, you can easily adapt it in order to pass
them (as a two reals list for exemple) to some other further
processing.

 

HTH


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
I
need a routine that will allow you to pick a polyline and then tell me the
smallest and the largest segment lengths, or something that will work for the
following. I am working on some master planing and did no do the original
layout not we have some design requirements. I would like to be able to select
a ployline that has multiple segments and the routine tell me what the
shortest length and the longest lengths are. So the I can verify that we do
not have any runs of pipe over a certain length. Do anyone have anything like
that? Thanks
Message 3 of 51
Anonymous
in reply to: Anonymous

Thanks this should get me going
Message 4 of 51
Anonymous
in reply to: Anonymous

Is there any way to make this zoom to the min or max lengths depending upon the users choice and if no choice the view stays the same?
Thanks
Message 5 of 51
Anonymous
in reply to: Anonymous


Yes, It can be done. I will come back with
something.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Is
there any way to make this zoom to the min or max lengths depending upon the
users choice and if no choice the view stays the same?
Thanks
Message 6 of 51
Anonymous
in reply to: Anonymous

While working your magic can you possibly change the command so that if the user selects the polyline before running the command it will use the selection.
Currently if you select a polyline before running the command it will still ask for the user to pick the polyline again.

Thanks
Message 7 of 51
Anonymous
in reply to: Anonymous


Here attached is the new function with the new
functionality. There is a dialog control now and the user can chose to zoom to
one of the segments. I didn't want to lose time with some other
conditions, so if you select an one segment polyline, the function will report
the same value for the MIN and the MAX segments. l hope it's what you
wanted.

 

Regards


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Is
there any way to make this zoom to the min or max lengths depending upon the
users choice and if no choice the view stays the same?
Thanks
Message 8 of 51
Anonymous
in reply to: Anonymous


I didn't see your last request till the last
minute, so here is a modified function, that will consider a selected
polyline if a selection is already made, or will ask for a polyline if nothing
is selected. However, you should be aware that if you accidentaly have more than
one selected object (polyline), the results are impredictible, i.e. you can't
control which one from the selection set wil be considered.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
While
working your magic can you possibly change the command so that if the user
selects the polyline before running the command it will use the selection.
Currently if you select a polyline before running the command it will still
ask for the user to pick the polyline again. Thanks
Message 9 of 51
Anonymous
in reply to: Anonymous

Can you make it only allow one selection?
Message 10 of 51
Anonymous
in reply to: Anonymous


No. If it's about an implied selection, it is
controled by the Autocad's native selection methods and commands, You are
talking about an already selected object, so if the selection is already done,
outside my function, I can not impose or restrain the user to select what ever
he wants. Of course, there is always an way to overcome, like asking the user to
specify which one of the selected objects he wants and so on, but I think
that common sense should prevail. I don't have time to tweak a function for
things that are obviously easier to avoid by a competent user. Or if the guy is
incompetent and doesn't know what is doing, then look for somebody
else.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Can
you make it only allow one selection?
Message 11 of 51
Anonymous
in reply to: Anonymous

This is absolutely perfect
Thanks for all the help.
Message 12 of 51
Anonymous
in reply to: Anonymous


You're welcome.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
This
is absolutely perfect Thanks for all the help.
Message 13 of 51
FTWilson
in reply to: Anonymous

Just for grins (actually, not really, I do kind of want this...)

Using your code, how would you go about finding the segment of the polyline that was selected (i.e. the segment picked on to select the polyline)? I would like to get the length of a selected polyline segment and then do some math using the end point coordinates of that segment (rise, run, slope) ? I have some Lisp code that does this, but it doesn't use VLisp.
Message 14 of 51
Anonymous
in reply to: Anonymous


The only problem ai see here, is the fact that the
selection method (specialy if implied, i.e. as you suggested in your last
message, the polyline is already selected when calling the
function), could be done with any of the following method:

 


size=2>Window/Last/Crossing/BOX/ALL/Fence/WPolygon/CPolygon/Group/Add/Remove/Multiple/Previous/Undo/AUto/SIngle

 

because there is no way (outside the function)
to force the user to select the polyline with a pick. Otherwise, if you can
guarantee that it was a picking selection, it could be done.

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Just
for grins (actually, not really, I do kind of want this...) Using your code,
how would you go about finding the segment of the polyline that was selected
(i.e. the segment picked on to select the polyline)? I would like to get the
length of a selected polyline segment and then do some math using the end
point coordinates of that segment (rise, run, slope) ? I have some Lisp code
that does this, but it doesn't use VLisp.
Message 15 of 51
FTWilson
in reply to: Anonymous

Actually, I am not the original poster. I don't need the implied selection. I was curious about how the code would look if you tried to take the pick point from selecting the polyline and use VLisp to find the selected segment and get its start and end points and angle.

If you don't have the time or inclination, don't worry about it. I'm slowly getting around to finding a method to do it.

-fred.
Message 16 of 51
Anonymous
in reply to: Anonymous

The easiest way would be to use the vlax-curve... functions AFAIK. Check
them out in vlide help.

wrote in message
news:6103146@discussion.autodesk.com...
Actually, I am not the original poster. I don't need the implied selection.
I was curious about how the code would look if you tried to take the pick
point from selecting the polyline and use VLisp to find the selected segment
and get its start and end points and angle. If you don't have the time or
inclination, don't worry about it. I'm slowly getting around to finding a
method to do it. -fred.
Message 17 of 51
Anonymous
in reply to: Anonymous


Oh, I'm sorry, I didn't pay attention, always
in rush 🙂 I will try to shed some light on your request. Maybe it's a good idea
to tell me what do you want to do with the information you are talking about
(rise, run, slope). Do you want just to print it, display it in the dialog box
or do something with ? May be you can post the function that you already have,
so I can better understand what you're up to. And last but not least, do you
need the other stuff, with the MIN and MAX segments, or you are
interested just about the segment that was picked ?


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Actually,
I am not the original poster. I don't need the implied selection. I was
curious about how the code would look if you tried to take the pick point from
selecting the polyline and use VLisp to find the selected segment and get its
start and end points and angle. If you don't have the time or inclination,
don't worry about it. I'm slowly getting around to finding a method to do it.
-fred.
Message 18 of 51
FTWilson
in reply to: Anonymous

Here's what I have now. I don't need the MIN and Max segments in this routine.

I have had this around for years to just give the basics of lines. I added the polyline stuff that I got from Tony Hotchkiss back in 1998.

We do a lot with slopes of ramps and other things, so the Rise and Run and Slope are the primary things this routine spits out. Often times the slope is part of a triangle polyline that makes the objects easier to work with.

So, I added the VL stuff about lines as a learning exercise, and stumbled upon this thread and have been a little stumped about how to proceed with working with the polyline in VLisp.

FYI - I have commented out some custom (and copyrighted) functions that are not important to the basics of this routine. It does still require the DosLib functions from www.McNeel.com (just for the message box that pops up). The Tony Hotchkiss functions are credited at the bottom of the file. Let me know if something is still missing.

Fred
Message 19 of 51
Anonymous
in reply to: Anonymous


Unfortunatelly I am quite busy today and tomorrow,
but I will take a look later in the day. I would need to know what AutoCAD
version are you using, in order to donload the right DOSLib??.arx.


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Here's
what I have now. I don't need the MIN and Max segments in this routine. I have
had this around for years to just give the basics of lines. I added the
polyline stuff that I got from Tony Hotchkiss back in 1998. We do a lot with
slopes of ramps and other things, so the Rise and Run and Slope are the
primary things this routine spits out. Often times the slope is part of a
triangle polyline that makes the objects easier to work with. So, I added the
VL stuff about lines as a learning exercise, and stumbled upon this thread and
have been a little stumped about how to proceed with working with the polyline
in VLisp. FYI - I have commented out some custom (and copyrighted) functions
that are not important to the basics of this routine. It does still require
the DosLib functions from www.McNeel.com (just for the message box that pops
up). The Tony Hotchkiss functions are credited at the bottom of the file. Let
me know if something is still missing. Fred
Message 20 of 51
FTWilson
in reply to: Anonymous

No problem. Totally understand. No rush. The routine works fine for my purposes as is. Although I did find one bug that I don't yet know enough about how to debug and it apparently may be in the Tony Hotchkiss functions.

When you get around to it, create a polyline with exactly a half circle arc as part of the pline. Any other arc works fine, but I get the following error when clicking on a perfect half circle:

; error: bad argument type: numberp: nil

Oh, and you would have to download the version of DosLib for your version of AutoCAD. You would need to do that if you want the Lisp routine to work for you. Otherwise, you could just rem out those dos_xxx functions.

I am using AutoCAD 2008 though.

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

Post to forums  

Autodesk Design & Make Report

”Boost