SelectionCycling with given point

SelectionCycling with given point

johnyDFFXO
Advocate Advocate
525 Views
6 Replies
Message 1 of 7

SelectionCycling with given point

johnyDFFXO
Advocate
Advocate

Does anyone have some idea of how to get the SelectionCycling menu with a given point? 

Or better yet, mimic the same functionality with ssget? In other words, get all objects (inc. hatch-solids) within the cursor active area.

TIA

0 Likes
526 Views
6 Replies
Replies (6)
Message 2 of 7

paullimapa
Mentor
Mentor

The key has to do with this selection filter code which will select everything within the aperture area:

(ssget "_+.:E:S")

The attached ssel.lsp lisp function kind of mimics selection cycling but at the command line and without highlighting the object...also hatch object can only be part of the selection process if one of the corners of the hatch pattern is in the aperture area:

paullimapa_4-1744406891915.png

 

paullimapa_5-1744406916066.png

 

paullimapa_6-1744406936027.png

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 7

Kent1Cooper
Consultant
Consultant

@johnyDFFXO wrote:

... how to get the SelectionCycling menu with a given point? 

Or ... mimic the same functionality with ssget? In other words, get all objects ... within the cursor active area.


I don't quite understand....  By "SelectionCycling menu" do you mean getting this kind of selection choice?

Kent1Cooper_0-1744652994030.png

Regular (ssget) lets you select things that way.  But it won't get all objects within the pickbox area that way, any more than doing it outside a routine will -- you need to pick one from the list.  Yes, @paullimapa's suggestion can get all objects at a specified point [i.e. via feeding the point of selection in within an AutoLisp routine], but without that selection option/menu.  And besides, if you want all objects, what is the point of involving selection cycling at all?

Kent Cooper, AIA
0 Likes
Message 4 of 7

komondormrex
Mentor
Mentor

@johnyDFFXO wrote:

Does anyone have some idea of how to get the SelectionCycling menu with a given point? 


i do. something simple like this. but point is getting via mouse click.

(defun c:selection_cycling nil
  (setvar 'selectioncycling 2)
  (sssetfirst nil (ssget ":S"))
  (setvar 'selectioncycling 0)
)

 

0 Likes
Message 5 of 7

johnyDFFXO
Advocate
Advocate

Thank you guys for your responses.

 

Sorry for not being clear enough. The idea was to get a SC menu without direct user interaction. Say...

 

(setvar 'selectioncycling 0)
(setq pnt (getpoint))
;; some stuff
(setvar 'selectioncycling 2)
(nentselp pnt)

 

Or better yet, without a selection cycling menu at all. Just be able to get all the objects to a list eg. (ssget ":E" pnt).

Then I can theoretically create my own menu and have total control over items and descriptions - say, I would like to show the object name AND the layer name.

 

And preferably without compromises such as not being able to select solid hatches from an area.

 

 

 

0 Likes
Message 6 of 7

Moshe-A
Mentor
Mentor

@johnyDFFXO  hi,

 

check this PB command

 

enjoy

Moshe

 

 

(defun c:pb (/ _calc_corner_2d ; local function
	       screenSize ax c0 p0 p1)

 (defun _cCorner_2d (func edge pt)
  (mapcar
    (function
      (lambda (x)
	(eval (list func x (* edge 0.5)))
      )
    )
    ; make sure pt is 2d
    (cond
     ((= (vl-list-length pt) 2) pt)
     ((= (vl-list-length pt) 3) (reverse (cdr (reverse pt))))
     ( t nil)
    )
  )
 ); _corner

			    
 (setq screenSize (getvar "screensize"))
 (setq ax (/ (* (car screenSize) (getvar "pickbox")) (cadr screenSize)))

 (if (and
       (setq c0 (getpoint "\nSpecify point: "))
       (setq p0 (_cCorner_2d - ax c0))
       (setq p1 (_cCorner_2d + ax c0))
     )
  (if (setq ss (ssget "_c" p0 p1))
   (sssetfirst nil ss)
   (prompt "\nNoting selected.")
  ); if
 ); if

 (princ)
)

 

 

 

0 Likes
Message 7 of 7

komondormrex
Mentor
Mentor

@johnyDFFXO 

not being clear is the reason to get lost in somebody's thoughts.

try the following function. returns a list of enames  within pickbox crossing polygon at a passed point or nil if not any. will pick only top one of stacked solid hatches, thou.

(defun pick_point_enames (point / pb_half_length pick_ename pick_sset pick_ename_list)
  (setq pb_half_length (* (getvar 'pickbox) (/ (getvar 'viewsize) (cadr (getvar 'screensize))))
	pick_ename (car (nentselp point))
  	pick_sset (ssget "_cp" (list (mapcar '+ point (mapcar '* '(-1 -1) (list pb_half_length pb_half_length)))
				     (mapcar '+ point (mapcar '* '(-1 +1) (list pb_half_length pb_half_length)))
				     (mapcar '+ point (mapcar '* '(+1 +1) (list pb_half_length pb_half_length)))
				     (mapcar '+ point (mapcar '* '(+1 -1) (list pb_half_length pb_half_length)))
			       )
                  )
        pick_ename_list (if pick_sset (setq pick_ename_list (vl-remove-if 'listp (mapcar 'cadr (ssnamex pick_sset)))))
  )
  (cond
    ((and pick_ename pick_ename_list)
      (if (not (member pick_ename pick_ename_list))
	  (setq pick_ename_list (append pick_ename_list (list pick_ename)))
      )
    )
    (pick_ename (setq pick_ename_list (list pick_ename)))
    (t) 
  )
  pick_ename_list
)

 

0 Likes