+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Senior Member
    Using
    AutoCAD 2015
    Join Date
    Mar 2016
    Posts
    150

    Default Extract specific Attribures to text or mtext

    Registered forum members do not see this ad.

    i found this lisp here on cad tutor. and it works great!
    but i was just wondering if i could just extract a specific attributes to text or mtext.
    here is the thread:
    http://www.cadtutor.net/forum/showth...ighlight=attmt


    i only needed the attributes "Hole_ID"
    can someone help?
    Attached Files

  2. #2
    Luminous Being Dadgad's Avatar
    Using
    AutoCAD 2013
    Join Date
    Nov 2011
    Location
    At the confluence of worthlessness & invaluability
    Posts
    6,056

    Default

    Try using the command NCOPY (NestedCopy), a great command.
    Volume and repetition do not validate opinions forged in the absence of thought.

  3. #3
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,702

    Default

    Like others here you pick a block and you getattributes looking for tag name = "Hole_id"

    No error checking just a crude example of picking a block and finding "Hole_id"
    Code:
    (foreach att (vlax-invoke (vlax-ename->vla-object (car (entsel))) 'getattributes)
            (if (= "HOLE_ID" (strcase (vla-get-tagstring att)))
            (alert (strcat "value found is "(vla-get-textstring att )))
            )
    )
    A man who never made mistakes never made anything

  4. #4
    Senior Member
    Using
    AutoCAD 2015
    Join Date
    Mar 2016
    Posts
    150

    Default

    Quote Originally Posted by BIGAL View Post
    Like others here you pick a block and you getattributes looking for tag name = "Hole_id"

    No error checking just a crude example of picking a block and finding "Hole_id"
    Code:
    (foreach att (vlax-invoke (vlax-ename->vla-object (car (entsel))) 'getattributes)
            (if (= "HOLE_ID" (strcase (vla-get-tagstring att)))
            (alert (strcat "value found is "(vla-get-textstring att )))
            )
    )

    thank you sir, i will try to figure out where will i put you code on the lisp... very much help!

  5. #5
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,702

    Default

    Here is a start, I would recommend adding a check does block have attributes, use entmake better than command for text.

    Code:
    (while (setq obj (vlax-ename->vla-object (car(entsel "pick block"))))
       (foreach att (vlax-invoke obj 'getattributes)
            (if (= "HOLE_ID" (strcase (vla-get-tagstring att)))
            (setq txt(vla-get-textstring att ))
            )
       )
      (if (/= txt nil)
      (progn 
        (setq pt (getpoint "pick point for text"))
        (command "text" pt 2.5 90 txt)
      )
      )
    )
    A man who never made mistakes never made anything

  6. #6
    Senior Member
    Using
    AutoCAD 2015
    Join Date
    Mar 2016
    Posts
    150

    Default

    Quote Originally Posted by BIGAL View Post
    Here is a start, I would recommend adding a check does block have attributes, use entmake better than command for text.

    Code:
    (while (setq obj (vlax-ename->vla-object (car(entsel "pick block"))))
       (foreach att (vlax-invoke obj 'getattributes)
            (if (= "HOLE_ID" (strcase (vla-get-tagstring att)))
            (setq txt(vla-get-textstring att ))
            )
       )
      (if (/= txt nil)
      (progn 
        (setq pt (getpoint "pick point for text"))
        (command "text" pt 2.5 90 txt)
      )
      )
    )

    i did it yey! thank you sir! look that i came up with!
    Code:
    (defun c:attmt(/ obj att txt pt)
    (while (setq obj (vlax-ename->vla-object (car(entsel "pick block"))))
       (foreach att (vlax-invoke obj 'getattributes)
            (if (= "HOLE_ID" (strcase (vla-get-tagstring att)))
            (setq txt(vla-get-textstring att ))
            )
       )
      (if (/= txt nil)
      (progn 
        (setq pt (getpoint "pick point for text"))
    ;    (command "text" pt 1.5 90 txt)
         (entmakex
        (list
          (cons 0   "MTEXT")         
          (cons 100 "AcDbEntity")          
          (cons 100 "AcDbMText")    
          (cons 10 pt)  
          (cons 40 1.5) 
          (cons 7 "Swis721 BlkOul BT")
          (cons 1 txt)
          
        )
            )
              
      )
      )
    )
    )
    the font won't work though >.<"

  7. #7
    Quantum Mechanic BIGAL's Avatar
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    10,702

    Default

    StyleName = "Standard" the cons 7 is probably looking for a style name not the font name. cons 7 "Standard"

    Entmake will over ride the text height which is good because if you use Command "text" it has two variants with and without text height. The height must be taken into account or code can error. I test but make sure what my text style is set to.
    A man who never made mistakes never made anything

  8. #8
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,246

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by ktbjx View Post
    the font won't work though >.<"
    Code:
         
    (cons 7 "Swis721 BlkOul BT") ;; delete or comment it
    (cons 1 (strcat "{\\fSwis721 BdOul BT|b0|i0|c0|p82;" txt "}"))

Similar Threads

  1. Replace specific text with closest mtext
    By MP7 in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 11th Nov 2017, 03:18 am
  2. Replies: 16
    Last Post: 17th Jan 2015, 08:05 am
  3. Extract values from specific attributes in a block based on tag name
    By mbaumhardt645 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 5th Aug 2013, 06:18 pm
  4. How to find all mtext which is using a specific text style?
    By salmonrose in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 3rd Feb 2010, 06:27 pm
  5. Extract text/Mtext as it appears in drawing
    By Robert J in forum AutoCAD General
    Replies: 0
    Last Post: 1st Jul 2008, 01:14 pm

Bookmarks

Posting Permissions

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