DIMSTYLE to display angular measurements in decimal degrees and radians

DIMSTYLE to display angular measurements in decimal degrees and radians

kczerwonka
Advocate Advocate
1,243 Views
15 Replies
Message 1 of 16

DIMSTYLE to display angular measurements in decimal degrees and radians

kczerwonka
Advocate
Advocate

I need a Dimension Style that displays angular measurements in both decimal degrees and in radians. I do not know how to accomplish this. Please help.

0 Likes
1,244 Views
15 Replies
Replies (15)
Message 2 of 16

pendean
Community Legend
Community Legend
That's not a built-in feature of DIMSTYLE command in AutoCAD. Sorry
Do you want to try a customized solution instead or is that a no-go for you?
0 Likes
Message 3 of 16

kczerwonka
Advocate
Advocate
Yes, a custom solution would be great. But I do not know how to do it.
0 Likes
Message 4 of 16

Kent1Cooper
Consultant
Consultant

It is kind of unexpected that alternate units are only usable with length-type Dimensions, not angular.

A workaround:  Create two Dimension Styles, both with the text aligned with the dimension line [arc in the case of angular Dimensions], with one using degrees with the text above the dimension arc, and the other using radians with the text below [or vice versa].  Copy a Dimenion in place, and have one of them in each Dimension Style.

Kent1Cooper_0-1706726118640.png

An AutoLisp routine could easily enough be made to do the Copying and assigning the other Style to the copy.

 

Kent Cooper, AIA
0 Likes
Message 5 of 16

kczerwonka
Advocate
Advocate
Thank you for the suggestion. But, I wanted to avoid using two separate, or overlapping and individual dimensions. My goal is to have all the info in a single dimension.

Would it be possible to have a routine that when an angular dimension is selected, the routine would evaluate the existing dim text and mathematically solve for radians and then overwrite the existing dim text by adding the resulting radian text below the existing dim text?
0 Likes
Message 6 of 16

Kent1Cooper
Consultant
Consultant

@kczerwonka wrote:
.... Would it be possible ... when an angular dimension is selected, the routine would evaluate the existing dim text and mathematically solve for radians and then overwrite the existing dim text by adding the resulting radian text below the existing dim text?

That would be possible.  The advantage of living with two overlapping Dimension objects is that they will both update appropriately if things are altered, such as by Stretching or grip-editing.  What you're looking for would involve a text-content override, and if things are altered, the "real" degrees text part will update appropriately [assuming the routine retains the actual measured value], but the added radian text part of the override will not.  You might not notice that you need to strip the override and run the routine again to re-establish it, so you could end up with an erroneous value.

Kent Cooper, AIA
0 Likes
Message 7 of 16

Sea-Haven
Mentor
Mentor

. As suggested by Kent if need to reflect changes then will  need a field.

SeaHaven_1-1706752091975.png

 

Try This

; Dim deg and radians for angle of arc
; By AlanH Feb 2024

