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

0 Members and 1 Guest are viewing this topic.

Hugo

  • Bull Frog
  • Posts: 300
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: 6122
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.    )
  17.  )
  18.  (if (and (setq e (car (entsel "\nSelect block to sync: ")))
  19.   (setq name (_name (vlax-ename->vla-object e)))
  20.   (setq ss (ssget "_x" (list '(0 . "insert") '(66 . 1))))
  21.      )
  22.    (progn (foreach x (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss)))
  23.     (and (eq (_name x) name) (setq atts (cons (_attpositions x) atts)))
  24.   )
  25.   (command "_.attsync" "_s" e "_yes")
  26.   (foreach x (apply 'append atts)
  27.     (vl-catch-all-apply 'vlax-put (list (car x) 'insertionpoint (cadr x)))
  28.     (vl-catch-all-apply 'vlax-put (list (car x) 'textalignmentpoint (caddr x)))
  29.     (vl-catch-all-apply 'vlax-put (list (car x) 'rotation (last x)))
  30.   )
  31.    )
  32.  )
  33.  (princ)
  34. )
« Last Edit: March 08, 2017, 12:23:06 pm by ronjonp »

Windows 10 x64 - AutoCAD 2017

Custom Build PC

Hugo

  • Bull Frog
  • Posts: 300
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: 6122
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 10 x64 - AutoCAD 2017

Custom Build PC