How to Convert Aligned Dimension to Rotated/Linear Dimension

How to Convert Aligned Dimension to Rotated/Linear Dimension

vsanchezT8AAJ
Community Visitor Community Visitor
11,315 Views
18 Replies
Message 1 of 19

How to Convert Aligned Dimension to Rotated/Linear Dimension

vsanchezT8AAJ
Community Visitor
Community Visitor

How to Convert Aligned Dimension to Rotated/Linear Dimension

0 Likes
11,316 Views
18 Replies
Replies (18)
Message 2 of 19

john.vellek
Alumni
Alumni

Hi @vsanchezT8AAJ,

 

I see that you are visiting as a new member to the AutoCAD forum. Welcome to the Autodesk Community!

 

 The dimension is an object so I don't know of a way to remove the object "Type" and change to another.  What is the problem you are facing? Perhaps there is another way to get things dimensioned the way you want.

 

You can also take a look at the AutoCAD App Store for dimensioning utilities.

 

 

Please select the Accept as Solution button if my post solves your issue or answers your question.


John Vellek


Join the Autodesk Customer Council - Interact with developers, provide feedback on current and future software releases, and beta test the latest software!

Autodesk Knowledge Network | Autodesk Account | Product Feedback
0 Likes
Message 3 of 19

jayhar
Advisor
Advisor

Hi,

If you Convert Aligned Dimension to Rotated/Linear Dimension, but dimension line does not come Vertical.

 

Copy/past code in command line, and command CHANGEDIMOBJECT

(defun dtr (deg) (* (/ deg 180.0) pi))

 

or

 

Download .lsp

Watch this video https://autode.sk/2zPTvZt

 

Please Mark the Post or Posts as Solution(s) to help others find the answer quickly. If your issue persists,

Please give me a bit more detail on this issue so we can continue to work towards getting this solved.

AutoCAD Certified Professional

Thanks You
Jayhar.M.J

 

Helpful Links: Prepare your computer for download |  Autodesk Virtual Agent | Clean Uninstall | Steps for Setting-Up Student Software

 

Please Subscribe YouTube Channel
https://www.youtube.com/channel/UCclj8v9vHQiFa8_DriuAk3w

Please Mark the Post or Posts as Solution(s) to help others find the answer quickly.
0 Likes
Message 4 of 19

BeKirra
Advisor
Advisor

"How to convert..."

There is no dimension convert method in AutoCAD but using replace method.

 

BTW it may be off topic...

I may be wrong, but guess the aligned dimensions are created by someone else and you want to "convert" them by a few clicks.

If this is the case, the answer may be "no" in practice.

 

Because the "convert" is not any kind of magic but is actually replacing the aligned dimensions with rotated/linear dimensions. It can theoretically be done by

1. manually replacing the aligned dimensions, or

2. using a piece of add-on (e.g. LSP)

Whatever choice you make, you end up manually repositioning the dimension lines of rotated/linear dimensions.

IMO you may keep them with no changes if the "convert" is not necessary.

 

Hope this explains/helps.

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
Message 5 of 19

Kent1Cooper
Consultant
Consultant

@vsanchezT8AAJ wrote:

How to Convert Aligned Dimension to Rotated/Linear Dimension


 

If you're talking about Dimensions that are horizontal or vertical, but were drawn as Aligned ones instead of as Linear/Horizontal/Vertical ones, you can use this:

(defun C:DAL (/ dim ddata); = Dimension: Aligned to Linear
  (setq
    dim (car (entsel "\nSelect Aligned Dimension: "))
    ddata (entget dim)
  ); setq
  (command "_.dimlinear"
    "_none" (cdr (assoc 13 ddata)) "_none" (cdr (assoc 14 ddata)) "_none" (cdr (assoc 11 ddata))
  ); command
  (entdel dim)
  (princ)
); defun

It will also work on Aligned Dimensions at non-orthogonal angles, but the configuration will affect whether they end up as horizontal or vertical, and of course the dimensioned length will be different.

 

