Author Topic: Stretch attributes (enhanced)  (Read 4670 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Stretch attributes (enhanced)
« on: April 08, 2019, 05:12:42 AM »
Perhaps it has already been solved ...

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Stretch attributes (enhanced)
« Reply #1 on: April 08, 2019, 06:48:36 AM »
Your attributes have Lock Position parameter turned on - it's default, but you should have unchecked it for stretching if you had that in mind...
I don't know, but perhaps some DXF code could be an answer to turning it off through code...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Stretch attributes (enhanced)
« Reply #3 on: April 08, 2019, 08:34:59 AM »
@Marko: try to use stretch on attribs… (insert point of block must be outside of window)

@Vovka:  think  "MOVEATT (gile) 07/05/08" it is the one that comes closest to my needs, but there is still no function that also combines the stretch command…

Grazie.

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Stretch attributes (enhanced)
« Reply #4 on: April 08, 2019, 10:04:03 AM »
@Marc' Antonio
I've checked it and it works no matter Lock Position yes or no... The problem is that your stretching window is wrong - it should be from upper left to lower right point... Check it with this procedure and reply if again you have problem...

M.R.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Stretch attributes (enhanced)
« Reply #5 on: April 08, 2019, 10:11:23 AM »
Post your drawing .. I can't replicate that behavior.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC


ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Stretch attributes (enhanced)
« Reply #7 on: April 08, 2019, 02:47:18 PM »
OK... It doesn't work, but try this quick fix :

Code - Auto/Visual Lisp: [Select]
  1. (defun c:statt ( / pp1 pp2 ss p1 p2 blkrefs blkrefptlst blkrefptlstn )
  2.  
  3.  
  4.   (if (and (not (prompt "\nSelect objects: ")) (setq pp1 (getpoint)) (setq pp2 (getcorner pp1)))
  5.     (progn
  6.       (vl-cmdf "_.select" "_box" "_non" pp1 "_non" pp2)
  7.       (while (< 0 (getvar 'cmdactive))
  8.         (vl-cmdf "\\")
  9.       )
  10.       (if (setq ss (ssget "_P"))
  11.         (progn
  12.           (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
  13.             (if (= 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (cdr (assoc 8 (entget e))))))))
  14.               (ssdel e ss)
  15.             )
  16.           )
  17.           (if (/= (sslength ss) 0)
  18.             (progn
  19.               (setq blkrefs (vl-remove-if-not '(lambda ( x ) (= (cdr (assoc 0 (entget x))) "INSERT")) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))
  20.               (setq blkrefptlst (mapcar '(lambda ( x ) (list x (assoc 10 (entget x)))) blkrefs))
  21.               (initget 1)
  22.               (setq p1 (getpoint "\nPick or specify base point : "))
  23.               (initget 1)
  24.               (setq p2 (getpoint p1 "\nPick or specify destination point : "))
  25.               (vl-cmdf "_.stretch" ss "" "_non" p1 "_non" p2)
  26.               (setq blkrefptlstn (mapcar '(lambda ( x ) (list x (assoc 10 (entget x)))) blkrefs))
  27.               (foreach blkref (mapcar 'car (vl-remove-if-not '(lambda ( x ) (vl-position x blkrefptlst)) blkrefptlstn))
  28.                 (if (= (cdr (assoc 66 (entget blkref))) 1)
  29.                   (foreach att (vlax-invoke (vlax-ename->vla-object blkref) 'getattributes)
  30.                     (if
  31.                       (and
  32.                         (< (apply 'min (mapcar 'car (list pp1 pp2))) (car (cdr (assoc 10 (entget (vlax-vla-object->ename att))))) (apply 'max (mapcar 'car (list pp1 pp2))))
  33.                         (< (apply 'min (mapcar 'cadr (list pp1 pp2))) (cadr (cdr (assoc 10 (entget (vlax-vla-object->ename att))))) (apply 'max (mapcar 'cadr (list pp1 pp2))))
  34.                       )
  35.                       (vla-move att (vlax-3d-point p1) (vlax-3d-point p2))
  36.                     )
  37.                   )
  38.                 )
  39.               )
  40.               (foreach blkref (mapcar 'car (vl-remove-if '(lambda ( x ) (vl-position x blkrefptlst)) blkrefptlstn))
  41.                 (if (= (cdr (assoc 66 (entget blkref))) 1)
  42.                   (foreach att (vlax-invoke (vlax-ename->vla-object blkref) 'getattributes)
  43.                     (if
  44.                       (not
  45.                         (and
  46.                           (< (apply 'min (mapcar 'car (list pp1 pp2))) (car (cdr (assoc 10 (entget (vlax-vla-object->ename att))))) (apply 'max (mapcar 'car (list pp1 pp2))))
  47.                           (< (apply 'min (mapcar 'cadr (list pp1 pp2))) (cadr (cdr (assoc 10 (entget (vlax-vla-object->ename att))))) (apply 'max (mapcar 'cadr (list pp1 pp2))))
  48.                         )
  49.                       )
  50.                       (vla-move att (vlax-3d-point p2) (vlax-3d-point p1))
  51.                     )
  52.                   )
  53.                 )
  54.               )
  55.             )
  56.           )
  57.         )
  58.       )
  59.     )
  60.   )
  61.   (princ)
  62. )
  63.  

