Author Topic: replace block with another block that has attributes  (Read 15565 times)

0 Members and 1 Guest are viewing this topic.

Hugo

  • Bull Frog
  • Posts: 422
Re: replace block with another block that has attributes
« Reply #15 on: March 08, 2017, 07:32:13 AM »
Hello ronjonp

Can you change the me the rotation is also taken over.
I can not do this

Thank you

(Vl-catch-all-apply 'vlax-put (list e' rotation (cadr x))) :-(


Hallo ronjonp

Kannst du mir das änder das die Drehung auch übernommen wird.
ich schaffe das nicht

Danke

ronjonp

  • Needs a day job
  • Posts: 7526
Re: replace block with another block that has attributes
« Reply #16 on: March 08, 2017, 10:57:51 AM »
Try this:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:attsync2 (/ _attpositions _name atts e name ss)
  2.   (defun _attpositions (block / att result)
  3.     (foreach att (vlax-invoke block 'getattributes)
  4.       (setq result (cons (list att
  5.                                (vlax-get att 'insertionpoint)
  6.                                (vlax-get att 'textalignmentpoint)
  7.                                (vlax-get att 'rotation)
  8.                          )
  9.                          result
  10.                    )
  11.       )
  12.     )
  13.   )
  14.   (defun _name (b)
  15.     (cond ((vlax-property-available-p b 'effectivename) (vla-get-effectivename b))
  16.           ((vlax-property-available-p b 'name) (vla-get-name b))
  17.     )
  18.   )
  19.   (if (and (setq e (car (entsel "\nSelect block to sync: ")))
  20.            (setq name (_name (vlax-ename->vla-object e)))
  21.            (setq ss (ssget "_x" (list '(0 . "insert") '(66 . 1))))
  22.       )
  23.     (progn (foreach x (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss)))
  24.              (and (eq (_name x) name) (setq atts (cons (_attpositions x) atts)))
  25.            )
  26.            (command "_.attsync" "_s" e "_yes")
  27.            (foreach x (apply 'append atts)
  28.              (vl-catch-all-apply 'vlax-put (list (car x) 'insertionpoint (cadr x)))
  29.              (vl-catch-all-apply 'vlax-put (list (car x) 'textalignmentpoint (caddr x)))
  30.              (vl-catch-all-apply 'vlax-put (list (car x) 'rotation (last x)))
  31.            )
  32.     )
  33.   )
  34.   (princ)
  35. )
« Last Edit: March 08, 2017, 12:23:06 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Hugo

  • Bull Frog
  • Posts: 422
Re: replace block with another block that has attributes
« Reply #17 on: March 08, 2017, 11:44:44 AM »
Super Thank you this works Perfectly  :-) :-) :-)

The best Lisp in my collection
« Last Edit: March 08, 2017, 11:50:10 AM by Hugo »

ronjonp

  • Needs a day job
  • Posts: 7526
Re: replace block with another block that has attributes
« Reply #18 on: March 08, 2017, 12:09:04 PM »
Super Thank you this works Perfectly  :) :) :)

The best Lisp in my collection
:)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC