Author Topic: Change Attribute width factor  (Read 6847 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Change Attribute width factor
« on: August 03, 2014, 03:36:42 AM »
I am wondering if there a lisp to change width factor of attributes for sected block?

ribarm

  • Gator
  • Posts: 3272
  • Marko Ribar, architect
Re: Change Attribute width factor
« Reply #1 on: August 03, 2014, 04:07:19 AM »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Change Attribute width factor
« Reply #2 on: August 03, 2014, 06:18:01 AM »
That is easily could be changed .

Code - Auto/Visual Lisp: [Select]
  1.     (defun c:Test (/ ss wd)
  2.      ;; Tharwat 03.08.2014 ;;
  3.      (princ "\n Select Attributed Blocks ")
  4.      (if (and (setq ss (ssget "_:L" '((0 . "INSERT") (66 . 1))))
  5.               (setq wd (getdist "\n Specify width factor :"))
  6.          )
  7.        ((lambda (i / sn)
  8.           (while (setq sn (ssname ss (setq i (1+ i))))
  9.             (foreach x (vlax-invoke (vlax-ename->vla-object sn) 'GetAttributes) (vla-put-scalefactor x wd))
  10.           )
  11.         )
  12.          -1
  13.        )
  14.      )
  15.      (princ)
  16.     )

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Change Attribute width factor
« Reply #3 on: August 03, 2014, 06:48:06 AM »
That is easily could be changed .

Thanks Tharwat, but the changes effect the selected block not all blocks and after ATTSYNC the attribute comes back again

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Change Attribute width factor
« Reply #4 on: August 03, 2014, 07:00:30 AM »
Thanks Tharwat, but the changes effect the selected block not all blocks and after ATTSYNC the attribute comes back again

Try the following:
Code: [Select]
(defun c:attw ( / b e i l s w x )
    (while
        (and
            (progn
                (initget 6)
                (setq w (getdist "\nSpecify width factor: "))
            )
            (not (< 0.01 w 100.0))
        )
        (princ "\nWidth factor must be between 0.01 & 100.")
    )
    (setq w (cons 41 w))
    (if (setq s (ssget '((0 . "INSERT") (66 . 1))))
        (repeat (setq i (sslength s))
            (setq e (ssname s (setq i (1- i)))
                  b (cdr (assoc 2 (entget e)))
                  e (entnext e)
                  x (entget  e)
            )
            (while (= "ATTRIB" (cdr (assoc 0 x)))
                (entmod (list (cons -1 e) w))
                (setq e (entnext e)
                      x (entget  e)
                )
            )
            (if (not (member b l))
                (progn
                    (setq l (cons b l)
                          e (tblobjname "block" b)
                    )
                    (while (setq e (entnext e))
                        (if (= "ATTDEF" (cdr (assoc 0 (entget e))))
                            (entmod (list (cons -1 e) w))
                        )
                    )
                )
            )
        )
    )
    (princ)
)

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Change Attribute width factor
« Reply #5 on: August 03, 2014, 07:04:14 AM »
That is easily could be changed .

Thanks Tharwat, but the changes effect the selected block not all blocks and after ATTSYNC the attribute comes back again
I am wondering if there a lisp to change width factor of attributes for sected block?

Sure only the selected , as per your request in the first post . right ?

Explain what your idea clearly to modify the codes as per your new request .

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Change Attribute width factor
« Reply #6 on: August 03, 2014, 09:36:01 AM »
Try the following:

Thanks LEE
I changed the lisp to match my needs and working as charm
But I tried to combine this lisp with ObjectDBX Wrapper. but can not because of function requirements.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Change Attribute width factor
« Reply #7 on: August 03, 2014, 10:12:03 AM »
But I tried to combine this lisp with ObjectDBX Wrapper. but can not because of function requirements.

The following should be compatible with my ObjectDBX Wrapper:

Code: [Select]
(defun attwidth ( doc / bnm tag wid )

    (setq bnm "*" ;; Block Filter
          tag "*" ;; Tag Filter
          wid 0.5 ;; Width Factor
          bnm (strcase bnm)
          tag (strcase tag)
    )
    (vlax-for blk (vla-get-blocks doc)
        (if (or (= :vlax-true (vla-get-islayout blk)) (wcmatch (strcase (vla-get-name blk)) bnm))
            (vlax-for obj blk
                (cond
                    (   (= "AcDbAttributeDefinition" (vla-get-objectname obj))
                        (if (wcmatch (strcase (vla-get-tagstring obj)) tag)
                            (vla-put-scalefactor obj wid)
                        )
                    )
                    (   (and (= "AcDbBlockReference" (vla-get-objectname obj))
                             (= :vlax-true (vla-get-hasattributes obj))
                             (wcmatch (strcase (vla-get-effectivename obj)) bnm)
                        )
                        (foreach att (vlax-invoke obj 'getattributes)
                            (if (wcmatch (strcase (vla-get-tagstring att)) tag)
                                (vla-put-scalefactor att wid)
                            )
                        )
                    )
                )
            )
        )
    )
    (princ)
)

For use in the active document:
Code: [Select]
(attwidth (vla-get-activedocument (vlax-get-acad-object)))
For use with my ObjectDBX Wrapper function:
Code: [Select]
(LM:odbx 'attwidth nil t)

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Change Attribute width factor
« Reply #8 on: August 04, 2014, 03:41:26 AM »
But I tried to combine this lisp with ObjectDBX Wrapper. but can not because of function requirements.

The following should be compatible with my ObjectDBX Wrapper:

As usual perfect. There is a question, is it posible to make ObjectDBX Wrapper working with folder and subfolders?

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Change Attribute width factor
« Reply #9 on: August 04, 2014, 04:17:08 PM »
But I tried to combine this lisp with ObjectDBX Wrapper. but can not because of function requirements.

The following should be compatible with my ObjectDBX Wrapper:

As usual perfect.

Thank you Hasan  :-)

There is a question, is it posible to make ObjectDBX Wrapper working with folder and subfolders?

Certainly - for a far more advanced file selection dialog, you could combine my ObjectDBX Wrapper function with my Get Files Dialog function in the following way:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:attwid ( / lst )
  2.     (if (setq lst (LM:getfiles "Select Drawings to Process" "" "dwg;dwt;dws"))
  3.         (LM:odbx 'attwidth lst t)
  4.     )
  5.     (princ)
  6. )

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Change Attribute width factor
« Reply #10 on: August 05, 2014, 08:32:00 AM »
But I tried to combine this lisp with ObjectDBX Wrapper. but can not because of function requirements.

The following should be compatible with my ObjectDBX Wrapper:

As usual perfect.

Thank you Hasan  :-)

There is a question, is it posible to make ObjectDBX Wrapper working with folder and subfolders?

Certainly - for a far more advanced file selection dialog, you could combine my ObjectDBX Wrapper function with my Get Files Dialog function in the following way:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:attwid ( / lst )
  2.     (if (setq lst (LM:getfiles "Select Drawings to Process" "" "dwg;dwt;dws"))
  3.         (LM:odbx 'attwidth lst t)
  4.     )
  5.     (princ)
  6. )

That is exactly what I am looking for.
Thanks

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Change Attribute width factor
« Reply #11 on: August 05, 2014, 01:06:52 PM »
You're welcome Hasan  :-)