Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Changing Text Alignment in Multiple Styles

  1. #1
    Active Member
    Join Date
    2013-06
    Posts
    72
    Login to Give a bone
    0

    Default Changing Text Alignment in Multiple Styles

    Hello,

    I am converting a bunch of old drawings where the vendor made a different dimension style for every single dimension. Unfortunately, I need to change all dimension styles to have the "Text Placement Vertical" set to "Centered", instead of "Above".

    I tried changing each dimension, but it seems like this property is only stored in the style. I was able to modify the 51 and 53 group codes to somewhat accomplish what I want, but it only gives the proper result if the dimension fits between the extension lines; when it's outside, I get varying results.

    I am decent at figuring out and manipulating those codes, but modifying the style, I have no idea. Googling hasn't given me what I want, and seemingly nobody else has ever had this problem, as I can't even see someone trying and failing.

    Any guidance would be greatly appreciated. I feel like this should be easy, but I can't sort it out.
    Last edited by ettore_c; 2015-07-27 at 06:43 PM.

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Changing Text Alignment in Multiple Styles

    Post what code you have, it may be a quick fix.
    Should be able to just set all of them to the style you want, then with all selected change Text Rotation to 0

    To code it you need to know the Dimension Style you want to set them to and where to import it from if it isn't in the drawings.

  3. #3
    Active Member
    Join Date
    2013-06
    Posts
    72
    Login to Give a bone
    0

    Default Re: Changing Text Alignment in Multiple Styles

    Quote Originally Posted by Tom Beauford View Post
    Post what code you have, it may be a quick fix.
    Should be able to just set all of them to the style you want, then with all selected change Text Rotation to 0

    To code it you need to know the Dimension Style you want to set them to and where to import it from if it isn't in the drawings.
    Note: I updated my question a little; I need Text Placement to change, but it's the same issue as changing the Text Alignment).

    Ok, well this is my current code:
    Code:
      (princ "\nSelect dimensions: ")
      (setq ss (ssget '((0 . "DIMENSION"))))
      (if ss
        (foreach forVar (vl-remove nil (mapcar '(lambda (x) (if (= (type (cadr x)) 'ENAME) (cadr x) '())) (ssnamex ss)))
          (setq eLst (entget forVar))
          (setq eLst (subst '(53 . 90) (assoc 53 eLst) eLst))
          (setq eLst (subst '(51 . 90) (assoc 51 eLst) eLst))
          (entmod eLst)
          (entupd forVar)
          )
        )
      (princ)
    Attached, as well, are the results of both this script, and changing the style:
    out_org_b: Original unmodified
    out_bad_b: After this script (looks very wrong, this is just a random example of the anomaly)
    out_good_b: After changing to "Text Placement Vertical: Centered"

    I changed both 53 and 51 because if I only change 53, I get an arbitrary rotation (if it matters, these are "rotated dimensions"). So, the rotating part of my issue isn't the problem, it's that I can't change the "Text Alignment" with DXF codes of the objects, it doesn't appear. This issue only manifests when the dimension is similar to how the examples show (dimension outside the extension lines).
    Attached Images Attached Images
    Last edited by ettore_c; 2015-07-27 at 06:53 PM. Reason: Clarifying

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Changing Text Alignment in Multiple Styles

    That's different that what I thought. To modify the actual Dimension Styles modify the entity list of the first one in the table with
    Code:
    (tblnext "DIMSTYLE" T)
    then loop through modifying the rest using
    Code:
    (tblnext "DIMSTYLE")
    Might be helpful if you attached small before and after drawings with just a handful of dimensions to test code on.

  5. #5
    Active Member
    Join Date
    2013-06
    Posts
    72
    Login to Give a bone
    0

    Default Re: Changing Text Alignment in Multiple Styles

    Quote Originally Posted by Tom Beauford View Post
    That's different that what I thought. To modify the actual Dimension Styles modify the entity list of the first one in the table with
    Code:
    (tblnext "DIMSTYLE" T)
    then loop through modifying the rest using
    Code:
    (tblnext "DIMSTYLE")
    Might be helpful if you attached small before and after drawings with just a handful of dimensions to test code on.
    Ok, so I think you broke me out of the Google issue I was having:
    Code:
    (setq Old_cmdecho (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    ;; getting first dimstyle created
    (setq sty (tblnext "DIMSTYLE"))
    ;; getting dimstyle name
    (setq sty(cdr (assoc 2 sty)))
    (while (/= sty nil) ;; if dimstyle is not nil then proceed
      (setq sty (tblsearch "DIMSTYLE" sty)) ;; searching dimstyle dialog box for dimstyle name
      (if (= (cdr (assoc 2 sty)) "Standard");; if the dimstyle name equals standard then go to the next dimstyle and get its name
        (progn
          (setq sty (tblnext "DIMSTYLE"))
          (setq sty(cdr (assoc 2 sty)))
        );; end of progn
        (progn
          (setvar "dimtad" 1);; If the dimstyle name is not Standard then set the dimtad to 1
          (command "-dimstyle" "s" (cdr (assoc 2 sty)) "y");; save the newly created dimstyle with the same name and new dimscale
          (setq sty (tblnext "DIMSTYLE"));;Get the next dimstyle
          (setq sty (cdr (assoc 2 sty)));; Get dimstyle name and repeat while until value is nil
        );; end of progn
      );; end of if
    );; end of while
    (setvar "cmdecho" Old_cmdecho);; when value is nil reset the cmdecho variable to its original value
    (princ)
    )
    This skips Standard, which I coincidentally actually want, then modifies that DIMTAD variable. However, nothing I change that to makes ANY difference. This script ORIGINALLY changed dimscale to 2, and it worked fine. I changed DIMSCALE to DIMTAD (mouseover on the item claims this is the variable), and messed with the numbers, but nothing ever changes.

    Attached .DWG shows an example of the silliness of multiple dimension styles, but it shouldn't be a problem. If you go into the dimension styles and update all of the DIMSTYLE* types to have Text Placement as Vertical and Text Alignment as Horizontal, the drawing will look exactly as I want it to.

    If this is somehow easier, I use this code to edit the SCALE and LINEAR SCALE; I assume it would be easy to edit for someone smarter than me. I don't know how anyone knows what the property names are:
    Code:
    (vl-load-com)
    ;; © Lee Mac 2010
    
    (defun *error* ( msg )
    (and doc (_EndUndo doc))
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
    (princ (strcat "\n** Error: " msg " **")))
    (princ)
    )
    
    (defun _StartUndo ( doc ) (_EndUndo doc)
    (vla-StartUndoMark doc)
    )
    
    (defun _EndUndo ( doc )
    (if (= 8 (logand 8 (getvar 'UNDOCTL)))
    (vla-EndUndoMark doc)
    )
    )
    
    (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
    
    (if (ssget "_X" '((0 . "*DIMENSION,LEADER")))
    (progn
    (setq *scl*
    (cond
    (
    (getdist
    (strcat "\nSpecify Linear Scale Factor <"
    (rtos
    (setq *scl* (cond ( *scl* ) ( 1.0 )))
    )
    "> : "
    )
    )
    )
    ( *scl* )
    )
    )
    (setq *oscl*
    (cond
    (
    (getdist
    (strcat "\nSpecify Overall Scale Factor <"
    (rtos
    (setq *oscl* (cond ( *oscl* ) ( 1.0 )))
    )
    "> : "
    )
    )
    )
    ( *oscl* )
    )
    )
    
    (_StartUndo doc)
    
    (vlax-for o (setq ss (vla-get-ActiveSelectionSet doc))
    (mapcar
    (function
    (lambda ( prop value )
    (if (vlax-property-available-p o prop)
    (vlax-put-property o prop value)
    )
    )
    )
    '(LinearScaleFactor ScaleFactor) (list *scl* *oscl*)
    )
    )
    
    (vla-delete ss)
    
    (_EndUndo doc)
    )
    )
    (princ)
    Attached Files Attached Files
    Last edited by ettore_c; 2015-07-28 at 03:06 AM.

  6. #6
    Active Member
    Join Date
    2013-06
    Posts
    72
    Login to Give a bone
    0

    Default Re: Changing Text Alignment in Multiple Styles

    So, it still seems like DIMTIH and DIMTAD are the things I need to be modifying, but changing them doesn't seem to accomplish anything. I feel like I am missing something super simple, like I am not "applying" the settings or something.

  7. #7
    Active Member
    Join Date
    2013-06
    Posts
    72
    Login to Give a bone
    0

    Default Re: Changing Text Alignment in Multiple Styles

    Does anyone have any feedback on why this might not be working? Seems like it should be SO simple to just change 2 variables in each style, but nothing's happening.

  8. #8
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    560
    Login to Give a bone
    0

    Default Re: Changing Text Alignment in Multiple Styles

    know how anyone knows what the property names
    This will open up a world of answers pick a dim

    Code:
    ;;; Dump all methods and properties for selected objects              ;
    ;;;===================================================================; 
    ;;; DumpIt                                                            ; 
    ;;;-------------------------------------------------------------------; 
    ;;;===================================================================; 
    (defun C:DumpIt ( / ent) 
      (while (setq ent (entsel)) 
        (vlax-Dump-Object 
          (vlax-Ename->Vla-Object (car ent)) T
        ) 
      ) 
      (princ) 
    )

  9. #9
    Active Member
    Join Date
    2013-06
    Posts
    72
    Login to Give a bone
    0

    Default Re: Changing Text Alignment in Multiple Styles

    Quote Originally Posted by BIG-AL View Post
    This will open up a world of answers pick a dim

    Code:
      (while (setq ent (entsel)) 
        (vlax-Dump-Object 
          (vlax-Ename->Vla-Object (car ent)) T
        ) 
      ) 
      (princ)
    With this new code you've provided, I found the following pieces of information change when I update the dimension styles:
    - TextInsideAlign goes from 0 to -1
    - TextOutsideAlign goes from 0 to -1
    - VerticalTextPosition goes from 1 to 0

    Updated code still does nothing:
    Code:
    (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
    
    (if (ssget "_X" '((0 . "*DIMENSION,LEADER")))
     (progn
      (vlax-for o (setq ss (vla-get-ActiveSelectionSet doc))
       (mapcar
        (function
         (lambda ( prop value )
          (if (vlax-property-available-p o prop)
           (vlax-put-property o prop value)
          )
         )
        )
        '(TextInsideAlign TextOutsideAlign VerticalPosition) (list -1 -1 0)
       )
      )
      (vla-delete ss)
     )
    )
    (princ)
    ... and this gives an error "; error: AutoCAD
    variable setting rejected: "TextInsideAlign" -1":
    Code:
    (setq Old_cmdecho (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    ;; getting first dimstyle created
    (setq sty (tblnext "DIMSTYLE"))
    ;; getting dimstyle name
    (setq sty(cdr (assoc 2 sty)))
    (while (/= sty nil) ;; if dimstyle is not nil then proceed
      (setq sty (tblsearch "DIMSTYLE" sty)) ;; searching dimstyle dialog box for dimstyle name
      (if (= (cdr (assoc 2 sty)) "Standard");; if the dimstyle name equals standard then go to the next dimstyle and get its name
        (progn
          (setq sty (tblnext "DIMSTYLE"))
          (setq sty(cdr (assoc 2 sty)))
        );; end of progn
        (progn
          (setvar "TextInsideAlign" -1)
          (setvar "TextOutsideAlign" -1)
          (setvar "VerticalTextPosition" 0)
          (command "-dimstyle" "s" (cdr (assoc 2 sty)) "y");; save the newly created dimstyle with the same name and new dimscale
          (setq sty (tblnext "DIMSTYLE"));;Get the next dimstyle
          (setq sty (cdr (assoc 2 sty)));; Get dimstyle name and repeat while until value is nil
        );; end of progn
      );; end of if
    );; end of while
    (setvar "cmdecho" Old_cmdecho);; when value is nil reset the cmdecho variable to its original value
    (princ)
    I think the first piece of code has a better chance of working. I'm honestly thinking of programming a dialogue-box clicker to automatically do this for me .

  10. #10
    Active Member
    Join Date
    2013-06
    Posts
    72
    Login to Give a bone
    0

    Default Re: Changing Text Alignment in Multiple Styles

    Ok, I am still stumped; anyone? Just need to change (in STYLE) Text Placement, Vertical -> Centered and Text Alignment -> Horizontal.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 4
    Last Post: 2013-01-31, 08:12 AM
  2. 2012: Changing surface styles on multiple surfaces
    By dmetcalf in forum AutoCAD Civil 3D - Surfaces
    Replies: 2
    Last Post: 2011-10-03, 03:31 PM
  3. different text notes alignment after changing view scale
    By Ning Zhou in forum Revit Architecture - General
    Replies: 3
    Last Post: 2010-07-31, 03:19 PM
  4. Replies: 1
    Last Post: 2009-05-25, 11:40 AM
  5. Changing styles in multiple .Ipt files
    By krh in forum Inventor - General
    Replies: 4
    Last Post: 2005-11-18, 07:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •