Fixed scale for attributes inside an attribute block?

Discussion in 'AutoCAD' started by elina.hyvamaki, Mar 5, 2005.

  1. Is it possible to make an attribute block so that if you scale the block, the attributes are not scaled = the attributes have a fixed scale?

    Elina H.
     
    elina.hyvamaki, Mar 5, 2005
    #1
  2. elina.hyvamaki

    ECCAD Guest

    No,
    But you 'can' change the Height of the Attribute, after
    insertion as in:
    (entmod (setq OBJ (subst (cons 40 ht)(assoc 40 OBJ) OBJ)))
    Where, OBJ = the Attribute Entity, 'ht' is the required new height (real number e.g. 0.125).

    Hope this helps.

    Bob
     
    ECCAD, Mar 5, 2005
    #2
  3. elina.hyvamaki

    Walt Engle Guest

    Or use Attribute Manager
     
    Walt Engle, Mar 5, 2005
    #3
  4. I tried that after insert and the result was text " nil ". What I did was that I wrote the tag name in the place of OBJ and then 200 where there was 40 in your example. Is attribute entity's name not the same as tag name?

    Elina
     
    elina.hyvamaki, Mar 6, 2005
    #4
  5. Enhanced Attribute Manager would be OK if I could select many differently scaled block's attributes and set them to the same height, all at the same time. However it seems that it has to be done individually.

    Elina H.
     
    elina.hyvamaki, Mar 6, 2005
    #5
  6. elina.hyvamaki

    ECCAD Guest

    Nope,
    It's inside this Lisp..
    Save as a text file called ts.lsp
    and load / run it.

    Bob


    ;; TS.LSP
    ;;

    (DEFUN C:TS ()
    (setvar "CMDECHO" 0)
    (setvar "ATTDIA" 0)
    ;;
    ;; Local DXF Function
    (defun dxf (code elist)
    (cdr (assoc code elist))
    ); end function dxf
    ;;
    ;; Local function to change Height of Attributes
    ;;
    (defun chg_attr_ht (); change height
    (if (and (/= old_ht nil)(/= OBJ nil))
    (progn
    (entmod (setq OBJ (subst (cons 40 ht)(assoc 40 OBJ) OBJ)))
    (setq old_ht nil OBJ nil)
    ); end progn
    ); end if
    (princ)
    ); end function chg_attr_ht
    ;;
    ;; SECTION 1: resizes TEXT
    ;;
    ;; Select Size wanted.
    ;;
    (setq HET "0.125")
    (setq CHK (getstring (strcat "\nNew Text Size ?<" HET ">: ")))
    (if (or (= CHK "") (= CHK " "))
    (setq TS1 HET D (atof TS1))
    (setq TS1 CHK HET TS1 D (atof TS1))
    ); end if
    (setq HT D)
    ;;
    ;; Get pick area.
    ;;
    (setq P1 (getpoint "\nPick first corner of Text Resize Area : "))
    (setq P2 (getcorner P1 "\nPick other corner : "))
    (setq A (ssget "_c" P1 P2)); get first selection set.
    (if (/= A nil); Else if A is nil, do nothing.
    (setq B (sslength A)); check number of members in 'A' selection set.
    (setq B 0); --- else, set length to zip.
    ); end if
    ;;
    (if (> B 0); must be some entities ?
    (progn
    (setq CTR 0); Note: CTR starts SSNAME function at 0, counts 1,2,3 ..
    (repeat B
    (setq C (ssname A CTR)); get item 0, item 1, etc.
    (setq OBJ (entget C)); put assoc list into OBJ
    (setq P (cdr (assoc 0 OBJ))); get entity name
    (if (or (= P "MTEXT")(= P "TEXT"))
    (progn
    (setq OBJ (subst (cons 40 D)(assoc 40 OBJ) OBJ)); CONStruct replacement Ht.
    (entmod OBJ); modify Object
    ); end progn
    ); end if
    (setq CTR (+ CTR 1)); ratchet counter, for next one
    ); end repeat
    ); end progn
    ); end if
    ;;
    ;; SECTION 2: resizes ATTRIBUTE TEXT Within Blocks
    ;;
    ;; A = selection set of entities
    ;; B = sslength of A
    ;;
    (if (> B 0)
    (progn
    (setq C 0 E 1) ;C = entity selecter, starts at 0, goes 1,2,3..
    (setq CTR 0); counter for number of attributes found
    (repeat B
    (setq D (ssname A C)); get entity name from 'A', if no name, D is nil.
    (if (/= D nil); found something ?
    (progn
    (setq F (entget D)); F used to hold each entity 'list' item.
    (if (and
    (= "INSERT" (cdr (assoc 0 F))); case of BLOCKS
    (/= (cdr (assoc 66 F)) nil)); with Attrib's following
    (progn
    (setq en (entget (entnext (dxf -1 F))))
    (if (/= en nil)
    (progn
    (setq G nil)
    (setq G (cdr (assoc 0 en)))
    (if (= "ATTRIB" G); case of attributes
    (progn
    (setq old_ht (cdr (assoc 40 en)))
    (setq OBJ en)
    (chg_attr_ht); change height
    ); end progn
    ); end if
    (while (/= "SEQEND" (cdr (assoc 0 en)))
    (setq ex (entget (entnext (dxf -1 en))))
    (setq G nil)
    (setq G (cdr (assoc 0 ex)))
    (if (= "ATTRIB" G); case of attributes
    (progn
    (setq old_ht (cdr (assoc 40 ex)))
    (setq OBJ ex)
    (chg_attr_ht); change height
    ); end progn
    ); end if
    (setq en ex); swap back
    ); end while
    ); end progn
    ); end if
    ); end progn
    ); end if
    (setq C (+ C 1)); ratchet counter C to get next entity.
    (setq D nil); reset D to nil - for IF above.
    ); end progn
    ); end if
    ); end repeat
    ); end progn
    ); end if
    ;;
    (if (> B 0)(command "_regen"))
    (setvar "CMDECHO" 0)
    (setq A nil B nil C nil D nil F nil G nil P nil P1 nil P2 nil)
    (setq CHK nil CTR nil OBJ nil TS1 nil en nil ex nil Y nil)
    (princ)
    ); end function TS
    (princ)
     
    ECCAD, Mar 6, 2005
    #6
  7. Thank you!! It works.

    Elina
     
    elina.hyvamaki, Mar 7, 2005
    #7
  8. elina.hyvamaki

    ECCAD Guest

    You are welcome.

    :)

    Bob
     
    ECCAD, Mar 7, 2005
    #8
  9. elina.hyvamaki

    wkiernan Guest

    Or alternatively, if rather than changing the ATTRIBs without changing the INSERT itself, you want to rescale the INSERT without changing the ATTRIBs, you can do it by applying entmod to the INSERT only.

    [pre]; BLSCALE scales an INSERT around its insertion point, by either a multiplier
    ; or to a new scale factor, without scaling any attribute attached to it.
    ; (c) 2005 Terrible Software Inc. WDK - everybody use it for free

    (defun-q C:BLSCALE( / ename edata xscf yscf zscf ans)
    (if (setq ename (entsel "\nSelect INSERT: "))
    (if (= "INSERT" (cdr (assoc 0 (setq edata (entget (setq ename (car ename)))))))
    (progn
    (setq xscf (cdr (assoc 41 edata))
    yscf (cdr (assoc 42 edata))
    zscf (cdr (assoc 43 edata))
    )
    (if (and (= xscf yscf)(= xscf zscf))
    (princ
    (strcat
    "\nCurrent scale factor for this "
    (strcase (cdr (assoc 2 edata)))
    " INSERT is "
    (rtos xscf 2 4)
    ". "
    )
    )
    (princ
    (strcat
    "\nThis "
    (strcase (cdr (assoc 2 edata)))
    " INSERT has different X, Y and Z scale factors.\nX scale factor: "
    (rtos xscf 2 4)
    "\nY scale factor: "
    (rtos yscf 2 4)
    "\nZ scale factor: "
    (rtos zscf 2 4)
    )
    )
    )

    (initget 7 "Scale Xyz")
    (setq ans (getreal "\nnew XYZ Scale factor, <enter scale multiplier>: "))
    (cond
    ((or (= ans "Xyz")(= ans "Scale"))
    (initget 7)
    (setq ans (getreal "\nNew XYZ scale factor: "))
    (entmod
    (subst
    (cons 41 ans)
    (assoc 41 edata)
    (subst
    (cons 42 ans)
    (assoc 42 edata)
    (subst
    (cons 43 ans)
    (assoc 43 edata)
    edata
    )
    )
    )
    )
    )
    (T
    (entmod
    (subst
    (cons 41 (* ans xscf))
    (assoc 41 edata)
    (subst
    (cons 42 (* ans yscf))
    (assoc 42 edata)
    (subst
    (cons 43 (* ans zscf))
    (assoc 43 edata)
    edata
    )
    )
    )
    )
    )
    )
    )
    (princ "\nEntity selected is not an INSERT. ")
    )
    (princ "\nNo entity selected. ")
    )
    (prin1)
    )
    [/pre]

    I've also got a program to move ATTRIBs attached to an INSERT all at the same time without moving the INSERT itself. First save the entity data for the INSERT in the variable edata. Now use the MOVE command to move the INSERT and ATTRIBs. Once you have moved it so the ATTRIBs are in the right place, do an (entmod edata) which resets the insertion point of the INSERT to where it was before the MOVE command; however the ATTRIBs stay where you moved them to.
     
    wkiernan, Mar 9, 2005
    #9
  10. Thanks...In this particular case however its better to rescale the attributes because then I can control the size of the attribute blocks by their X and Y scale from the properties window, which is a very simple way of controlling them. I can use the same attrib block (containing a 1x1 size rectangle) in the drawing in many different scales.

    I'll look into this too, anyway...

    Elina
     
    elina.hyvamaki, Mar 17, 2005
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.