Jump to content

Bnamelabel.lsp - how to edit text width and rotation?


webster

Recommended Posts

Hi LISP Experts

 

I have this awesome lsp that allows me to click on a block, and then label that block with a leader using my default selected text style. Works perfectly.

 

Is there any way to tweak the code to also reduce the text width to 0.9 and the text rotation the text to 45 degrees?

I'd like to use this function in isometric mode and would love for it to do this automatically if possible (as I'd have hundreds of blocks to label). I am currently editing each label manually after running the lsp.

 

Thank you!

Bnamelabel.LSP

Link to comment
Share on other sites

(defun c:BNameLabel (/ ent entl obj objl pt rl ud degset ) 
  (defun dtr (a) (* pi (/ a 180.0)))
  (cond 
    ((not (setq ent (car (entsel "\nSelect block: ")))))
    ((not (eq (cdr (assoc 0 (entget ent))) "INSERT")) (princ "\nInvalid object!"))
    ((setq pt (getpoint "\nSpecify first point: "))
     (setq entl (entlast))
     (vl-cmdf "_.mleader" "_non" pt "\\")
     (while (eq (logand 1 (getvar 'CMDACTIVE)) 1) (vl-cmdf ""))
     (if (not (equal entl (setq entl (entlast)))) 
       (progn 
         (vla-put-textstring 
           (setq objl (vlax-ename->vla-object entl))
           (vlax-get-property 
             (setq obj (vlax-ename->vla-object ent))
             (if (vlax-property-available-p obj 'EffectiveName) 
               'EffectiveName
               'Name
             )
           )
         )
         (setq coordlist1 (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget entl)))) ;edited line
         (if (> (- (car (car coordlist1)) (car (cadr coordlist1))) 0)
            (setq rl "right")
            (setq rl "left")
         )
         (if (> (- (cadr (cadr coordlist1)) (cadr (caddr coordlist1))) 0)
            (setq ud "up")
            (setq ud "down")
         )
         (cond
           ((and (= rl "right") (= ud "up"))
             (setq degset 45)
           )
           ((and (= rl "right") (= ud "down"))
             (setq degset 315)
           )
           ((and (= rl "left") (= ud "up"))
             (setq degset 315)
           )
           ((and (= rl "left") (= ud "down"))
             (setq degset 45)
           )
         )
         (vlax-put-property objl 'textrotation (dtr degset))
         (vlax-put-property objl 'textwidth 0.9)
       )
     )
    )
  )
  (princ)
)
(vl-load-com)
(princ)

like this?

Link to comment
Share on other sites

Hi Exceed

 

Thank you for your efforts on this.

Unfortunately, no.

 

This lsp is shortening the entire multileader frame width condensing the text over multiple lines. Ideally, I would like the description to maintain 1 line, however, for the text width to be reduced to 0.9. i.e. the character width.

 

When I have done this manually, I double-click and highlight the text, and then with the 'Text Formatting' dialog popup, I reduce the text width there to 0.9.

 

I am not seeing any rotation on the multileader, it maintains a rotation of 0.

 

Thank you.

 

 

Link to comment
Share on other sites

I tried (entmod (subst (cons 42 1.57) (assoc 42 ent) ent)), ok when you do a check 42 is 1.57 but the text is not rotated same with using property 'TextRotation, it may be my Bricscad V20, I did read a comment that you have to reset the arrow head point, then it changes.

 

I did notice that the end leader line point changes when you manually change the angle so I think that is the answer. Change more than one value. Now where is that landing point value hidden. One suggestion is to use setproperty will try it.

  • Like 1
Link to comment
Share on other sites

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...