Jump to content

How to Convert Aligned Dimension to Rotated/Linear Dimension Globally..


lonelysn

Recommended Posts

:cry:

Dear Friends & Masters,

Need Help again for this query,

one of my man by mistake gave aligned dimension instead of Linear,

now it will be a big task for us to delete all the Dim and do it again,

So can anyone help, i need to

Convert those Aligned Dimensions to Rotated/Linear Dimension Globally,

so please if you all have any suggestions or solutions for this please reply.

 

Hoping a reply:cry::(

Link to comment
Share on other sites

Link to comment
Share on other sites

 

Thanks for your valuable direction and Quick Reply,

but there is problem with this lisp file,

it changes the axis or direction

Eg: when i click the Aligned Dim it directly changes the value to zero

 

i need it in the same place where it was earlier. :(

Please Help

Link to comment
Share on other sites

Did you try BOTH lisp routines?

 

I've done all I can. I'm not the lisp-guru-in-residence here so you'll have to wait until one shows up. In the meantime, send the guy who messed up the drawing in the first place for some training.

Link to comment
Share on other sites

Did you try BOTH lisp routines?

 

I've done all I can. I'm not the lisp-guru-in-residence here so you'll have to wait until one shows up. In the meantime, send the guy who messed up the drawing in the first place for some training.

 

:D he is out of the project now...i kicked him off:twisted:

now the whole thing is on my head,

no issues brother thanks for the efforts.:) will wait:(

Link to comment
Share on other sites

Did you try both routines?

 

Have you tried searching for a lisp routine yourself?

Edited by ReMark
Link to comment
Share on other sites

Here is my attempt try it and let me know how things get on with you.

 

(defun c:ali2rot  (/ _dxf spc ss sn e dim c)
 ;; =====-----[ Tharwat 16.Mar.2016 ]-----=====;;
 ;; Convert Aligned dimension into Rotated	;;
 (defun _dxf (c) (cdr (assoc c e)))
 (setq spc
        (vlax-get (vla-get-activelayout
                    (vla-get-activedocument (vlax-get-acad-object)))
                  'BLOCK))

 (if (setq ss (ssget "_:L" '((0 . "*DIMENSION"))))
   (while (setq sn (ssname ss 0))
     (if (and (not (member '(100 . "AcDbRotatedDimension")
                           (setq e (entget sn))))
              (member '(100 . "AcDbAlignedDimension") e)
              )
       (progn
         (setq dim (vla-adddimrotated
                     spc
                     (vlax-3d-point (_dxf 13))
                     (vlax-3d-point (_dxf 14))
                     (vlax-3d-point (_dxf 10))
                     0.
                     )
               )
         (vla-put-layer dim (_dxf )
         (if (setq c (_dxf 62))
           (vla-put-color dim c)
           )
         (entdel sn)
         )
       )
     (ssdel sn ss)
     )
   )
 (princ)
 )(vl-load-com)

Link to comment
Share on other sites

  • 5 years later...

Original code (Links of which can be found in the header) modified to work with a selection set along with adding 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
;; - To work with a selection of dimensions.
;; - Add error handling and undo points.
;;

;; 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
  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")
    )
  )

(setq ss1 (ssget '((0 . "DIMENSION"))))

(if ss1

  (progn

    (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)))
          )

        ;; Delete the older dimension
        (entdel entOld)

        ;; 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

        ) ; End progn
      ) ; End if

     (ssdel entOld ss1)

     ) ; End while

    ) ; End progn

  ) ; End if ss1

(vla-EndUndoMark acDoc)

(*error* nil) (princ)

)

(princ)

 

Link to comment
Share on other sites

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...