Jump to content

How can I increase the offset of the dimension line from the object?


Recommended Posts

Posted (edited)

This code sets the dimensions of the polygons.

Please tell me in which line of the code it is possible to increase the indentation of the dimension line from the object.

;;; Programm for the dimensioning of all the polygon/polyline segments
;;; Polyline must be closed or opened

oupping list ======;;

(defun group-by-num (lst num / ls ret)
 (if (= (rem (length lst) num ) 0)
 (progn
 (setq ls nil)
 (repeat (/ (length lst) num)
(repeat num (setq ls 
 (cons (car lst) ls)
 lst (cdr lst)))
(setq ret (append ret (list (reverse ls)))
 ls nil)))
 )
ret
 )

;;======= get coordinates =======;;

(defun get-vexs (pline_obj / verts)
 (setq verts (vlax-get pline_obj 'Coordinates)
 verts
 (cond
 ((wcmatch (vlax-get pline_obj 'Objectname )
 "AcDb2dPolyline,AcDb3dPolyline") 
 (group-by-num verts 3)
 )
 ((eq (vlax-get pline_obj 'Objectname )
 "AcDbPolyline") 
 (group-by-num verts 2)
 )
 (T nil)
 )
)
 ) 


;;======= get included angle =======;;

(defun dif-angle (ang1 ang2 / def)
 (set 'ang1
 (if (> ang2 (+ pi ang1))
 (+ (* pi 2) ang1)
 ang1
 )
 )
 (set 'ang2
 (if (> ang1 (+ pi ang2))
 (+ (* pi 2) ang2)
 ang2
 )
 )
 (setq def (- ang2 ang1))
)

;;======= CW-CCW test =======;;
;; (angdir=0)
(defun ccw-test (pt_list / angle_list)
 (setq angle_list
 (mapcar (function (lambda (x y)
 (angle x y)
 )
 )
 pt_list
 (cdr pt_list)
 )
 )
 (if (> (apply '+
 (mapcar (function (lambda (x y) (dif-angle x y)))
 angle_list
 (cdr angle_list)
 )
 )
 0
 )
 t
 nil
 )
)
;; *** main programm ***

(defun C:dmp (/ *Error* *Debug* acsp adoc blg cen chord coors
 dm dop ent gap hgt mid param_list pl rad ss txp)
;Fatty () 2005 
;thanks to Robert R.Bell for the credit of error handler function
 (vl-load-com)
 (defun *Error* (msg)
 (cond ((not msg))
((member msg '("Function cancelled" "quit / exit abort")))
((princ (strcat "\nError: " msg))
 (cond (*Debug* (vl-bt)))
)
 )
 (vla-endundomark
(vla-get-activedocument (vlax-get-acad-object))
 )
)
 (if (< (atof (getvar "ACADVER")) 15.06)
 (alert "Impossible to use this lisp \nin version less than A2000")
 (progn
 (vl-load-com)
 (or adoc (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
 (or acsp (setq acsp
 (if (or (= (getvar "TILEMODE") 1)
 (> (getvar "CVPORT") 1))
 (vla-get-modelspace adoc)
 (vla-get-paperspace adoc)
 )
)
 )
 (vla-startundomark
adoc
 )
 (if 
 (setq ss (ssget "_:S:E:L" '((0 . "*POLYLINE"))))
 (progn 
 (setq pl (vlax-ename->vla-object
 (ssname ss 0)
 )
 )
(setq coors (get-vexs pl))
 (if (eq :vlax-true (vla-get-closed pl))
 (setq coors (append coors (list (car coors)))))
 (if (ccw-test coors)(setq dop pi)(setq dop 0)) 
(setq param_list (mapcar (function (lambda (x)
 (fix (vlax-curve-getparamatpoint pl x))))
 (mapcar (function (lambda (y)(trans y 0 1))) coors)))
(setq gap (getvar "dimtxt"))
(mapcar (function (lambda (x y z) 
(cond
((not (zerop (setq blg (vla-getbulge pl x))))
(progn
(setq hgt (* 4 (atan (abs blg)))
chord (distance y z)
rad (abs (/ chord 2 (sin (/ hgt 2))))
mid (trans (vlax-curve-getpointatparam pl (+ (fix x) 0.5)) 0 1)
cen (trans (polar y (if (minusp blg)(-(angle y z)(-(/ pi 2)(/ hgt 2)))
 (+(angle y z)(-(/ pi 2)(/ hgt 2)))) rad) 0 1)
txp (trans (polar mid (if (minusp blg)(angle cen mid)
 (angle mid cen)) gap) 0 1)
)
(setq dm (vla-adddim3pointangular acsp
 (vlax-3d-point cen)
 (vlax-3d-point y)
 (vlax-3d-point z)
 (vlax-3d-point txp)))
(vla-put-textoverride dm (rtos (abs (- (vlax-curve-getdistatpoint pl y)
 (vlax-curve-getdistatpoint pl z))) 2 2)))
)
(T (progn
 (setq mid (trans (vlax-curve-getpointatparam pl (+ (fix x) 0.5)) 0 1))
 (setq txp (trans (polar mid (+ dop (angle y z) (/ pi 2)) gap) 0 1))
 (vla-adddimaligned acsp 
 (vlax-3d-point y)
 (vlax-3d-point z)
 (vlax-3d-point txp))

)
))))
param_list
coors
(cdr coors)))
 )
 )
 )
 (vla-endundomark
 adoc
 )
 (*Error* nil) 
 (princ)
)

(prompt "\n\t***\tProgramm loaded\t***\n")
(prompt "\nStart command with DMP\n")
(princ)

 

dmp.png

Edited by Nikon
Posted

Try changing this line :

(setq gap (getvar "dimtxt"))

To this line :

(setq gap (* 2.0 (getvar "dimtxt")))

  • Like 2
Posted (edited)
  On 2/1/2025 at 5:50 PM, marko_ribar said:

Try changing this line :

(setq gap (getvar "dimtxt"))

To this line :

(setq gap (* 2.0 (getvar "dimtxt")))

Thanks, it helped!

dmp2.png

Edited by Nikon

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...