В продолжении форумной темы об отрисовке размера с/без дуги на дуге, окружности расширенная версия с добавленной возможностью выбора дугового сегмента полилинии и переключение по пробелу привязки размерного текста к курсору или к середине дугового размера.
;************************************************************************************************************************************************************
; koMon, май 2024
;************************************************************************************************************************************************************
(defun get_center_point (start_point end_point bulge)
(polar (polar start_point (angle start_point end_point) (* 0.5 (distance start_point end_point)))
(- (angle start_point end_point) (* 0.5 pi))
(/ (* 0.5 (distance start_point end_point)) (/ (sin (- pi (* 2 (atan bulge)))) (cos (- pi (* 2 (atan bulge))))))
)
)
;************************************************************************************************************************************************************
(defun c:dim_arc (/ circle arc_bearing_data center bulge start_param is_pline dim_arc_point_1 arc_point_list dim_arc_textposition dim_arc
arc centered is_pline dim_reset
)
(setq centered t)
(while (null circle)
(setq arc_bearing_data (entsel "\nВыберите окружность/дугу/дуговой сегмент полилинии: "))
(cond
((null arc_bearing_data) (setq circle nil))
((member (cdr (assoc 0 (entget (setq circle (car arc_bearing_data))))) '("ARC" "CIRCLE"))
(setq center (vlax-get (vlax-ename->vla-object circle) 'center))
)
((and (= "LWPOLYLINE" (cdr (assoc 0 (entget circle))))
(not (zerop (setq bulge (vla-getbulge (vlax-ename->vla-object circle)
(setq start_param
(fix (vlax-curve-getparamatpoint circle
(vlax-curve-getclosestpointto
circle
(trans (cadr arc_bearing_data) 1 0)
)
)
)
)
)
)
)
)
(setq is_pline t)
)
(setq center (get_center_point (vlax-curve-getpointatparam circle start_param) (vlax-curve-getpointatparam circle (1+ start_param)) bulge))
)
(t (setq circle nil))
)
)
(setq dim_arc_point_1 (trans (vlax-curve-getclosestpointto circle (trans (getpoint "\nУкажите первую точку дугового размера: ") 1 0)) 0 1)
dim_arc_point_2 (trans (vlax-curve-getclosestpointto circle (trans (getpoint dim_arc_point_1 "\nУкажите вторую точку дугового размера: ") 1 0)) 0 1)
)
(if is_pline
(progn
(if (< (vlax-curve-getparamatpoint circle (trans dim_arc_point_1 1 0)) start_param)
(setq dim_arc_point_1 (trans (vlax-curve-getpointatparam circle start_param) 0 1))
)
(if (> (vlax-curve-getparamatpoint circle (trans dim_arc_point_1 1 0)) (1+ start_param))
(setq dim_arc_point_1 (trans (vlax-curve-getpointatparam circle (1+ start_param)) 0 1))
)
(if (< (vlax-curve-getparamatpoint circle (trans dim_arc_point_2 1 0)) start_param)
(setq dim_arc_point_2 (trans (vlax-curve-getpointatparam circle start_param) 0 1))
)
(if (> (vlax-curve-getparamatpoint circle (trans dim_arc_point_2 1 0)) (1+ start_param))
(setq dim_arc_point_2 (trans (vlax-curve-getpointatparam circle (1+ start_param)) 0 1))
)
)
)
(setq arc_point_list (list dim_arc_point_1 dim_arc_point_2)
dim_arc_textposition dim_arc_point_2
dim_arc (vla-adddimarc (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-3d-point center)
(vlax-3d-point (trans dim_arc_point_1 1 0))
(vlax-3d-point (trans dim_arc_point_2 1 0))
(vlax-3d-point dim_arc_textposition)
)
arc (vla-addarc (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-3d-point center)
(distance center (trans (car arc_point_list) 1 0))
(angle center (trans (car arc_point_list) 1 0))
(angle center (trans (cadr arc_point_list) 1 0))
)
)
(vla-put-color arc 230)
(vla-put-lineweight arc 50)
(princ "\n<ЛКМ> дуга + размер дуги, <ПКМ> дуга")
(while (and (setq dim_arc_textposition (grread t 5 0)) (not (member (car dim_arc_textposition) '(3 25))))
(if (= 5 (car dim_arc_textposition))
(progn
(if centered
(if dim_reset
(progn
(vla-erase dim_arc)
(setq dim_arc (vla-adddimarc (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))
(vlax-3d-point center)
(vlax-3d-point (trans dim_arc_point_1 1 0))
(vlax-3d-point (trans dim_arc_point_2 1 0))
(vlax-3d-point (cadr dim_arc_textposition))
)
dim_reset nil
)
)
(vlax-put dim_arc 'textmovement 0)
)
(progn
(vlax-put dim_arc 'textmovement 0)
(vlax-put dim_arc 'textposition (cadr dim_arc_textposition))
(setq dim_reset t)
)
)
(vlax-put dim_arc 'arcpoint (trans (cadr dim_arc_textposition) 1 0))
(if (not (equal (vla-get-measurement dim_arc) (vla-get-arclength arc) 1e-6))
(progn
(setq arc_point_list (reverse arc_point_list))
(vla-put-startangle arc (angle center (trans (car arc_point_list) 1 0)))
(vla-put-endangle arc (angle center (trans (cadr arc_point_list) 1 0)))
)
)
)
(if (equal '(2 32) dim_arc_textposition) (setq centered (not centered)))
)
)
(if (= 25 (car dim_arc_textposition)) (vla-erase dim_arc))
(princ)
)
;************************************************************************************************************************************************************

