Jump to content

Change entsel to ssget


GLORY

Recommended Posts

Hello everyone i have this code that im working for sometime...


     (while (not (setq ent (car (entsel "\nSelect rectangle: ")))))
 

What i want is to change the selection option into ssget with layer filter, so that i would not pick the rectangle one by one and will do the same routine for every rectangle in the selection set.

Edited by GLORY
Link to comment
Share on other sites

Hi,

Rectify the layer name "MyLayer" in the following codes to suit yours. 

(ssget '((0 . "*POLYLINE") (8 . "MyLayer") (-4 . "<AND") (-4 . "&=") (70 . 1) (-4 . "AND>")))

 

  • Like 1
Link to comment
Share on other sites

What i did is...

     (while (not (setq en (car (ssget '((0 . "*POLYLINE") (8 . "DWG_SHEET") (-4 . "<AND") (-4 . "&=") (70 . 1) (-4 . "AND>")))))))

But the routine after that condition is not running, or should i specify the counter also?

Link to comment
Share on other sites

Its not like that.

The codes that I posted allow the user to select as many as they want then you need after that to iterate the selection set and do your stuff at each entity object.

e.g:

 (if (setq ss (ssget '((0 . "*POLYLINE") (8 . "DWG_SHEET") (-4 . "<AND") (-4 . "&=") (70 . 1) (-4 . "AND>"))))
   (repeat (setq i (sslength ss))
     (setq ent (ssname ss (setq i (1- i)))) ;; one entity which is eaual to single selection like, (car (entsel "\nSelect object :"))
     ;; do your stuff here ....
     )
   )
     

 

  • Like 2
Link to comment
Share on other sites

One more thing, i had this in mind to trim lines in specific layer automatically is possible, given say for example dwg_sheet layer as the trim boundary?

Link to comment
Share on other sites

Yes that is possible and it depends on your requirements in this case since the required codes for this task would be much, so search the forum for your key word like trim , trimming ... or so.

Good luck.

Link to comment
Share on other sites

If interpret correct  "dwg_sheet layer as the trim boundary" is this not what a layout and a viewport would do ?

 

Try Cookiecutter2.lsp or Extrim, Express option can be programmed to trim objects automatically.

Edited by BIGAL
Link to comment
Share on other sites

On 3/26/2021 at 3:06 PM, Tharwat said:

Rectify the layer name "MyLayer" in the following codes to suit yours. 


(ssget '((0 . "*POLYLINE") (8 . "MyLayer") (-4 . "<AND") (-4 . "&=") (70 . 1) (-4 . "AND>")))

 

 

For what it's worth, the (-4 . "<AND") (-4 . "AND>") logical operators are not actually required here, as the ssget filter list has an implicit AND logic.

Link to comment
Share on other sites

  • 1 year later...
10 hours ago, islasi said:

What is this for?

(-4 . "<AND") (-4 . "&=") (70 . 1) (-4 . "AND>"))

 

For a polyline, it will only select those that are closed. (More technically, selects the polyline whose "Closed" property is set to "Yes").

  • Like 2
Link to comment
Share on other sites

@islasi more info closer to the bottom of the page under "Logical Operators"

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

 

Here is a better example. This will select any polyline on Mylayer that is either color red or white.

(ssget '((0 . "*POLYLINE") (8 . "MyLayer") (-4 . "<OR") (62 . 1) (62 . 7) (-4 . "OR>")))

 

So its like two ssget's in one

(ssget '((0 . "*POLYLINE") (8 . "MyLayer") (62 . 1)))
(ssget '((0 . "*POLYLINE") (8 . "MyLayer") (62 . 7)))

 

This isn't needed for dotted pairs with strings as you can search multiple criteria with a " , "

(ssget '((0 . "*POLYLINE,CIRCLE") (8 . "MyLayer1,MyLayer2,MyLayer3") (62 . 7)))

Select any polyline or circle that are on MyLayer1 - 3 that is color white

Edited by mhupp
  • Like 1
Link to comment
Share on other sites

From the SSGET examples, I look at it that anything within a pair of brackets is OR, and different sets of brackets is AND for the selection:

 

Select

 

(Polyline OR Circle)

AND

(MyLayer1 OR MyLayer2 OR MyLayer3)

AND

((colour) 7)

 

 

 

I'll have to remember the polyline code 70, am sure it came up the other day in something I was doing.

Link to comment
Share on other sites

7 hours ago, Steven P said:

From the SSGET examples, I look at it that anything within a pair of brackets is OR, and different sets of brackets is AND for the selection:

 

There are four logical operators: AND, OR, NOT, XOR. Like you said, anything not being enclosed (or the outermost part of any nested expressions which you call "brackets") is treated using the AND operator, and any others is just as how the expressions detail it. More details on this here.

Link to comment
Share on other sites

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...