BTW. I should have said that it's always better if Lock Position is NO... And yes this sort of thing is job for Autodesk - they should find correct solution and fix the problem... In my testings - if Lock Position NO and you select attribute upper left - lower right it may work, but I tested with one attribute and sometimes it could fail...
« Last Edit: April 08, 2019, 06:05:50 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube


ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Stretch attributes (enhanced)
« Reply #9 on: April 08, 2019, 05:35:37 PM »
@marko  can you please post a video?

You have to test it and see if that's what you're looking for...
Code slightly changed...

Regards, M.R.
BTW. Now it doesn't matter how do you pick window... It is assumed that you work with WCS...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Stretch attributes (enhanced)
« Reply #10 on: April 09, 2019, 02:25:25 AM »
@marko  can you please post a video?

You have to test it and see if that's what you're looking for...
Code slightly changed...

Regards, M.R.
BTW. Now it doesn't matter how do you pick window... It is assumed that you work with WCS...
Ok now it works. I try if I can modify it to see the objects during the drag (even without the attributes). Thank you so much for your time.  :-)

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Stretch attributes (enhanced)
« Reply #11 on: April 09, 2019, 04:12:25 AM »
Maybe this is very simple (need to see attribs on drag), with a layer filter...
Code: [Select]
; (ALE_Edit_StretchAttribLayer "*")
;
(defun ALE_Edit_StretchAttribLayer (LyrNms / Pnt001 Pnt002 Ss_Str EntNam Countr)
  (if
    (and
      (setq Pnt001 (getpoint "\nSpecify first corner of Crossing Window: "))
      (not (initget 32))
      (setq Pnt002 (getcorner Pnt001 "\nSpecify opposite corner: "))
    )
    (progn
      (if (setq Ss_Str (ssget "_C" Pnt001 Pnt002 (list (cons 8 LyrNms))))
        (progn
          (princ "\nBase point: "   ) (vl-cmdf "_.STRETCH" Ss_Str "" "\\") (setq Pnt001 (getvar "LASTPOINT"))
          (princ "\nSecond point: " ) (vl-cmdf "\\"                      ) (setq Pnt002 (getvar "LASTPOINT"))
          (repeat (setq Countr (sslength Ss_Str))
            (and
              (= (cdr (assoc 0 (entget (setq EntNam (ssname Ss_Str (setq Countr (1- Countr))))))) "INSERT")
      (mapcar
        (function
          (lambda (a)
            (vla-move a (vlax-3d-point (trans Pnt001 1 0)) (vlax-3d-point (trans Pnt002 1 0)))
          )
        )
        (vlax-invoke (vlax-ename->vla-object EntNam) 'getattributes)
      )
            ) 
          )         
        )
        (princ "\nNo Objects to Stretch found in Crossing Window.")
      )
    )
  )
  (princ)
)

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Stretch attributes (enhanced)
« Reply #12 on: April 09, 2019, 09:27:47 AM »
What if not all attribute references are inside the CW?

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: Stretch attributes (enhanced)
« Reply #13 on: April 09, 2019, 09:40:53 AM »
What if not all attribute references are inside the CW?

You should have tested my code...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Stretch attributes (enhanced)
« Reply #14 on: April 09, 2019, 09:50:38 AM »
What if not all attribute references are inside the CW?

You should have tested my code...
I actually have, but I see you have revised it. Your previous code did have this problem.