Jump to content
Sign in to follow this  
Pat Stanford

Select All Lines of Same Length

Recommended Posts

The following script selects all lines the same length as a selected line.

Procedure SelectSameLengthLines;
{If the first selected object in the drawing is a line}
{this script gets the length of that line and selects all}
{other lines in the drawing that have the same length.}

{February 13, 2012}
{? 2012, Coviana, Inc - Pat Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}


Var H1	:Handle;
OLength		:Real;


Procedure DoIt(H2:Handle);

Begin
If HLength(H2)=OLength then SetSelect(H2);
End;



Begin
If GetType(FSActLayer)=2 then
	Begin
		OLength:=HLength(FSActLayer);
		ForEachObject(DoIt,((T=LINE)));
	End
Else AlrtDialog('First Selected Object Must Be A Line.');
End;

Run(SelectSameLengthLines);

Share this post


Link to post

Late reply but this came up in a search for some similar functionality. I'm trying to find a way of selecting all lines of shorter length than my first selected line - I tried modifying your script but to no avail (my scripting experience is very very limited!)

Incidentally, I also tried just running it as it is and it did nothing - no errors, no selections, nothing. Also tested it on a circle to see if it would produce the error message but that also produced nothing. Any clues what I'm missing?

Share this post


Link to post

Try this:

Procedure SelectShorterLines;
{If the first selected object in the drawing is a line}
{this script gets the length of that line and selects all}
{other lines in the drawing that have a shorter length.}

{September 11, 2015}
{February 13, 2012}
{© 2015, Pat Stanford pat@coviana.com}
{© 2012, Coviana, Inc - Pat Stanford pat@coviana.com}
{Licensed under the GNU Lesser General Public License}


Var H1	:Handle;
OLength		:Real;


Procedure DoIt(H2:Handle);

Begin
If HLength(H2)End;



Begin
If GetType(FSActLayer)=2 then
	Begin
		OLength:=HLength(FSActLayer);
		DSelectAll;
		ForEachObject(DoIt,((T=LINE)));
	End
Else AlrtDialog('First Selected Object Must Be A Line.');
End;

Run(SelectShorterLines);

I changed the comparison in the DoIt routine from = to <.

I also added a DSelectAll function in the main routine so you will only have lines shorter that the original selected at the end, not the shorter lines plus the original line.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...