Site Logo
Site Logo
 
It is currently Sun Apr 02, 2017 6:43 pm

All times are UTC [ DST ]




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Selecting short lines and arcs
PostPosted: Mon Feb 22, 2016 11:44 am 
Offline
DELCAM Guru
DELCAM Guru

Joined: Wed Sep 09, 2015 8:15 am
Posts: 66
Location: Poland
Hello everyone,

Is there any way to search and select short lines and arcs which length is less than 'x'?
'x' is a variable, it will be great if I could define it in some text field just before searching.

The screenshot below illustrates my problem.

I'm working on PowerSHAPE Pro 2015 R2 (SP2 CR 15.2.31).

Thank You
Mateusz


Attachments:
shortSection.png
shortSection.png [ 33.8 KiB | Viewed 116 times ]
Top
 Profile  
 
 Post subject: Re: Selecting short lines and arcs
PostPosted: Thu Mar 10, 2016 1:30 pm 
Offline
DELCAM Guru
DELCAM Guru
User avatar

Joined: Fri Oct 08, 2004 8:19 am
Posts: 445
Location: Basildon, Essex, UK
Hi,

I have this macro which selects small items, it doesn' mesaure the lengths of actually lines and arcs just the overall sizes.

It should work for what you want.

I'm not taking credit for it as I can't remember if I wrote it or someone created it on here for me.

Regards,
Jim


Attachments:
select_small_items.txt [947 Bytes]
Downloaded 6 times
Top
 Profile  
 
 Post subject: Re: Selecting short lines and arcs
PostPosted: Thu Mar 10, 2016 1:30 pm 
Offline
DELCAM Guru
DELCAM Guru
User avatar

Joined: Fri Oct 08, 2004 8:19 am
Posts: 445
Location: Basildon, Essex, UK
double post oops


Top
 Profile  
 
 Post subject: Re: Selecting short lines and arcs
PostPosted: Thu Mar 10, 2016 1:43 pm 
Offline
DELCAM Guru
DELCAM Guru
User avatar

Joined: Fri Oct 08, 2004 8:19 am
Posts: 445
Location: Basildon, Essex, UK
I've just written this one which does exactly what you want...


Attachments:
select short lines and arcs.txt [786 Bytes]
Downloaded 10 times
Top
 Profile  
 
 Post subject: Re: Selecting short lines and arcs
PostPosted: Tue Mar 15, 2016 9:19 am 
Offline
DELCAM Guru
DELCAM Guru

Joined: Wed Sep 09, 2015 8:15 am
Posts: 66
Location: Poland
Thank you very much for your help. I have to correct it a little bit, because there is a small mistake, but thanks for the base to do this.

Here is a correct solution:
Code:
//---------------------------------------
// Select only lines and arcs shorter than a specified amount
//---------------------------------------
INPUT NUMBER 'Enter the minimum length of lines or arcs to select' $minsize
FILTERBUTTON FilterItems
SelectType Arc Line
All
accept
LET l_list = ''

//
LET numturn = selection.number

WHILE $numturn {
   LET s_line = $numturn - 1
   LET l_name = selection.object[$s_line].name
   IF (selection.type[$s_line] == 'Line') {
      LET l_len = line[$l_name].length
   } ELSE {
      LET l_len = arc[$l_name].length
   }
   LET type = (selection.type[$s_line])
   PRINT 'Length of ' $type ' ' $l_name ' is '$l_len

   IF ($l_len < $minsize) {
      LET l_list = concat($l_list;'add ';$type;' "';$l_name;'" ')
   }
   
   LET numturn = $numturn - 1
}

EVERYTHING PARTIALBOX
select clearlist
EXECUTE COMMAND $l_list
RETURN


______________________________________________________
Edit 15.03.2016:
I have a better solution . String variable is limited in length and generates errors if there are too many objects . It would be better to use the list. This solution takes more time , but there are no errors of number of objects:
Code:
//---------------------------------------
// Select only lines and arcs shorter than a specified amount
//---------------------------------------
INPUT NUMBER 'Enter the minimum length of lines or arcs to select' $minsize
FILTERBUTTON FilterItems
SelectType Arc Line
All
accept
LET l_list = {}

//
LET numturn = selection.number

WHILE $numturn {
   LET s_line = $numturn - 1
   LET l_name = selection.object[$s_line].name
   IF (selection.type[$s_line] == 'Line') {
      LET l_len = line[$l_name].length
   } ELSE {
      LET l_len = arc[$l_name].length
   }
   LET type = (selection.type[$s_line])
   PRINT 'Length of ' $type ' ' $l_name ' is '$l_len

   IF ($l_len < $minsize) {
      LIST_ADD $l_list END concat('ADD ';$type;' "';$l_name;'" ')
   }
   
   LET numturn = $numturn - 1
}

EVERYTHING PARTIALBOX
select clearlist
LET i = LENGTH($l_list)
WHILE $i {
   LET str = $l_list[$i]
   EXECUTE COMMAND $str
   LET $i = $i - 1
}
RETURN




Mateusz


Top
 Profile  
 
 Post subject: Re: Selecting short lines and arcs
PostPosted: Tue Mar 15, 2016 3:41 pm 
Offline
DELCAM Guru
DELCAM Guru
User avatar

Joined: Fri Oct 08, 2004 8:19 am
Posts: 445
Location: Basildon, Essex, UK
Nice work.

I wanted to use lists but didn't have time to look up the syntax required to get it to work.

Regards,

Jim


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB