REQUEST FOR A LISP ARC TO LINE

REQUEST FOR A LISP ARC TO LINE

smallƑish
Advocate Advocate
3,062 Views
23 Replies
Message 1 of 24

REQUEST FOR A LISP ARC TO LINE

smallƑish
Advocate
Advocate

Replacing multiple arcs to pline, If both end of the arcs are on an orthogonal straight line, replace the arc with a straight line, If not on an ortho stright line find out the intersection point with reference to the arc mid-point direction, and make 3 point pline.

sample drawing. attached.

 

smallish_0-1703440367060.png

 

0 Likes
Accepted solutions (4)
3,063 Views
23 Replies
Replies (23)
Message 21 of 24

Kent1Cooper
Consultant
Consultant

@smallƑish wrote:
IS that ok to share your testing code?

[I don't have any.  My comments were all just from imagining possible outcomes of different starting configurations.]

Kent Cooper, AIA
Message 22 of 24

komondormrex
Mentor
Mentor
Accepted solution

hey there,

this one is for any crossed by an arc block and got rid from command method of drawing a pline. still needs to adjust pline direction.

 

 

;*******************************************************************************************************************************************

(defun get_approximation_list (arc / approximation_steps approximation_distance approximation_point_list point_index)
	(setq approximation_steps (fix (/ (vla-get-arclength arc) (* 0.1 (vla-get-radius arc))))
		  approximation_distance (/ (vla-get-arclength arc) approximation_steps)
		  approximation_point_list (list (vlax-get arc 'startpoint))
		  point_index 0
	)
	(repeat approximation_steps
	  	(setq approximation_point_list (append approximation_point_list
											  (list (vlax-curve-getpointatdist
											  			arc
											  			(* approximation_distance (setq point_index (1+ point_index)))
													)
											  )
									   )
		)
	)
	approximation_point_list
)

;*******************************************************************************************************************************************

(defun c:sf_arc_pline (/ arc_sset block_sset vertex_list segment_vertices_raw_list pline_object number_processed)
  	(setq number_processed 0) 
	(if (setq arc_sset (ssget '((0 . "arc"))))
		(foreach arc (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex arc_sset))))
		  	(princ (strcat "\r" (itoa (setq number_processed (1+ number_processed))) " arcs of " (itoa (sslength arc_sset)) " processed"))
			(if (setq block_sset (ssget "_f" (get_approximation_list arc) (list '(0 . "insert"))))
				(progn
					(setq vertex_list (mapcar '(lambda (vertex) (mapcar '+ '(0 0) vertex)) 
									   (mapcar '(lambda (insert) (cdr (assoc 10 (entget insert))))
												(vl-remove-if 'listp (mapcar 'cadr (ssnamex block_sset)))
									   )
							  )
					)
					(foreach segment (setq segment_list (mapcar 'list vertex_list (cdr vertex_list)))
						(setq segment_vertices_raw_list (apply 'append (list (car segment) 
													(list (car (car segment)) (cadr (cadr segment))) 
													(cadr segment)
											   	)
										)  
							  pline_object (vla-addlightweightpolyline (vla-get-block 
	  												(vla-get-activelayout 
														(vla-get-activedocument 
															(vlax-get-acad-object)
														)
													)
												   )
										  		   (vlax-safearray-fill 
											   		(vlax-make-safearray vlax-vbdouble 
																(cons 1 (length segment_vertices_raw_list))
													)
										  			    segment_vertices_raw_list
										  		   )
										   )
	    					)
					)
				)
			)
		)
	)
	(princ)
)

;*******************************************************************************************************************************************

 

 

updated_2

Message 23 of 24

smallƑish
Advocate
Advocate

The remarkable aspect of the code lies in its ability to identify and link missed blocks seamlessly. Moreover, it conveniently displays the number of connections in the command line, greatly facilitating the counting of light numbers and the calculation of electrical load. @komondormrex  you seem like a core figure in electrical engineering.

0 Likes
Message 24 of 24

smallƑish
Advocate
Advocate

Yeah, even if we ignore the landing length issues and block center point issues, considering they can be fixed manually. I have tried all those options. It's coming  8x4= 24 Options. I realized that it's not complex, need to say very complex or impossible. 

 

smallish_0-1704001896026.png

 

in any case, it happens. It will be an asset to all upcoming cad users who are looping. forever!

 

0 Likes