Move the two circles to the line endpoints and trim the line in side the circle.

Move the two circles to the line endpoints and trim the line in side the circle.

arpansark0544TCX
Advocate Advocate
1,877 Views
22 Replies
Message 1 of 23

Move the two circles to the line endpoints and trim the line in side the circle.

arpansark0544TCX
Advocate
Advocate

Dear All, 

 

I am working on a project where I have to move a cluster of two circles to the endpoints of the line which is exactly 3 units (mtr lets say ) long. 

 

I tried to code a basic code which is attached below.

 

Kindly help me to do the following things.

1. the user can select two circles and the line (which can be at any angle).

2. As mention the line is 3 mtr long and the center of the circle should be at the endpoints of the line.

3. After the center are placed at the end points the user shall have option to trim/delete the line coming inside the circle.

 

I have posted the snap of  the after and before the code is applied.

I have also attached the DWG file for the same.

The dimension is for illustration only. there is no need for the dimension.

 

Kindly help me to rewrite the code attached.

 

Very much thank you for your support.

 

 

 

 

 

arpansark0544TCX_0-1722085991947.pngarpansark0544TCX_1-1722086004198.png

 

 

0 Likes
1,878 Views
22 Replies
Replies (22)
Message 21 of 23

arpansark0544TCX
Advocate
Advocate
Sure let me see.
0 Likes
Message 22 of 23

arpansark0544TCX
Advocate
Advocate

Sure Sir, Will test it out. I think it will work for sure now. Will let you know.

0 Likes
Message 23 of 23

komondormrex
Mentor
Mentor
Accepted solution

hey there,

check this one

(defun c:move_circle (/ lines_sset fuzz circle_sset circle line_points_list)
	(setq lines_sset (ssget "_x" '((0 . "line")))
		  fuzz 0.5
	)
	(if lines_sset
		(foreach line (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex lines_sset))))
			(if (equal 3 (vla-get-length line) 1e-3)
				(mapcar '(lambda (point)
							(if (and
									(setq circle_sset (ssget "_x" (list '(0 . "circle")
															    		'(-4 . "<and")
															   				'(-4 . ">,>,*") (list 10 (- (car point) fuzz) (- (cadr point) fuzz))
																			'(-4 . "<,<,*") (list 10 (+ (car point) fuzz) (+ (cadr point) fuzz))
															    		'(-4 . "and>")
														  		  )
											  		  )
									)
									(= 1 (sslength circle_sset))
								)
								(progn
									(vla-move (setq circle (vlax-ename->vla-object (ssname circle_sset 0))) 
											  (vla-get-center circle)
											  (vlax-3d-point point)
									)
									(vlax-put line (if (equal point (vlax-get line 'endpoint)) 'endpoint 'startpoint)
												   (polar point (angle point (car (vl-remove point line_points_list))) (vla-get-radius circle))
									)
								)
							)
						)
						(setq line_points_list (list (vlax-get line 'startpoint) (vlax-get line 'endpoint)))
				)
			)
		)
	)
	(princ)
)