Author Topic: Investigating visibility state of graphic entities in blocks  (Read 236 times)

0 Members and 2 Guests are viewing this topic.

Giuseppe Beatrice

  • Newt
  • Posts: 24
Investigating visibility state of graphic entities in blocks
« on: September 22, 2017, 09:21:22 am »
Hello guys,
I want to investigate about the visibility state of entities in a dynamic block.
Is there a method to see via lisp if a line (or any other graphic entity) is visible or not in a certain visibility state?
Thanks in advance

CincyJeff

  • Newt
  • Posts: 68
Re: Investigating visibility state of graphic entities in blocks
« Reply #1 on: September 22, 2017, 12:15:19 pm »
You should be able to open the block in the Block Editor, set the visibility state as desired, and perform a search for the entity,

Lee Mac

  • Seagull
  • Posts: 11799
  • AutoCAD 2015 Windows 7 London, England
Re: Investigating visibility state of graphic entities in blocks
« Reply #2 on: September 22, 2017, 07:04:22 pm »
Check the value of DXF group 60.
« Last Edit: October 06, 2017, 01:41:29 pm by Lee Mac »

Grrr1337

  • Bull Frog
  • Posts: 397
Re: Investigating visibility state of graphic entities in blocks
« Reply #3 on: September 23, 2017, 02:43:50 pm »
Heres a start (I assumed that you were talking about the block's definition and its definition objects) :

Code - Auto/Visual Lisp: [Select]
  1. ; _$ (BlockRef->VisStatesL  (car (entsel "\nPick block reference: ")))
  2. ; (("VisibilityState0" <Entity name: 9180e75c30> <Entity name: 9180e75c40> <Entity name: 9180e75c50>) ("VisibilityState1" <Entity name: 9180e75c70> <Entity name: 9180e75c60> <Entity name: 9180e75c50>))
  3. (defun BlockRef->VisStatesL ( e / o L )
  4.  
  5.  ; https://www.theswamp.org/index.php?topic=53354.msg580794#msg580794
  6.  (defun SplitListTf ( prd lst / rtn tmp ) ; Lee Mac
  7.    (foreach itm lst
  8.      (if (apply prd (list itm))
  9.        (setq rtn (vl-list* (list itm) (reverse tmp) rtn) tmp nil)
  10.        (setq tmp (cons itm tmp))
  11.      )
  12.    )
  13.    (vl-remove nil (reverse (cons (reverse tmp) rtn)))
  14.  )
  15.  
  16.  (defun GroupN ( n L )
  17.    ( (lambda (f) (f n L))
  18.      (lambda (n L) (cond ( (not L) L) ( (cons ((lambda ( / tmp ) (repeat n (setq tmp (cons (car L) tmp)) (setq L (cdr L))) (reverse tmp))) (f n L)) ) ) )
  19.    )
  20.  )  
  21.  
  22.  (cond
  23.    ( (not e) )
  24.    ( (/= "AcDbBlockReference" (vla-get-ObjectName (setq o (vlax-ename->vla-object e)))) )
  25.    ( (setq o (vla-item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) (vla-get-EffectiveName o)))
  26.      (and
  27.        (setq L (cdr (assoc 360 (dictsearch (cdr (assoc 360 (entget (vlax-vla-object->ename o)))) "ACAD_ENHANCEDBLOCK"))))
  28.        (setq L (entget L))
  29.        (setq L
  30.          (mapcar '(lambda (x) (vl-remove-if-not '(lambda (xx) (member (type xx) '(str ename))) (mapcar 'cdr (apply 'append x))))
  31.            (GroupN 2 (SplitListTf '(lambda (x) (= 303 (car x))) (vl-member-if '(lambda (x) (= 303 (car x))) L)))
  32.          )
  33.        )
  34.      )
  35.    )
  36.  )
  37.  L
  38. ); defun BlockRef->VisStatesL

So the above returns an assoc list of (<VisParamName> <List of enames>) [car/cdr list accessing], heres a sample test from one of my blocks:

Code - Auto/Visual Lisp: [Select]
  1. _$ (BlockRef->VisStatesL  (car (entsel "\nPick block reference: ")))
  2. (("TOP"
  3.   <Entity name: 9180e31ac0>
  4.   <Entity name: 9180e31b30>
  5.   <Entity name: 9180e31bd0>
  6.   <Entity name: 9180e31be0>
  7.   <Entity name: 9180e31bf0>
  8.   <Entity name: 9180e31c00>
  9.  )
  10.  ("BOTTOM"
  11.    <Entity name: 9180e31af0>
  12.    <Entity name: 9180e31b00>
  13.    <Entity name: 9180e31b70>
  14.    <Entity name: 9180e31b80>
  15.    <Entity name: 9180e31b90>
  16.    <Entity name: 9180e31c10>
  17.   )
  18.  ("RIGHT"
  19.    <Entity name: 9180e31ad0>
  20.    <Entity name: 9180e31ae0>
  21.    <Entity name: 9180e31ba0>
  22.    <Entity name: 9180e31bb0>
  23.    <Entity name: 9180e31bc0>
  24.    <Entity name: 9180e31c20>
  25.   )
  26.  ("LEFT"
  27.    <Entity name: 9180e31b10>
  28.    <Entity name: 9180e31b20>
  29.    <Entity name: 9180e31b40>
  30.    <Entity name: 9180e31b50>
  31.    <Entity name: 9180e31b60>
  32.    <Entity name: 9180e31c30>
  33.   )
  34. )

Giuseppe Beatrice

  • Newt
  • Posts: 24
Re: Investigating visibility state of graphic entities in blocks
« Reply #4 on: October 02, 2017, 06:19:46 am »
Very nice job Grrr1337. It is exactly what I searched of; thank you a lot and pardon my delay.
I want to study Lee tips too.
Thanks you all, you are precious.

Grrr1337

  • Bull Frog
  • Posts: 397
Re: Investigating visibility state of graphic entities in blocks
« Reply #5 on: October 02, 2017, 10:18:53 am »
Very nice job Grrr1337. It is exactly what I searched of; thank you a lot and pardon my delay.

No problem, just be careful because I didn't tested it much - so there might be bugs.

I want to study Lee tips too.

Although it sounds logical (since GC 66 stands for the visibility of the entity), I tried to and
I didn't really understood what would be the exact approach with Lee's tip.
Since:
  • One could change the visibility state of the dynamic block reference, but how could he access the referenced entities inside the block reference? Atleast I've never heard of accessing reference objects inside a block reference.
  • One could access the definition entities, inside the block definition, but how could he change the visibility state then?
(Please do not understand like I'm picking up on these things, rather I'm asking questions.)

Giuseppe Beatrice

  • Newt
  • Posts: 24
Re: Investigating visibility state of graphic entities in blocks
« Reply #6 on: October 05, 2017, 06:06:15 am »
I have substituted the program lines 27-28 with the following:

(setq L (dictsearch (cdr (assoc 360 (entget (vlax-vla-object->ename o)))) "ACAD_ENHANCEDBLOCK"))
(setq L (vl-remove nil (mapcar '(lambda (x) (cond ((= (car x) 360) x))) L)))
(setq L (vl-some '(lambda (x) (cond ((= (cdr (assoc 0 (entget x))) "BLOCKVISIBILITYPARAMETER") (entget x))))  (mapcar 'cdr L)))

In fact, in some cases the first  (assoc 360 ...) returns other dynamic properties ("BLOCKBASEPOINTPARAMETER" etc...)
« Last Edit: October 05, 2017, 06:10:28 am by Giuseppe Beatrice »