See the top rated post in this thread. Click here

Results 1 to 9 of 9

Thread: Edit Mtext Attribute in Block using LISP

  1. #1
    Member
    Join Date
    2021-04
    Posts
    9
    Login to Give a bone
    0

    Default Edit Mtext Attribute in Block using LISP

    Is there an AutoLISP function that works similar to ATTIPEDIT, or like pressing Ctrl and double clicking a Mtext Attribute in a Block? I’m wanting to pass it two arguments like EntityName and TagName. It would work similar to press the [...] button in the Enhanced Attribute Editor, but it would be used for custom AutoLISP programs. For starters I use: (setq EntityName (car (entsel))), and there are also several other ways to get it. The first part of the function might look like this.
    (defun MtextFunction (EntityName "TAGNAME") The real one of course.
    Thanks,
    Adam

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    560
    Login to Give a bone
    0

    Default Re: Edit Mtext Attribute in Block using LISP

    Have you looked into NENTSEL that allows direct access to a attribute. You can entmod or put-textstring dont need tagname.

    (entget (car (nentsel "\pick a attribute ")))

  3. #3
    Member
    Join Date
    2021-04
    Posts
    9
    Login to Give a bone
    0

    Default Re: Edit Mtext Attribute in Block using LISP

    I’m looking for an AutoLISP function that is run after a Dialog closes when the user picks a button like [...] to edit the Mtext Attribute in the block, which may have more than one Attribute. For example the Dialog may have prompts for Part Number, Quantity and Installation Notes. Right now I’m telling the users to press Ctrl and double click on the "INSTALLATION_NOTES" Mtext in the block. This works, but I would like a better way of doing it similar to the [...] button function in the Enhanced Attribute Editor so the user doesn't have to pick anything in the block.
    Thanks.

  4. #4
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    560
    Login to Give a bone
    0

    Default Re: Edit Mtext Attribute in Block using LISP

    In simplest terms 2 ways use a attribute tag name or use the attribute order. An example using tagname.

    Code:
    (foreach att (vlax-invoke (vlax-ename->vla-object blockobj) 'getattributes)
            (if (= tagname (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr) 
            ) ; end if

  5. #5
    Member
    Join Date
    2021-04
    Posts
    9
    Login to Give a bone
    0

    Default Re: Edit Mtext Attribute in Block using LISP

    Hi Big-AL. Thanks for the code, but I couldn't get it to load. Something to do with malformed list on input, and AutoLISP file doesn't have matching parentheses.

  6. #6
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    560
    Login to Give a bone
    0

    Default Re: Edit Mtext Attribute in Block using LISP

    It is an example of the bit of the code you would use in your code to change a attribute string value. There is more code wrapped around it. Like select a entity Blockobj and tagname the latter would be "INSTALLATION_NOTES"

    Code:
    (setq newstr (getstring "\nEnter new string "))
    (setq blockobj (vlax-ename->vla-object (car  (entsel "Pick block"))))
    (foreach att (vlax-invoke (vlax-ename->vla-object blockobj) 'getattributes)
            (if (= "INSTALLATION_NOTES" (strcase (vla-get-tagstring att)))
            (vla-put-textstring att newstr) 
            )
    )
    It should also do a error check does Block have attributes.

  7. #7
    Member
    Join Date
    2021-04
    Posts
    9
    Login to Give a bone
    0

    Default Re: Edit Mtext Attribute in Block using LISP

    Is there a way using AutoLISP to open the "MTEXT Editor" to edit a Mtext Attribute in a Block?
    I’m thinking you would only need the blocks EntityName and "TAGNAME" in an AutoLISP function.

  8. #8
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    1

    Default Re: Edit Mtext Attribute in Block using LISP

    This attached lisp may help:
    A replacement function for -attedit that uses dialog boxes instead of the command line for changing attribute or text Value, Position, Height, Width, Rotation, Style, Layer ,Color or Case. There are also options to draw a box around the text as well as one to Undo each modification one at a time. Modify Attribute Definitions, Mtext, Text or Dimension Objects as well.
    (load "Atted") Atted
    Attached Files Attached Files

  9. #9
    Member
    Join Date
    2021-04
    Posts
    9
    Login to Give a bone
    0

    Default Re: Edit Mtext Attribute in Block using LISP

    Tom, I’m looking into your code for Atted.lsp and it is impressive to say the least. It will take me some time to study it all and figure out what I need here. I appreciate it. Thanks.

Similar Threads

  1. 2016: MLEADERSTYLE - USING BLOCK FOR MTEXT HAS MISBEHAVING ATTRIBUTE
    By mmiles in forum AutoCAD Annotation
    Replies: 3
    Last Post: 2019-01-04, 06:21 PM
  2. 2014: want to edit mtext and other mtext also change
    By radosak368138 in forum AutoCAD General
    Replies: 1
    Last Post: 2013-04-27, 12:03 PM
  3. Copy previous Block Attribute Value to next Block Attribute
    By CADfunk MC in forum VBA/COM Interop
    Replies: 8
    Last Post: 2009-02-27, 09:46 PM
  4. Using lisp to Edit Attributes in a Title Block
    By Red Devil in forum AutoLISP
    Replies: 14
    Last Post: 2007-08-10, 06:42 AM
  5. Replies: 35
    Last Post: 2007-06-05, 10:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •