PDA

View Full Version : Is possible to select entities from a selection set obtained by using ssget command?


tany0070
2007-03-08, 09:01 AM
hi i would like to know if it is possible to select entities from a selection set obtained by using ssget command, and process the entities for point coordinates (eg center point of circle square, extreme points of a square or end points of a line). thank you.

abdulhuck
2007-03-08, 02:12 PM
hi i would like to know if it is possible to select entities from a selection set obtained by using ssget command, and process the entities for point coordinates (eg center point of circle square, extreme points of a square or end points of a line). thank you.Hi,

Try the following code. This will select all the circles in a drawing and draw a line.


(defun c:fc (/ circles numCircle cenCircle radCircle count cEnt LineStPt LineEdPt)
(setq circles (ssget "x" '((0 . "Circle")))) ; select all the circles
(if circles ; if circles found
(progn
(setq numCircle (sslength circles) ; total number of circles in the selection
count 0 ; initiate a counter
)
(repeat numCircle
(setq cEnt (entget (ssname circles count))) ; entity data
(setq cenCircle (cdr (assoc 10 cEnt))) ; center of the circle
(setq radCircle (cdr (assoc 40 cEnt))) ; radius of the circle
(setq LineStPt (polar cenCircle (dtr 180) radCircle); determine start point of a line
LineEdPt (polar cenCircle (dtr 0) radCircle); end point of the line

)
(entmake
(list
'(0 . "LINE")
'(100 . "AcDbLine")
(cons 10 LineStPt)
(cons 11 LineEdPt)
)
) ; draw the line

(setq count (1+ count)) ; do for the next circle
) ; end of repeat
) ; progn
) ; if
(princ)
)
; function to covert degree to radian angle
(defun dtr (a)
(* pi (/ a 180))
)


Similar for all the entities, but have a look at entities group codes.

Regards,

Abdul Huck