(defun c:dimraddeg ( / ent ent2 obj start end angr angd deg mins secs str)
(setq ent (car  (entsel "Pick Arc for deg & Rads ")))
(setq obj (vlax-ename->vla-object ent))
(setq start (vlax-get obj 'startangle))
(setq end (vlax-get obj 'endangle))
(setq angr (- end start))
(setq angd (/ (* angr 180.0) pi))
(setq deg (fix angd))
(setq mins (* (- angd deg) 60.))
(setq min (fix mins))
(setq secs (* (- mins min) 60.))
(setq deg (strcat (rtos deg  2 0) "%%d" (rtos min 2 0) "'" (rtos secs 2 2) "\""))
(prompt "\npick point for dim ")
(command "dimarc" ent pause)
(setq ent2 (entget (entlast)))
(setq str (strcat deg "\\P" (rtos angr 2 4)))
(entmod (subst (cons 1 str) (assoc 1 ent2) ent2))
(princ)
)
(c:dimraddeg)

I know need to look at internal external angles problems but for now test this.

 

0 Likes
Message 8 of 16

ВeekeeCZ
Consultant
Consultant

Or like this

 

(defun c:Dangr ( / s i e)
  (princ "\nSelect angular dimensions to add value in radians, ") 
  (if (setq s (ssget "_:L" '((0 . "DIMENSION") (1 . "") (-4 . "<OR") (-4 . "&") (70 . 2) (-4 . "&") (70 . 5) (-4 . "OR>"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (setpropertyvalue e "DimensionText" (strcat "<> [" (rtos (getpropertyvalue e "AngularMeasurement") 2 3) "r]"))))
  (princ)
  )

 

0 Likes
Message 9 of 16

kczerwonka
Advocate
Advocate
This is great. 99 percent there.
The only other thing I would like is for the radian portion of the dimension to also automatically update when the measured angle changes.
Is that possible?
Other than that, this is perfect, exactly what I am looking for.
Thank you very much.

0 Likes
Message 10 of 16

ВeekeeCZ
Consultant
Consultant

@kczerwonka wrote:
This is great. 99 percent there.
The only other thing I would like is for the radian portion of the dimension to also automatically update when the measured angle changes.
Is that possible?
Other than that, this is perfect, exactly what I am looking for.
Thank you very much.


 

Of course, yes, anything is possible. But that.. actually that makes 99% left to do, so it makes it No.

Or get back to Kent's suggestion.

0 Likes
Message 11 of 16

kczerwonka
Advocate
Advocate
OK. Thank you very much for your help.
0 Likes
Message 12 of 16

kczerwonka
Advocate
Advocate
This could work... the only other thing I would like is for the radian portion of the dimension to also automatically update when the measured angle changes.
Kent mentioned using a field, is that possible?
0 Likes
Message 13 of 16

Kent1Cooper
Consultant
Consultant

@kczerwonka wrote:
.... using a field, is that possible?

I tried editing a Dimenion's text content manually to introduce a Field for the radian measurement, but I couldn't find a way.  In ordinary Mtext, I can make a Field of a Dimension's radian measurement, using the "Object" Field name, the "Measurement" property, and "Radians" Format.  But in editing the text of a Dimension, even though otherwise it works like editing Mtext, trying the "Object" Field name and selecting the Dimension itself again results in:

Kent1Cooper_0-1706795858460.png

I assume it has something to do with that Object being already "open" for editing.

 

I do find, though, that if I create an Mtext object containing such a Field, copy its content to the clipboard, and then go into Dimension text editing and paste that in there, it works.  [It shows up in the pasting as ####, but with REGEN it takes on the value.]  And it does update upon alteration of the Dimension [again, with REGEN].  Whether that can be automated, I'm not sure, and even if so, I assume it would need to be done for each Dimension, i.e. it couldn't be part of a Dimension Style definition.

Kent Cooper, AIA
Message 14 of 16

ВeekeeCZ
Consultant
Consultant

Nice one, Kent. Would not think it's possible. It's silly that it cannot be done the expected way.

 

(vl-load-com)

(defun c:Dangr ( / GetObjectID s i e)
  
  (defun GetObjectID ( obj doc )
    (if (eq "X64" (strcase (getenv "PROCESSOR_ARCHITECTURE")))
      (vlax-invoke-method
	(vla-get-Utility doc) 'GetObjectIdString obj :vlax-false)
      (itoa (vla-get-Objectid obj))))
  
  (princ "\nSelect angular dimensions to add value in radians, ")
  (if (setq s (ssget "_:L" '((0 . "DIMENSION") (1 . "") (-4 . "<OR") (-4 . "&") (70 . 2) (-4 . "&") (70 . 5) (-4 . "OR>"))))
    (repeat (setq i (sslength s))
      (setq e (ssname s (setq i (1- i))))
      (setpropertyvalue e "DimensionText" (strcat "<> [%<\\AcObjProp Object(%<\\_ObjId "
						  (GetObjectID (vlax-ename->vla-object e) (vla-get-ActiveDocument (vlax-get-acad-object)))
						  ">%).Measurement \\f \"%au3%pr2\">%]"))))
  (vla-regen (vla-get-ActiveDocument (vlax-get-acad-object)) acActiveViewport)
  (princ)
  )

 

0 Likes
Message 15 of 16

kczerwonka
Advocate
Advocate

OK. I am leaning toward going with you suggestion of using two dimstyles. I like that this approach keeps the asccociativity of the geometry and dimension intact. I can live with having to place the additional dimension.


I created the two dimstyles as suggested and tested the theory. However, I found that when a change is made to the geometry and the dimension is updated, the vertical text alignments return to center positions. Even though the respective dimstyles and vertical text alignment properties in the properties pallet still show the alignments as being above or below.

 

I attached a simple drawing I am using for testing.  

0 Likes
Message 16 of 16

Sea-Haven
Mentor
Mentor

Measurement is length ? Need totalangle, need to use a formula style answer and do the field twice once for radians and once for decimals. But in one string. 

 

D M S
%<\AcObjProp Object(%<\_ObjId 649882272>%).TotalAngle \f "%au1">%
Radian
%<\AcObjProp Object(%<\_ObjId 649882272>%).TotalAngle>%

 Will try to do lunch is calling.

0 Likes