Author Topic: How to Merge Dimension Styles ?  (Read 7583 times)

0 Members and 1 Guest are viewing this topic.

Oak3s

  • Guest
How to Merge Dimension Styles ?
« on: December 17, 2010, 10:10:49 PM »
I have been using this to merge text styles [by T.Willey] and am hoping there is something similar for dimension styles.

I have also recently been using this to merge defined text styles (this is not mine - credit to Fatty @forums.autodesk):
Code: [Select]
(defun C:SM ( / CurEnt CurObj CurSet)
(vl-load-com)
(setq CurSet (ssget "_x" '((0 . "TEXT")(7 . "AB"))))
(if CurSet
(while (setq CurEnt (ssname CurSet 0))
(setq CurObj (vlax-ename->vla-object CurEnt))
(ssdel CurEnt CurSet)
(vla-put-StyleName CurObj "A")
(vla-Update CurObj)
)
)
(princ)
)

The dimstyles that need to be 'merged' are very similar. AB dimensions should be A dimensions. No error checking is necessary at this point. I just need some help with where to start or a working example I can manipulate.

Something similar to these would be extremely helpful. Usually I would post something I have been working on but in this case I dont have anything to show for the hours I have spent trying to do something. Any help is very much appreciated.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How to Merge Dimension Styles ?
« Reply #1 on: December 18, 2010, 08:10:55 AM »
Check this out ....

Code: [Select]
(defun c:THsm (/ ss)
;Tharwat Dec. 18- 2010
(if (setq ss (ssget "_x" '((0 . "*DIMENSION")(3 . "AB"))))
  ((lambda (i / a e )
   (while
     (setq a (ssname ss (setq i (1+ i))))
       (setq e (entget a))
          (entupd (cdr (assoc -1 (entmod (subst (cons 3 "A")(assoc 3 e) e)))))
         )
        )
     -1
    )
       (alert "\n No Dimensions selected")
    )
  (princ)
  )

Tharwat

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to Merge Dimension Styles ?
« Reply #2 on: December 18, 2010, 10:01:00 AM »
Another  :-)

Code: [Select]
(defun c:MergeDims ( / d1 d2 ss ) (vl-load-com)
  ;; Example by Lee Mac 2010 - www.lee-mac.com

  (if
    (and
      (vl-every
        (function
          (lambda ( sym str )
            (while
              (not
                (or
                  (eq ""
                    (set sym
                      (getstring t str)
                    )
                  )
                  (tblsearch "DIMSTYLE" (eval sym))
                )
              )
              (princ "\n** DimStyle not Found **")
            )
            (not (eq "" (eval sym)))
          )
        )
        (list 'd1 'd2)
        (list "\nSpecify DimStyle to Merge <Exit> : " "\nSpecify DimStyle to Use <Exit> : ")
      )
      (ssget "_X" (list (cons 0 "*DIMENSION") (cons 3 d1)))
    )
    (progn
      (vlax-for dim
        (setq ss
          (vla-get-ActiveSelectionSet
            (vla-get-ActiveDocument (vlax-get-acad-object))
          )
        )
        (vla-put-StyleName dim d2)
      )
      (vla-delete ss)
    )
  )
  (princ)
)

Oak3s

  • Guest
Re: How to Merge Dimension Styles ?
« Reply #3 on: December 21, 2010, 02:17:28 PM »
Sorry for the few days of no reply. I just got back to work.

Thank you both for the examples. Both of them work nicely for dimension styles. I cant get them to change child leaders though. I dont know if its the '$7' that is throwing off the name but it doesnt seem to be recognized in either example. Any ideas on how to deal with child leaders?

Oak3s

  • Guest
Re: How to Merge Dimension Styles ?
« Reply #4 on: December 21, 2010, 02:26:32 PM »
scratch that. I took a closer look at both codes and realized I need to look at 'Leaders' and not 'Dimensions'. :)
Code: [Select]
(cons 0 "DIMENSION")
edited by Oak3s 12.21.10]
« Last Edit: December 21, 2010, 02:30:55 PM by Oak3s »

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How to Merge Dimension Styles ?
« Reply #5 on: December 21, 2010, 02:30:38 PM »
scratch that. I took a closer look at both codes and realized I need to look at 'Leaders' and not 'Dimensions'. :)
Code: [Select]
(cons 0 "DIMENSIONS")

That's right, besides that remove the style name (3 . "AB")

Things like .....
Code: [Select]
(defun c:THsm (/ ss)
;Tharwat Dec. 18- 2010
(if (setq ss (ssget "_x" '((0 . "*LEADER"))))
  ((lambda (i / a e )
   (while
     (setq a (ssname ss (setq i (1+ i))))
       (setq e (entget a))
          (entupd (cdr (assoc -1 (entmod (subst (cons 3 "A")(assoc 3 e) e)))))
         )
        )
     -1
    )
       (alert "\n No Leaders selected")
    )
  (princ)
  )

Tharwat

Oak3s

  • Guest
Re: How to Merge Dimension Styles ?
« Reply #6 on: December 21, 2010, 02:32:22 PM »
Thank you.
What is the * doing in (0 . "*DIMENSION")?

Oak3s

  • Guest
Re: How to Merge Dimension Styles ?
« Reply #7 on: December 21, 2010, 02:41:03 PM »

That's right, besides that remove the style name (3 . "AB")
[/quote]

Why take out the style name? I modified the style name to include "$7" but I had to remove it all together to get the leaders to change. In my particular case all the leaders can be on the same style but how do you isolate leaders on a specific style without the (3 . "AB")?

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: How to Merge Dimension Styles ?
« Reply #8 on: December 22, 2010, 08:29:06 AM »
Thank you.
What is the * doing in (0 . "*DIMENSION")?

You're welcome .

Actually the "*DIMENSION"  is for filtering all objects that related to Dimensions , things like Aligned . linear , and so on .....

And for removing the Leader Style name form the selection set .

I tried it with it but that doesn't work at all , I also wonder why . :-(

Thanks

Tharwat

moon47usac@gmail.com

  • Mosquito
  • Posts: 1
Re: How to Merge Dimension Styles ?
« Reply #9 on: September 29, 2021, 12:41:20 PM »
Lee, as usual this is great work.

Rather than typing them into prompt I would rather provide a list in the code.

IE: AB, ABD, ABQ all merge into A.

Can you have it look inside blocks as well?

I only know plain lisp so this is all french to me or I would try to modify.