Jump to content

Need Help with lsp to change a selected group of the block attributes text size


Recommended Posts

Posted (edited)

Hi.

I found a lsp from lee mac that used to change attribute width for all the blocks attributes in a drawing,

and I modify it to change the attribute text size.

I need help with 3 issues:

1. the most important is to be able to select a group of blocks to apply this change and not to all the blocks in the drawing.

2. to be able to assign the text size (need the lsp to prompt the user to choose the size). at the moment I need to open the lsp file and change the value there.

    in the attached lsp file I've tried to do it but I get an error that I fail to solve... this is the error:

    "; error : bad argument type <ASSOC> ; expected <INTEGER> at [invalid DXF/XED data]"

3. to select a specific attribute (Tag name) to change. I need to change tag that call "ORDER", and I need to set it in the lsp, no need to prompt the user to choose it.

 

thanks,

Ari. 

 

*EDIT:

here is a sample DWG:

 

attw11.lsp

 

Drawing1.dwg

Edited by aridzv
Posted

maybe it could help

 



use this ssget 
(setq s (ssget  '((0 . "INSERT") (66 . 1)))) 

and 
(assoc 40 . sz) 

sz.0 is not a INTEGER  neither a variable 

 

Posted

You have this posted else where and I offered a start solution on that forum.

 

How to change attribute text size of multiple blocks? - BricsCAD Forum (bricsys.com)

 

re questions asked there all the answers are in the code posted need subtle changes. Can add rotation similar to height request, remove the bname from ssget code.

Posted
20 hours ago, devitg said:

maybe it could help

 




use this ssget 
(setq s (ssget  '((0 . "INSERT") (66 . 1)))) 

and 
(assoc 40 . sz) 

sz.0 is not a INTEGER  neither a variable 

 

@devitg

I tried it, but I'm getting errors.

this the code I'm trying:

 

(defun c:attw141 ( / e i s x sz )
 (if (null(setq sz (getdist "\nText size: ")))
(setq sz "5"))
    (if (setq s (ssget "_X" '((0 . "INSERT") (66 . 1))))
        (repeat (setq i (sslength s))
            (setq e (entnext (ssname s (setq i (1- i))))
                  x (entget e)
            )
            (while (= "ATTRIB" (cdr (assoc 0  x)))
                (or (equal 1.0 (cdr (assoc 40 x)) 1e-8)
                    (entmod ((assoc 40 sz)  (assoc 40 x) x))
                )
                (setq e (entnext e)
                      x (entget  e)
                )
            )
        )
    )
    (princ)
)

 

and this is the error I'm getting:

; error : bad argument type <12.0> ; expected <LIST> at [assoc]

 

what am I doing wrong here?

Posted

For anyone else, what I posted.

 

(defun c:chatht ( / bent bent2 pt lay tagname ss bname x att)

(setq bent (nentsel "\Pick attribute"))
(setq pt (cadr bent))

(setq bent (entget (car bent)))
(setq lay (cdr (assoc 8 bent)))
(setq tagname (cdr (assoc 2 bent)))

(setq bent2 (ssname (ssget pt ) 0))
(setq bname (cdr (assoc 2 (entget bent2))))

(setq ss (ssget (list (cons 0 "INSERT") (cons 2 bname))))

(setq ht (getreal "\nEnter text height "))

(repeat (setq x (sslength ss))
(foreach att (vlax-invoke (setq obj (vlax-ename->vla-object (ssname SS (setq x (- x 1) )))) 'getattributes)
(if (= tagname (strcase (vla-get-tagstring att)))
(vla-put-height att ht)
)
)
)

(princ)
)

(c:chatht)

 

Posted (edited)

@BIGAL

I tried your code on the drawing attached here, and it raise an error:

; error : bad argument type <NIL> ; expected SELECTIONSET at [sslength]

 

about the sample drawing I've attached here:

the drawing has 3 inserted blocks, and all the blocks have a number of attributes.

only one attribute is visible, the one with Tag name "ORDER", and this is the attribute that I need to change its text size and rotation For  a selected groups of blocks, and if it is a problem so for all the blocks in the drawing.

for example - I need all the attributes with Tag Name "ORDER" to have text size of 24 and rotation angle of 0.

 

Drawing1.dwg

Edited by aridzv
Posted

Hard coded

(defun c:chatht2 ( / bent bent2 pt lay tagname ss bname x att)

;(setq bent (nentsel "\Pick attribute"))
;(setq pt (cadr bent))

;(setq bent (entget (car bent)))
;(setq lay (cdr (assoc 8 bent)))
;(setq tagname (cdr (assoc 2 bent)))

(setq tagname "ORDER")

(setq ss (ssget (list (cons 0 "INSERT"))))

(setq ht (getreal "\nEnter text height "))

(repeat (setq x (sslength ss))
  (setq obj (vlax-ename->vla-object (ssname SS (setq x (- x 1) ))))
  (if  (= (vla-get-hasattributes obj) :vlax-true)
    (foreach att (vlax-invoke obj 'getattributes)
      (if (= tagname (strcase (vla-get-tagstring att)))
        (vla-put-height att ht)
      )
    )
  )
)

(princ)
)

 

Posted

@BIGAL

THANKS!!!

works bountifully!!

based on your previous advises I have made some additions to the code (see attached lsp file).

and again - thank you for your guidance!!

Ari.

chatht15.lsp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...