Author Topic: Change the layer of attribute labels in a block  (Read 1516 times)

0 Members and 1 Guest are viewing this topic.

nini007

  • Newt
  • Posts: 58
Change the layer of attribute labels in a block
« on: November 10, 2021, 03:31:57 AM »
Hello the forum,

I need your help😀.
I have a "BIL" block on the "0-INFO-LOCAL" layer made up of three attributes on the "0" layer.

I would like by a lisp or any other command to change the layer of the labels of the attributes "0" in "0-INFO-LOCAL" or any other layer of my choice.
There is indeed the command "DEFDUCALQUE" the problem is that this only moves on DUCALQUE or DUBLOC.
I tried this macro:
Code: [Select]
^C^C-MODIFBLOCK;BIL;chprop;;_all;CA;0-INFO-LOCAL;_bclose; that doesn't work, I don't understand the error.
I also tried to change directly in my original block, re-import it and redefine all blocks unfortunately it doesn't work.

Does anyone have a tip or a lisp because I have plans with dozens of attributes to change.

PS: block in the attached file


thank you in advance for your help
Best regards

kpblc

  • Bull Frog
  • Posts: 396
Re: Change the layer of attribute labels in a block
« Reply #1 on: November 10, 2021, 05:45:22 AM »
I think the better way is to change attribute definitions to layer "0", all properties "ByBlock" and then _.attsync command
Sorry for my English.

nini007

  • Newt
  • Posts: 58
Re: Change the layer of attribute labels in a block
« Reply #2 on: November 11, 2021, 05:39:04 AM »
Hello,

Thank you for your message and your help.
Yes your proposal is fine unfortunately I have to do it on several dozen shots and do the manipulation on two different name blocks.
I would have liked if it is possible, maybe not, to automate the commands with a lisp, a macro or a script.

Best regard

kpblc

  • Bull Frog
  • Posts: 396
Re: Change the layer of attribute labels in a block
« Reply #3 on: November 11, 2021, 11:24:22 PM »
TO normalize block definition:
Code - Auto/Visual Lisp: [Select]
  1. (defun norm-block-def (/ ent adoc vla_ent def)
  2.   (if (= (type
  3.            (setq ent (vl-catch-all-apply (function (lambda () (car (entsel "\nSelect block to normalize <Cancel> : "))))))
  4.          ) ;_ end of type
  5.          'ename
  6.       ) ;_ end of =
  7.     (if (and (= (cdr (assoc 0 (entget ent))) "INSERT") (= (cdr (assoc 66 (entget ent))) 1))
  8.              (setq vla_ent (vlax-ename->vla-object ent)
  9.                    def     (vla-item (vla-get-blocks adoc)
  10.                                      (if (vlax-property-available-p vla_ent 'effectivename)
  11.                                        (vla-get-effectivename vla_ent)
  12.                                        (vla-get-name vla_ent)
  13.                                      ) ;_ end of if
  14.                            ) ;_ end of vla-item
  15.              ) ;_ end of setq
  16.              (vlax-for sub def
  17.                (if (= (vla-get-objectname sub) "AcDbAttributeDefinition")
  18.                  (progn (vla-put-layer sub "0")
  19.                         (vla-put-color sub 0)
  20.                         (vla-put-lineweight sub aclnwtbyblock)
  21.                         (vla-put-linetype sub "ByBlock")
  22.                  ) ;_ end of progn
  23.                ) ;_ end of if
  24.              ) ;_ end of vlax-for
  25.              (vl-cmdf "_.attsync" "_name" (vla-get-name def))
  26.              (vla-endundomark adoc)
  27.       ) ;_ end of progn
  28.       (princ "\nIt's not block with attributes!")
  29.     ) ;_ end of if
  30.     (princ "\nNothing selected")
  31.   ) ;_ end of if
  32.   (princ)
  33. ) ;_ end of defun
Sorry for my English.

nini007

  • Newt
  • Posts: 58
Re: Change the layer of attribute labels in a block
« Reply #4 on: November 12, 2021, 04:53:41 AM »
Hello :-),

I thank you for your message.
Pretty works for your code, it works great.
I make two small modifications in your code, I added "c:" and change the layer "0" by the layer "0-INFO-LOCAL"
One last little thing if possible, to be able to put the name of the block in the code so that it does not manually select it ? :idea:


Best regards

PS: no problem my English is not great either, more comfortable with French or Italian ;-)

kpblc

  • Bull Frog
  • Posts: 396
Re: Change the layer of attribute labels in a block
« Reply #5 on: November 12, 2021, 12:44:26 PM »
Seems like this.I didn't test this code
Code - Auto/Visual Lisp: [Select]
  1. (defun norm-block-def (/ ent adoc vla_ent def)
  2.   (if (and (= (type
  3.                 (setq ent (vl-catch-all-apply (function (lambda () (getstring "\nEnter block name <Cancel> : ")))))
  4.               ) ;_ end of type
  5.               'str
  6.            ) ;_ end of =
  7.            (tblobjname "block" ent)
  8.       ) ;_ end of and
  9.            (setq def (vla-item (vla-get-blocks adoc) ent))
  10.            (vlax-for sub def
  11.              (if (= (vla-get-objectname sub) "AcDbAttributeDefinition")
  12.                (progn (vla-put-layer sub "0")
  13.                       (vla-put-color sub 0)
  14.                       (vla-put-lineweight sub aclnwtbyblock)
  15.                       (vla-put-linetype sub "ByBlock")
  16.                ) ;_ end of progn
  17.              ) ;_ end of if
  18.            ) ;_ end of vlax-for
  19.            (vl-cmdf "_.attsync" "_name" (vla-get-name def))
  20.            (vla-endundomark adoc)
  21.     ) ;_ end of progn
  22.     (princ "\nWrong block name!")
  23.   ) ;_ end of if
  24.   (princ)
  25. ) ;_ end of defun
Sorry for my English.

nini007

  • Newt
  • Posts: 58
Re: Change the layer of attribute labels in a block
« Reply #6 on: November 14, 2021, 06:57:41 AM »
Hello :-),

Thank you for your message and for your help :wink:.
Sorry, maybe I misspoke.

I would have wanted the name of the block to be in the code without having to select it and write its name.


Best regards

nini007

  • Newt
  • Posts: 58
Re: Change the layer of attribute labels in a block
« Reply #7 on: November 26, 2021, 03:20:09 PM »
Hello :-D,
I have code which modifies the text of the attributes and I would like to modify some additional options.
For color and rotation it was easy, I found it to be "color and rotation" --> (setpropertyvalue e "Color" 5) and (setpropertyvalue e "rotation" 0)

I would like to know what the following options are called: --> Text style, width factor, slant angle, etc.

For the width factor I tried (setpropertyvalue e "width" 0.75), it doesn't work.


Thank you for your help.