devitg Posted July 25, 2023 Posted July 25, 2023 7 hours ago, Hải_Duy said: @Hải_Duy Please upload your sample.dwg Quote
devitg Posted August 2, 2023 Posted August 2, 2023 @Hải_Duy why not to use dim arc length? And not override the 3 point angular dimension abc-01.dwg Quote
Hải_Duy Posted August 3, 2023 Author Posted August 3, 2023 (edited) this is i am assuming a short and want to have a lisp that adjusts polyline to dimension distance so with many spacing lines overlapping polyline like this you have an idea to adjust distance from polyline to line size ? 123.dwg Edited August 3, 2023 by Hải_Duy Quote
Tsuky Posted August 3, 2023 Posted August 3, 2023 This can help you? (vl-load-com) (defun c:Dim_PolyArc ( / js AcDoc modelSpace n ename obj pr dist_start dist_end pt_start pt_end pt_sel seg_len seg_bulge pos offset ang_base ang rad alpha pt_cen) (princ "\nSelect polylines.") (while (null (setq js (ssget '((0 . "LWPOLYLINE"))))) (princ "\nSelection is empty, or aren't POLYLINES!") ) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) modelSpace (vla-get-ModelSpace Acdoc) ) (vla-StartUndoMark AcDoc) (repeat (setq n (sslength js)) (setq ename (ssname js (setq n (1- n))) obj (vlax-ename->vla-object ename) pr -1 ) (repeat (fix (vlax-curve-getEndParam obj)) (setq dist_start (vlax-curve-GetDistAtParam obj (setq pr (1+ pr))) dist_end (vlax-curve-GetDistAtParam obj (1+ pr)) pt_start (vlax-curve-GetPointAtParam obj pr) pt_sel (vlax-curve-GetPointAtParam obj (+ pr 0.5)) pt_end (vlax-curve-GetPointAtParam obj (1+ pr)) seg_len (- dist_end dist_start) seg_bulge (vla-GetBulge obj pr) ang_base (angle pt_start pt_end) ) (if (or (not offset) (and (not (eq (getvar "USERR1") (* pi 0.5))) (not (eq (getvar "USERR1") (* pi 1.5))))) (progn (initget 1) (setq pos (getpoint pt_sel "\nPosition for all dimensions: ") offset (distance pt_sel pos) ang (angle pt_sel pos) ) (setvar "USERR1" (if (eq (rem pi (- ang ang_base)) pi) (* 0.5 pi) (* 1.5 pi))) ) ) (if (not (zerop seg_bulge)) (progn (setq rad (/ seg_len (* 4.0 (atan seg_bulge))) alpha (+ (angle pt_start pt_end) (- (* pi 0.5) (* 2.0 (atan seg_bulge)))) pt_cen (polar pt_start alpha rad) ) (vlax-put (vla-AddDimAngular modelSpace (vlax-3d-point pt_cen) (vlax-3d-point pt_start) (vlax-3d-point pt_end) (vlax-3d-point (polar pt_sel (+ ang_base (getvar "USERR1")) offset)) ) 'TextOverride (vl-string-subst (getvar "DIMDSEP") "." (rtos seg_len (getvar "DIMLUNIT") (getvar "DIMDEC"))) ) ) (vla-AddDimAligned modelSpace (vlax-3d-point pt_start) (vlax-3d-point pt_end) (vlax-3d-point (polar pt_sel (+ ang_base (getvar "USERR1")) offset)) ) ) ) ) (vla-EndUndoMark AcDoc) (prin1) ) 3 Quote
Hải_Duy Posted August 4, 2023 Author Posted August 4, 2023 this is what i need for my work, thank you very much 13 hours ago, Tsuky said: This can help you? (vl-load-com) (defun c:Dim_PolyArc ( / js AcDoc modelSpace n ename obj pr dist_start dist_end pt_start pt_end pt_sel seg_len seg_bulge pos offset ang_base ang rad alpha pt_cen) (princ "\nSelect polylines.") (while (null (setq js (ssget '((0 . "LWPOLYLINE"))))) (princ "\nSelection is empty, or aren't POLYLINES!") ) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) modelSpace (vla-get-ModelSpace Acdoc) ) (vla-StartUndoMark AcDoc) (repeat (setq n (sslength js)) (setq ename (ssname js (setq n (1- n))) obj (vlax-ename->vla-object ename) pr -1 ) (repeat (fix (vlax-curve-getEndParam obj)) (setq dist_start (vlax-curve-GetDistAtParam obj (setq pr (1+ pr))) dist_end (vlax-curve-GetDistAtParam obj (1+ pr)) pt_start (vlax-curve-GetPointAtParam obj pr) pt_sel (vlax-curve-GetPointAtParam obj (+ pr 0.5)) pt_end (vlax-curve-GetPointAtParam obj (1+ pr)) seg_len (- dist_end dist_start) seg_bulge (vla-GetBulge obj pr) ang_base (angle pt_start pt_end) ) (if (or (not offset) (and (not (eq (getvar "USERR1") (* pi 0.5))) (not (eq (getvar "USERR1") (* pi 1.5))))) (progn (initget 1) (setq pos (getpoint pt_sel "\nPosition for all dimensions: ") offset (distance pt_sel pos) ang (angle pt_sel pos) ) (setvar "USERR1" (if (eq (rem pi (- ang ang_base)) pi) (* 0.5 pi) (* 1.5 pi))) ) ) (if (not (zerop seg_bulge)) (progn (setq rad (/ seg_len (* 4.0 (atan seg_bulge))) alpha (+ (angle pt_start pt_end) (- (* pi 0.5) (* 2.0 (atan seg_bulge)))) pt_cen (polar pt_start alpha rad) ) (vlax-put (vla-AddDimAngular modelSpace (vlax-3d-point pt_cen) (vlax-3d-point pt_start) (vlax-3d-point pt_end) (vlax-3d-point (polar pt_sel (+ ang_base (getvar "USERR1")) offset)) ) 'TextOverride (vl-string-subst (getvar "DIMDSEP") "." (rtos seg_len (getvar "DIMLUNIT") (getvar "DIMDEC"))) ) ) (vla-AddDimAligned modelSpace (vlax-3d-point pt_start) (vlax-3d-point pt_end) (vlax-3d-point (polar pt_sel (+ ang_base (getvar "USERR1")) offset)) ) ) ) ) (vla-EndUndoMark AcDoc) (prin1) ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.