Author Topic: Dynamic Block has Alignment Parameter?  (Read 1349 times)

0 Members and 1 Guest are viewing this topic.

cmwade77

  • Swamp Rat
  • Posts: 1449
Dynamic Block has Alignment Parameter?
« on: August 17, 2023, 01:42:11 PM »
Does anyone have a way in LISP to check if a Dynamic Block has an alignment parameter?

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Dynamic Block has Alignment Parameter?
« Reply #1 on: August 18, 2023, 06:11:18 AM »
Does anyone have a way in LISP to check if a Dynamic Block has an alignment parameter?

You could use a function such as the following:
Code - Auto/Visual Lisp: [Select]
  1. ;; Has Dynamic Parameter Type  -  Lee Mac
  2. ;; Returns T if the supplied dynamic block reference contains a parameter of the given type
  3. ;; obj - [vla] VLA Block Reference object
  4. ;; typ - [str] Dynamic parameter type (may use wildcards)
  5.  
  6. (defun LM:hasdynamicparametertype ( obj typ / def )
  7.     (if
  8.         (and
  9.             (vlax-property-available-p obj 'effectivename)
  10.             (setq def
  11.                 (vla-item
  12.                     (vla-get-blocks (vla-get-document obj))
  13.                     (vla-get-effectivename obj)
  14.                 )
  15.             )
  16.             (= :vlax-true (vla-get-isdynamicblock def))
  17.             (= :vlax-true (vla-get-hasextensiondictionary def))
  18.         )
  19.         (vl-some
  20.            '(lambda ( grp )
  21.                 (and (= 360 (car grp))
  22.                      (wcmatch (cdr (assoc 0 (entget (cdr grp)))) typ)
  23.                 )
  24.             )
  25.             (dictsearch
  26.                 (vlax-vla-object->ename (vla-getextensiondictionary def))
  27.                 "acad_enhancedblock"
  28.             )
  29.         )
  30.     )
  31. )
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / ent )
  2.     (if (setq ent (car (entsel "\nSelect dynamic block: ")))
  3.         (LM:hasdynamicparametertype (vlax-ename->vla-object ent) "BLOCKALIGNMENTPARAMETER")
  4.     )
  5. )

cmwade77

  • Swamp Rat
  • Posts: 1449
Re: Dynamic Block has Alignment Parameter?
« Reply #2 on: August 18, 2023, 01:40:48 PM »
Perfect, that worked wonders, as always, thank you.

Out of curiosity is that code somewhere on your website or somewhere else? I just want to know so I know if I just didn't look hard enough in all of my searching everywhere for it.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Dynamic Block has Alignment Parameter?
« Reply #3 on: August 18, 2023, 05:20:08 PM »
Perfect, that worked wonders, as always, thank you.

You're welcome Chris, happy to help.

Out of curiosity is that code somewhere on your website or somewhere else? I just want to know so I know if I just didn't look hard enough in all of my searching everywhere for it.

No - I hadn't published that particular function anywhere prior.

cmwade77

  • Swamp Rat
  • Posts: 1449
Re: Dynamic Block has Alignment Parameter?
« Reply #4 on: August 18, 2023, 06:43:01 PM »
Ok, just making sure I am not loosing my touch at searching.....lol