;------------------------------deneme------------------------ (defun c:SelectCirclesOnSide (/ ss line startPoint endPoint sidePoint circleList) ;; Helper function to determine if a point is to the left of a line (defun isLeft (p0 p1 p2) (> (- (* (- (car p1) (car p0)) (- (cadr p2) (cadr p0))) (* (- (car p2) (car p0)) (- (cadr p1) (cadr p0)))) 0)) ;; Select all circles in the drawing/except mavi Layer (setq ss (ssget ":L" '((0 . "CIRCLE") (-4 . "") ))) ;; Check if circles are selected (if ss (progn ;; Prompt the user to select a line (setq line (car (entsel "\nSelect the line: "))) ;; Check if the selection was valid and it's a line entity (if (and line (eq (cdr (assoc 0 (entget line))) "LINE")) (progn ;; Get the start and end points of the line (setq startPoint (cdr (assoc 10 (entget line)))) (setq endPoint (cdr (assoc 11 (entget line)))) ;; Ask the user to pick a point to determine the side (setq sidePoint (getpoint "\nPick a point to determine the side: ")) ;; Check if the point selection was valid (if sidePoint (progn ;; Determine if the picked point is on the left or right (setq side (if (isLeft startPoint endPoint sidePoint) "Left" "Right")) ;; Initialize an empty list to store the selected circles (setq circleList '()) ;; Loop through each circle and check its position relative to the line (setq i 0) (while (< i (sslength ss)) (setq circle (ssname ss i)) (setq center (cdr (assoc 10 (entget circle)))) ;; Check if the circle is on the correct side of the line (setq isLeftOfLine (isLeft startPoint endPoint center)) (if (or (and (eq side "Left") isLeftOfLine) (and (eq side "Right") (not isLeftOfLine))) (setq circleList (cons circle circleList)) ) (setq i (1+ i)) ) ;; Create a new selection set with the filtered circles (if circleList (progn (setq newSS (ssadd)) (foreach circle circleList (setq newSS (ssadd circle newSS)) ) (sssetfirst nil newSS) (princ (strcat "\nSelected circles on the " side " side.")) ) (princ "\nNo circles found on the chosen side.") ) ) (princ "\nPoint selection was invalid.") ) (princ "\nPlease select a valid line.") ) ) (princ "\nNo circles found in the drawing.") ) (princ) )