Author Topic: Avoid Hatches Sel - Reactor  (Read 2842 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Swamp Rat
  • Posts: 812
Avoid Hatches Sel - Reactor
« on: March 10, 2020, 03:28:19 AM »
Hey guys,
Currently I've got this working -
Code - Auto/Visual Lisp: [Select]
  1. (defun AvoidHatches:CB (rtr args / L )
  2.   (and
  3.    
  4.     (setq L
  5.       (
  6.         (lambda ( SS / i o L )
  7.           (if
  8.             (and SS
  9.               (repeat (setq i (sslength SS))
  10.                 (setq o (vlax-ename->vla-object (ssname SS (setq i (1- i)))))
  11.                 (setq L (cons o L))
  12.               ); repeat
  13.               (vl-some (function (lambda (o) (eq "AcDbHatch" (vla-get-ObjectName o)))) L)
  14.               (setq L (vl-remove-if (function (lambda (o) (eq "AcDbHatch" (vla-get-ObjectName o)))) L))
  15.             ); and
  16.             L
  17.           ); if
  18.         ); lambda
  19.         (cadr (ssgetfirst))
  20.       )
  21.     ); setq L
  22.     (
  23.       (lambda ( L / nSS )
  24.         (setq nSS (ssadd))
  25.         (foreach o L
  26.           (ssadd (vlax-vla-object->ename o) nSS)
  27.         ); foreach
  28.         (sssetfirst nil nil)
  29.         (sssetfirst nil nSS)
  30.       ); lambda
  31.       L
  32.     )
  33.   ); and
  34. ); defun  
  35.  
  36. (vlr-Miscellaneous-Reactor "AvoidHatches" '((:VLR-PickFirstModified . AvoidHatches:CB)))


But I am aware that my callback function might not be the faster way.

Can you come up with some alternatives that would be better? - to select anything else but the "HATCH" entities from the implied selection.

(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Avoid Hatches Sel - Reactor
« Reply #1 on: March 10, 2020, 06:33:59 AM »
I don't know if I understand the question correctly ... perhaps the easiest way is the fastest:
Code: [Select]
(setq NewSSt (ssadd))
(repeat (setq i (sslength SS))
  (or
    (= "HATCH" (cdr (assoc 0 (entget (setq EntNam (ssname SS (setq i (1- i))))))))
    (setq NewSSt (ssadd EntNam))
  )
)

VovKa

  • Water Moccasin
  • Posts: 1629
  • Ukraine
Re: Avoid Hatches Sel - Reactor
« Reply #2 on: March 10, 2020, 07:25:53 AM »
Currently I've got this working -
you've noticed that your function is 'recursive'?
the purpose of you filtering is unclear to me
why don't you want to use (ssget "_I" (list (cons 0 "~HATCH"))) ?

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Avoid Hatches Sel - Reactor
« Reply #3 on: March 10, 2020, 09:08:49 AM »
Changing the pickfirst selection within a function evaluated when the pickfirst selection is changed is never a good idea  :evil:

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Avoid Hatches Sel - Reactor
« Reply #4 on: March 10, 2020, 10:08:08 AM »
Also consider that a selection set can contain sub-entities.

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Avoid Hatches Sel - Reactor
« Reply #5 on: March 15, 2020, 04:27:04 PM »

Currently I've got this working -
you've noticed that your function is 'recursive'?
the purpose of you filtering is unclear to me
why don't you want to use (ssget "_I" (list (cons 0 "~HATCH"))) ?

Hi,
The point is while constantly selecting to filter out the hatch objects - the key is in lines 13. and 14.
"Recursion" stops when no acDbHatch objects are contained within the current selection.
My question was is if I could avoid the SS iteration in the 1st place - my callback function seems to be clumsy.



I don't know if I understand the question correctly ... perhaps the easiest way is the fastest:
Code: [Select]
(setq NewSSt (ssadd))
(repeat (setq i (sslength SS))
  (or
    (= "HATCH" (cdr (assoc 0 (entget (setq EntNam (ssname SS (setq i (1- i))))))))
    (setq NewSSt (ssadd EntNam))
  )
)

Thanks! I've got used with these lists that I've forgot I could just rebuilt the new SS within the iteration of the original SS.  :uglystupid2:
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: Avoid Hatches Sel - Reactor
« Reply #6 on: March 16, 2020, 04:24:19 AM »
Thanks! I've got used with these lists that I've forgot I could just rebuilt the new SS within the iteration of the original SS.  :uglystupid2:
Well come on is not really a big flaw!    8-)             (Google Transl.)