ALIGNED DIM TO DISPLAY X VALUE & Y VALUE (ROUNDED UP) & CUSTOM TEXT??

ALIGNED DIM TO DISPLAY X VALUE & Y VALUE (ROUNDED UP) & CUSTOM TEXT??

buzzytrent
Enthusiast Enthusiast
824 Views
3 Replies
Message 1 of 4

ALIGNED DIM TO DISPLAY X VALUE & Y VALUE (ROUNDED UP) & CUSTOM TEXT??

buzzytrent
Enthusiast
Enthusiast

Hi all,

 

Does anybody know how to create an aligned dimension that will display its X value (rounded up to nearest 1000mm then divided by 1000) plus some custom text, then its Y value (rounded up to the nearest 5mm).

 

As shown below

 

Annotation 2019-07-18 111421.png

 

Any help would be greatly appriciated.

 

Thankyou in advanced

0 Likes
825 Views
3 Replies
Replies (3)
Message 2 of 4

leeminardi
Mentor
Mentor

I think you should post this on the AutoCAD forum and not hear on the 3ds Max forum.

 

This is a fairly easy vlisp program if clear specs are given,  It seems like the illustration is inconsistent with the description of what you want.

 

  1.  
lee.minardi
0 Likes
Message 3 of 4

CodeDing
Advisor
Advisor

@buzzytrent ,

 

When you say "rounded up", can you please help further-clarify by answering this..

 

When "rounding up" to the nearest 5mm, if you were provided with 6mm you do indeed want this rounded to 10mm correct?

 

~DD

0 Likes
Message 4 of 4

CodeDing
Advisor
Advisor

@buzzytrent ,

 

Assuming the answer to my previous question is "yes" then give this a try. I have included some commented-out parts where you can select which layer and dimstyle (otherwise currents are used):

(defun c:XYA ( / p1 p2 e x y txt osm lyr dms)
;X/Y Aligned dim
;get points for dim
(initget 1) (setq p1 (getpoint "\nSelect First Point: "))
(initget 1) (setq p2 (getpoint p1 "\nSelect Second Point: "))
;prep
(setq osm (getvar 'OSMODE)) (setvar 'OSMODE (logior 16384 osm))
;(setq lyr (getvar 'CLAYER)) (setvar 'CLAYER "MyDimLayer")
;(setq dms (getvar 'DIMSTYLE)) (setvar 'DIMSTYLE "MyDimStyle")
;calc x/y vals
(setq x (/ (abs (- (car p2) (car p1))) 1000.0)
      y (/ (abs (- (cadr p2) (cadr p1))) 10.0))
(princ x) (princ "\n")
;round-up to nearest 1000 for x
(if (> x (fix x)) (setq x (1+ (fix x))) (setq x (fix x)))
;round-up to nearest 5 for y
(if (> (fix (+ 0.5 y)) (fix y)) (setq y (+ 5 (* 10 (fix y)))) (setq y (* 10 (fix y))))
;create dim
(command "_.DIMALIGNED" p1 p2 p2)
(if (and (setq e (entlast)) (member '(100 . "AcDbAlignedDimension") (entget e)))
  (progn
    (setq txt (strcat (itoa x) " LENGTHS @ " (itoa y)))
    (setpropertyvalue e "DimensionText" txt)
  );progn
;else
  (prompt "\n...no dimension created.")
);if
;restore
(setvar 'OSMODE osm)
;(setvar 'CLAYER lyr)
;(setvar 'DIMSTYLE dms)
;finish
(prompt "\nXYA Complete...")
(princ)
);defun

Best,

~DD

0 Likes