Results 1 to 4 of 4

Thread: Dynamic block names..

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    I could stop if I wanted to
    Join Date
    2009-04
    Location
    Houston, TX
    Posts
    204
    Login to Give a bone
    0

    Default Dynamic block names..

    Does anyone know of a way to get the actual name (i. e. the filename) of a dynamic block once you have changed a parameter.. without using vla-get-effectivename or adding an invisible attribute to hold the name?

    I thought maybe this would work:

    Code:
    (setq en (ssname ss cntr)
              enlist (entget en)
              ent (tblobjname "BLOCK" (cdr (assoc 2 enlist)))
              entlist (entget ent)
              blkname (cdr (assoc 2 enlist)))
    But unfortunately it doesn't

    EDIT: Disregard, after rearranging some code, finally got it acceptable for this picky LT addon pkg. However, if there is a way to get the name without using the methods mentioned above, please share!
    Last edited by M. Kubitza; 2010-02-19 at 08:07 PM. Reason: Problem solved

  2. #2
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Dynamic block names..

    There is a way through pure lisp without using vla/vlax. The trick is to find those pesky dictionary objects which link the block to its original. E.g. say you have a block Insert's DXF data list:
    • Directly after the 102 code (102 . "{ACAD_XDICTIONARY") there should be a code 360 which points to the dictionary object's ename.
    • This in turn has another 360 directly following (3 . "AcDbBlockRepresentation")
    • This points to another dictionary with a 360 just after (3 . "AcDbRepData")
    • This one's a ACDB_BLOCKREPRESENTATION_DATA dictionary. Its got a 340 code at its end.
    • Which points to the original block record of which you can get the name from its code 2
    Here's some sample defun which takes an INSERT's ename / entget list:
    Code:
    ;; Get Block's effective name without ActiveX
    (defun EffectiveName (en / ed d1 d2 d3 br)
      (if (= (type en) 'ENAME) ;Check if ename is passed as argument
        (setq ed (entget en)) ;Get the dxf data
        (setq ed en) ;Else assume dxf data as argument
      ) ;_ end of if
      ;; Get the ACAD linking dictionary
      (setq d1 (entget (cdr (assoc 360 (member '(102 . "{ACAD_XDICTIONARY") ed)))))
      ;; Get the ACAD black representation dictionary
      (setq d2 (entget (cdr (assoc 360 (member '(3 . "AcDbBlockRepresentation") d1)))))
      ;; Get the Representation Data Dictionary
      (setq d3 (entget (cdr (assoc 360 (member '(3 . "AcDbRepData") d2)))))
      ;; Get the block record
      (setq br (entget (cdr (assoc 340 d3))))
      ;; Return the block's name
      (cdr (assoc 2 br))
    ) ;_ end of defun

  3. #3
    I could stop if I wanted to
    Join Date
    2009-04
    Location
    Houston, TX
    Posts
    204
    Login to Give a bone
    0

    Default Re: Dynamic block names..

    Worked like a charm as usual! Will have to just run with it for now, figure out what's actually happening over the weekend maybe, if possible.

    Can't thank you enough, you just saved me so much headache.

  4. #4
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Dynamic block names..

    You're welcome!

Similar Threads

  1. Replies: 2
    Last Post: 2013-06-04, 02:59 AM
  2. Replies: 1
    Last Post: 2012-02-16, 06:58 PM
  3. Replies: 1
    Last Post: 2012-01-17, 08:41 PM
  4. Edit Block Names within Block Editor
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2007-05-26, 06:04 PM
  5. Dynamic Blocks change names?
    By mcoffman in forum VBA/COM Interop
    Replies: 11
    Last Post: 2006-09-08, 03:43 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
  •