Jump to content

Lisp request - click on block and get text output ?


sinnerboy

Recommended Posts

You're welcome ! Have fun !

 

That is a very helpful little tool, thanks steve! :)

 

Does anybody know how this would need to be altered to add the text in paperspace, instead of modelspace?

Edited by Dadgad
Link to comment
Share on other sites

That is a very helpful little tool, thanks steve! :)

Does anybody know how this would need to be altered to add the text in paperspace, instead of modelspace?

 

Not sure what you mean that Dadgad

 

Anonymous Name Friendly

(defun c:BlockName (/ #Ent #Point)
[color=blue](vl-load-com)      
[/color]  (and
   [color=blue](setq #Ent (ssget "_:S:E" '((0 . "INSERT"))))
[/color]    (setq #Point (getpoint "\nSpecify placement point for MText: "))
   (entmake (list
              '(0 . "MTEXT")
              '(100 . "AcDbEntity")
              '(100 . "AcDbMText")
              (cons 7 (getvar "textstyle"))
              (cons 10 (trans #Point 1 0))
              (cons 1
                    [color=blue](vla-get-EffectiveName
                          (vlax-ename->vla-object (ssname #Ent 0)))[/color])
            ) ;_ list
   ) ;_ entmake
 ) ;_ and
 (princ)
)

Link to comment
Share on other sites

Here's another version, tweaked to work with Dynamic Blocks and for all UCS / Views:

 

(defun c:bn ( / e p ) (vl-load-com)
   (if
       (and
           (setq e (ssget "_+.:E:S" '((0 . "INSERT"))))
           (setq e (vlax-ename->vla-object (ssname e 0)))
           (setq p (getpoint "\nSpecify Point for MText: "))
       )
       (entmake
           (list
              '(0 . "MTEXT")
              '(100 . "AcDbEntity")
              '(100 . "AcDbMText")
               (cons 7 (getvar 'TEXTSTYLE))
               (cons 10 (trans p 1 0))
               (cons 11 (getvar 'UCSXDIR))
               (cons 210 (trans '(0.0 0.0 1.0) 1 0 t))
               (cons 1
                   (vlax-get-property e
                       (if (vlax-property-available-p e 'effectivename)
                           'effectivename
                           'name
                       )
                   )
               )
           )
       )
   )
   (princ)
)

 

EDIT: Oops! pBe beat me to it :)

Link to comment
Share on other sites

(cons 11 (getvar 'UCSXDIR))
(cons 210 (trans '(0.0 0.0 1.0) 1 0 t))

 

Nice addition :thumbsup:

 

EDIT: Oops! pBe beat me to it :)

 

Doesn't happen very often though :lol:

 

Cheers Lee

Link to comment
Share on other sites

Nice addition :thumbsup:

 

Thanks to both of you, and I agree that the UCS function is a really nice added touch, as I want to use this from various perspectives, including isometrics. No problem, just set the UCS to VIEW and good to go from any perspective. After my last post as I was walking out the door to eat I realized I should have mentioned that too. :thumbsup:

My previous question still stands however. My blocks are in modelspace, but I am annotating in paperspace. Sure I could do them all and then filter select them and do a CHANGESPACE on the whole lot. After the point is selected in modelspace, could it be translated to paperspace, and the MTEXT inserted there?

 

Very frustrating to be so illisperate. The only computer class I ever took was at Berkeley in 1969, things have changed a bit since then.

PSPACE ANNOTATION.JPG

Link to comment
Share on other sites

Try this (for use through a Viewport):

 

(defun c:bn ( / e p ) (vl-load-com)
   (if
       (and
           (setq e (ssget "_+.:E:S" '((0 . "INSERT"))))
           (setq e (vlax-ename->vla-object (ssname e 0)))
           (setq p (getpoint "\nSpecify Point for MText: "))
       )
       (entmake
           (list
              '(0 . "MTEXT")
              '(100 . "AcDbEntity")
              '(100 . "AcDbMText")
               (cons   7 (getvar 'TEXTSTYLE))
               (cons  10 (trans (trans p 1 2) 2 3))
               (cons  11 (getvar 'UCSXDIR))
               (cons  50 (getvar 'VIEWTWIST))
               (cons 410 (getvar 'CTAB))
               (cons 210 (trans '(0.0 0.0 1.0) 1 0 t))
               (cons 1
                   (vlax-get-property e
                       (if (vlax-property-available-p e 'effectivename)
                           'effectivename
                           'name
                       )
                   )
               )
           )
       )
   )
   (princ)
)

 

EDIT: Updated to account for ViewTwist

Link to comment
Share on other sites

Lee, thank you very much, that's outstanding, don't even need to reset the UCS. My appetite has been seriously whetted by this little exercise. Keep up the great work! :beer:

Link to comment
Share on other sites

Lee, thank you very much, that's outstanding, don't even need to reset the UCS. My appetite has been seriously whetted by this little exercise. Keep up the great work! :beer:

 

Thanks Dadgad, you're very welcome :)

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