It is very basic, but could be made to verify that you picked a Dimension, and that it's an Aligned one, to allow selection of more than one at a time, and all the other usual enhancements [error handling, Undo begin/end, etc.].

Kent Cooper, AIA
Message 6 of 19

scot-65
Advisor
Advisor
Another method to replace the Aligned with a Linear
by not using LISP is to first rotate the UCS to the angle of
the aligned dimension and trace over it with command
DIMLINEAR.

One may first move the "bad" dimension to a "junk" layer,
assign the junk layer to a color that is different from that
the dimension was originally placed on, then delete
everything on that junk layer after replacing.

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 7 of 19

john.uhden
Mentor
Mentor

Visit this piece of history...

here

John F. Uhden

0 Likes
Message 8 of 19

dbhunia
Advisor
Advisor

Try this ...... this is some modification of @Kent1Cooper code...

 

(defun C:DRAL (/ dim ddata pt ptv ptn ent)
(setvar 'cmdecho 0)
  (setq
    dim (car (entsel "\nSelect Aligned Dimension: "))
    ddata (entget dim)
  )
  (initget "H V")
  (setq pl
    	(cond ((getkword "\nLinear Dimension to be Placed [Vertically/Horizontally] <Horizontally>: "))
              ("H")
    	)
  )
  (command "_.dimlinear"
    "_none" (cdr (assoc 13 ddata)) "_none" (cdr (assoc 14 ddata)) "_none" (setq pt (cdr (assoc 11 ddata)))
  )
  (entdel dim)
  (setq ent (entget(entlast)))
  (if (= pl "V")
      (progn
	(entmod (subst (cons 50 1.5708) (assoc 50 ent) ent))
	(setq ent (entget(entlast))
	      ptv (cdr (assoc 10 ent))
	)
	(setq ptn (list (car pt) (cadr ptv) (caddr ptv)))
	(entmod (subst (cons 10 ptn) (assoc 10 ent) ent))
      )
      (entmod (subst (cons 50 0.0) (assoc 50 ent) ent))
  )
(setvar 'cmdecho 1)
(princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 9 of 19

Anonymous
Not applicable

hello,

 

what if I wanted the vice ? I want to change aligned to linear dimension how can I modify the code.

 

regards

0 Likes
Message 10 of 19

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

...

what if I wanted the vice ? I want to change aligned to linear dimension ....


That's what this thread is already about.  Do you mean you want to change linear dimensions to aligned?  If so, just reversing the types in my earlier routine works for me in limited testing:

(defun C:DLA (/ dim ddata); = Dimension: Linear to Aligned
  (setq
    dim (car (entsel "\nSelect Linear Dimension: "))
    ddata (entget dim)
  ); setq
  (command "_.dimaligned"
    "_none" (cdr (assoc 13 ddata)) "_none" (cdr (assoc 14 ddata)) "_none" (cdr (assoc 11 ddata))
  ); command
  (entdel dim)
  (princ)
); defun
Kent Cooper, AIA
Message 11 of 19

john.uhden
Mentor
Mentor

Try this out (no commands involved)...

(defun @aligned2rotated (e / ent flag ang rotated)
  ;; where e is the entity name of the aligned dimension
  ;; It returns the entity name of the resulting rotated dimension
  (and
    (= (type e) 'ENAME)
    (setq ent (entget e))
    (setq flag (cdr (assoc 70 ent)))
    (= (logand flag 1) 1) ;; aligned [I think]
    (setq ent (vl-remove-if '(lambda (x)(vl-position (car x)'(-1 5))) ent))
   ;; (setq ent (subst '( 2 . "*D")(assoc 2 ent) ent)) ;; omit per BeekeeCZ (05-04-18)
    (setq ent (subst (cons 70 (boole 2 flag 1))(assoc 70 ent) ent))
    (setq ang (angle (cdr (assoc 13 ent))(cdr (assoc 14 ent))))
    (setq ent (subst (cons 50 ang)(assoc 50 ent) ent))
    (setq ent (append ent '((100 . "AcDbRotatedDimension"))))
    (or (entdel e) 1)
    (setq rotated (entmakex ent))
  )
  rotated
)

 

John F. Uhden

0 Likes
Message 12 of 19

Anonymous
Not applicable

thanks for you response I want to convert aligned dimension to DIMLINEAR 

0 Likes
Message 13 of 19

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

thanks for you response I want to convert aligned dimension to DIMLINEAR 


I repeat -- that's what this thread is already about.  What did you mean by "what if I wanted the vice ?"  Does that not mean "vice versa" or converting in the other direction?

 

Does the DAL command defined in Message 5 not do what you want?  Or the DRAL command in Message 8?  Or if the definition points are not orthogonally aligned, the suggestion in Message 6?

Kent Cooper, AIA
0 Likes
Message 14 of 19

3dwannab
Advocate
Advocate

Mod of Kents orginal code and dbhunias to work with a selection of dims. I've added error handling and undo marks.

 

 

 

 

 

 

 

;;
;; Original code here:
;; Kent1Coopers: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-convert-aligned-dimension-to-rotated-linear-dimension/m-p/8465854#M378437
;; dbhunias: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-convert-aligned-dimension-to-rotated-linear-dimension/m-p/8469614#M378460
;;
;; 3dwannab modified on 2022.02.05
;; - Add error handling and undo points.
;; - Add changing the dimension to the same that previous one.
;; - Check Annotative objects
;;
;; 3dwannab modified on 2024.05.15
;; - Fixed the newly created dim not taking the properties of the old aligned one. Style, Layer etc.
;; - Select changed dims after command has finished.

;; Quick loader for the routine.
(defun c:--LDDM_Aligned_To_Linear (/) (progn (LOAD "DM_Aligned_To_Linear") (c:DM_Aligned_To_Linear)))

;; Main routine
(defun c:DM_Aligned_To_Linear (/ *error* acDoc ansVertOrHor EntData entHor entOld pt ptn ss1 ssSel var_cmdecho var_osmode) 
  (vl-load-com)

  (defun *error* (errmsg) 
    (and acDoc (vla-EndUndoMark acDoc))
    (and errmsg 
         (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*"))
         (princ (strcat "\n<< Error: " errmsg " >>\n"))
    )

    (princ "\nExiting 'DM_Aligned_To_Linear.lsp' Program\n")
    (princ)
    (setvar 'cmdecho var_cmdecho)
    (setvar 'osmode var_osmode)
  )

  ;; Save the variable for use in the error handler
  (setq var_cmdecho (getvar "cmdecho"))
  (setq var_osmode (getvar "osmode"))

  ;; Set the variables
  (setvar 'cmdecho 0)
  (setvar 'osmode 0)

  ;; Start the undo mark here
  (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
  (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc))

  ;; Give the user the option to convert to horizontal or vertical dimensions
  (initget "H V")
  (setq ansVertOrHor (cond 
                       ((getkword "\nLinear Dimension to be Placed [Vertical/Horizontal] <Horizontal>: "))
                       ("H")
                     )
  )

  ;; My forum post here about selection different dimensions based on what type
  ;; they are.
  ;; https://www.cadtutor.net/forum/topic/71460-select-rotated-dimension/?do=findComment&comment=589429
  ; 70 33 for Aligned and 70 32 for rotated are just two examples.

  (if (setq ss1 (ssget (list (cons 0 "DIMENSION") (cons 70 33)))) 

    (progn 

      (setq ssSel (ssadd))

      (while (setq entOld (ssname ss1 0)) 
        (setq EntData (entget entOld))
        (if (not (member '(100 . "AcDbRotatedDimension") EntData)) 

          (progn 

            ;; Create the dimension for each
            (command "_.dimlinear" 
                     "_none"
                     (cdr (assoc 13 EntData))
                     "_none"
                     (cdr (assoc 14 EntData))
                     "_none"
                     (setq pt (cdr (assoc 11 EntData)))
            )

            ;; This will modify the existing new dimension to vertical if that option was chosen
            (setq entHor (entget (entlast)))
            (if (= ansVertOrHor "V") 
              (progn 
                (entmod (subst (cons 50 1.5708) (assoc 50 entHor) entHor))
                (setq entHor (entget (entlast))
                      ptv    (cdr (assoc 10 entHor))
                )
                (setq ptn (list (car pt) (cadr ptv) (caddr ptv)))
                (entmod (subst (cons 10 ptn) (assoc 10 entHor) entHor))
              ) ; End progn
              (entmod (subst (cons 50 0.0) (assoc 50 entHor) entHor))
            ) ; End if

            ;; Matches the new dim with the old aligned one
            (command "_.matchprop" "_non" entOld "_non" (entlast) "")

            ;; Add the newly created dims to a selection set for later selection
            (setq ssSel (ssadd (entlast) ssSel))

            ;; Delete the older dimension
            (entdel entOld)
          ) ; End progn
        ) ; End if

        (ssdel entOld ss1)
      ) ; End while

      (if ssSel 
        (progn 
          (sssetfirst nil ssSel)
          (command "_.REGEN")
        )
      )
    ) ; End progn
  ) ; End if ss1

  (vla-EndUndoMark acDoc)

  (*error* nil)
  (princ)
)

  ;;----------------------------------------------------------------------;;
  ;; _dxf
  ;; Finds the association pair, strips 1st element
  ;; args   - dxfcode elist
  ;; Example  - (_dxf -1 (entget (ssname (ssget) 0)))
  ;; Returns  - <Entity name: xxxxxxxxxxx>
(defun _dxf (code elist) 
  (cdr (assoc code elist))
)
(princ)

  ; (c:DM_Aligned_To_Linear) ;; unblock for testing

 

 

 

 

 

 

 

 

0 Likes
Message 15 of 19

holyhexor0o0
Contributor
Contributor

how do you add select multiple dims

0 Likes
Message 16 of 19

Kent1Cooper
Consultant
Consultant

@holyhexor0o0 wrote:

how do you add select multiple dims


See Message 14.

Kent Cooper, AIA
Message 17 of 19

holyhexor0o0
Contributor
Contributor

Thank you for replyibg

Sorry for not being specific, I was referring to message 10 for Lisp Linear to Aligned. I tried adding sset1, it didnt really convert plural objects. 

0 Likes
Message 18 of 19

Kent1Cooper
Consultant
Consultant

@holyhexor0o0 wrote:

.... I was referring to message 10 for Lisp Linear to Aligned.... 


Did my Reply in your new topic cover it?

Kent Cooper, AIA
Message 19 of 19

3dwannab
Advocate
Advocate

Updated code to do these:

;; 3dwannab modified on 2024.05.15
;; - Fixed the newly created dim not taking the properties of the old aligned one. Style, Layer etc.
;; - Select changed dims after command has finished.

 

Updated code:

;;
;; Original code here:
;; Kent1Coopers: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-convert-aligned-dimension-to-rotated-linear-dimension/m-p/8465854#M378437
;; dbhunias: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-convert-aligned-dimension-to-rotated-linear-dimension/m-p/8469614#M378460
;;
;; 3dwannab modified on 2022.02.05
;; - Add error handling and undo points.
;; - Add changing the dimension to the same that previous one.
;; - Check Annotative objects
;;
;; 3dwannab modified on 2024.05.15
;; - Fixed the newly created dim not taking the properties of the old aligned one. Style, Layer etc.
;; - Select changed dims after command has finished.

;; Quick loader for the routine.
(defun c:--LDDM_Aligned_To_Linear (/) (progn (LOAD "DM_Aligned_To_Linear") (c:DM_Aligned_To_Linear)))

;; Main routine
(defun c:DM_Aligned_To_Linear (/ *error* acDoc ansVertOrHor EntData entHor entOld pt ptn ss1 ssSel var_cmdecho var_osmode) 
  (vl-load-com)

  (defun *error* (errmsg) 
    (and acDoc (vla-EndUndoMark acDoc))
    (and errmsg 
         (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*"))
         (princ (strcat "\n<< Error: " errmsg " >>\n"))
    )

    (princ "\nExiting 'DM_Aligned_To_Linear.lsp' Program\n")
    (princ)
    (setvar 'cmdecho var_cmdecho)
    (setvar 'osmode var_osmode)
  )

  ;; Save the variable for use in the error handler
  (setq var_cmdecho (getvar "cmdecho"))
  (setq var_osmode (getvar "osmode"))

  ;; Set the variables
  (setvar 'cmdecho 0)
  (setvar 'osmode 0)

  ;; Start the undo mark here
  (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
  (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc))

  ;; Give the user the option to convert to horizontal or vertical dimensions
  (initget "H V")
  (setq ansVertOrHor (cond 
                       ((getkword "\nLinear Dimension to be Placed [Vertical/Horizontal] <Horizontal>: "))
                       ("H")
                     )
  )

  ;; My forum post here about selection different dimensions based on what type
  ;; they are.
  ;; https://www.cadtutor.net/forum/topic/71460-select-rotated-dimension/?do=findComment&comment=589429
  ; 70 33 for Aligned and 70 32 for rotated are just two examples.

  (if (setq ss1 (ssget (list (cons 0 "DIMENSION") (cons 70 33)))) 

    (progn 

      (setq ssSel (ssadd))

      (while (setq entOld (ssname ss1 0)) 
        (setq EntData (entget entOld))
        (if (not (member '(100 . "AcDbRotatedDimension") EntData)) 

          (progn 

            ;; Create the dimension for each
            (command "_.dimlinear" 
                     "_none"
                     (cdr (assoc 13 EntData))
                     "_none"
                     (cdr (assoc 14 EntData))
                     "_none"
                     (setq pt (cdr (assoc 11 EntData)))
            )

            ;; This will modify the existing new dimension to vertical if that option was chosen
            (setq entHor (entget (entlast)))
            (if (= ansVertOrHor "V") 
              (progn 
                (entmod (subst (cons 50 1.5708) (assoc 50 entHor) entHor))
                (setq entHor (entget (entlast))
                      ptv    (cdr (assoc 10 entHor))
                )
                (setq ptn (list (car pt) (cadr ptv) (caddr ptv)))
                (entmod (subst (cons 10 ptn) (assoc 10 entHor) entHor))
              ) ; End progn
              (entmod (subst (cons 50 0.0) (assoc 50 entHor) entHor))
            ) ; End if

            ;; Matches the new dim with the old aligned one
            (command "_.matchprop" "_non" entOld "_non" (entlast) "")

            ;; Add the newly created dims to a selection set for later selection
            (setq ssSel (ssadd (entlast) ssSel))

            ;; Delete the older dimension
            (entdel entOld)
          ) ; End progn
        ) ; End if

        (ssdel entOld ss1)
      ) ; End while

      (if ssSel 
        (progn 
          (sssetfirst nil ssSel)
          (command "_.REGEN")
        )
      )
    ) ; End progn
  ) ; End if ss1

  (vla-EndUndoMark acDoc)

  (*error* nil)
  (princ)
)

  ;;----------------------------------------------------------------------;;
  ;; _dxf
  ;; Finds the association pair, strips 1st element
  ;; args   - dxfcode elist
  ;; Example  - (_dxf -1 (entget (ssname (ssget) 0)))
  ;; Returns  - <Entity name: xxxxxxxxxxx>
(defun _dxf (code elist) 
  (cdr (assoc code elist))
)
(princ)

  ; (c:DM_Aligned_To_Linear) ;; unblock for testing

 

0 Likes