Author Topic: vla-explode and delay  (Read 4300 times)

0 Members and 1 Guest are viewing this topic.

domenicomaria

  • Swamp Rat
  • Posts: 725
vla-explode and delay
« on: May 09, 2021, 02:41:14 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun :SS>OBJECT-LIST (ss / ind r)
  2.    (setq ind 0 r '())
  3.    (repeat (sslength ss)
  4.       (setq r (cons (vlax-ename->vla-object (ssname ss ind) ) r) )      (setq ind (+ 1 ind) )
  5.    )
  6.    (reverse r)
  7. )
  8.  
  9.  
  10. (defun :VLA-EXPLODE-SS (ss /  new-obj-lst ss-obj-lst x-obj)
  11.    (setq ss-obj-lst (:SS>OBJECT-LIST ss) )
  12.    
  13.    (setq new-obj-lst '() )
  14.    (mapcar '(lambda    (x-obj)
  15.                      (if(vlax-method-applicable-p x-obj 'explode)
  16.                         (progn
  17.                            (setq new-obj-lst (append (vlax-invoke x-obj 'explode) new-obj-lst ) )
  18.                            (vla-delete x-obj)
  19.                         )
  20.                      )
  21.             )
  22.               ss-obj-lst
  23.    )
  24.    new-obj-lst
  25. )
  26.  
  27.  
  28. ;   TEST    asks 2 POINTS
  29. ;         selects with the CROSSING option using these 2 POINTS
  30. ;         and gets the selection 2 TIMES :
  31. ;         BEFORE and AFTER the SELECION has been EXPLODED
  32. (defun c:test ( / ll-pt ss ss1 ss2 ur-pt)
  33.    (setq ll-pt (getpoint "\nLOWER LEFT point :"))
  34.    (initget 32)
  35.    (setq ur-pt (getcorner ll-pt "\nUPPER RIGHT point :"))
  36.    (setq ss1 (ssget "_C" ll-pt ur-pt) )
  37.    
  38.    (:VLA-EXPLODE-SS ss1)
  39.    ;   (command "delay" 10)  
  40.    (setq ss2 (ssget "_C" ll-pt ur-pt) )
  41.    
  42.    (setq r ss2)
  43. )
  44.  
  45.  

select some polylines, using the TEST function

If (command "delay" 10)   is commented
ss2 is NIL

IF NOT it is a VALID SELECTION SET !

WHY ?
« Last Edit: May 09, 2021, 02:45:11 AM by domenicomaria »

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: vla-explode and delay
« Reply #1 on: May 09, 2021, 03:56:46 AM »
Try with this simple mod...

Quote
(defun c:test ( / ll-pt ss ss1 ss2 ur-pt )
   (initget 1)
   (setq ll-pt (getpoint "\nLOWER LEFT point :"))
   (initget 32)
   (setq ur-pt (getcorner ll-pt "\nUPPER RIGHT point :"))
   (setq ss1 (ssget "_C" ll-pt ur-pt))
   (if (:VLA-EXPLODE-SS ss1)
     (setq ss2 (ssget "_C" ll-pt ur-pt))
   )
   (setq r ss2)
)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: vla-explode and delay
« Reply #2 on: May 09, 2021, 04:15:26 AM »
Try with this simple mod...

Quote
(defun c:test ( / ll-pt ss ss1 ss2 ur-pt )
   (initget 1)
   (setq ll-pt (getpoint "\nLOWER LEFT point :"))
   (initget 32)
   (setq ur-pt (getcorner ll-pt "\nUPPER RIGHT point :"))
   (setq ss1 (ssget "_C" ll-pt ur-pt))
   (if (:VLA-EXPLODE-SS ss1)
     (setq ss2 (ssget "_C" ll-pt ur-pt))
   )
   (setq r ss2)
)
I think he wants to have a selection (SS2) even if there are no objects to explode...

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: vla-explode and delay
« Reply #3 on: May 09, 2021, 04:19:23 AM »
I removed some local variables and more...
I have tried several times without the DELAY and always I get a selection.
Code: [Select]
(eq '() nil) => T
(null '())   => T
(not '())    => T
(not nil)    => T
(null nil)   => T
(type '()) => nil
(type nil) => nil

(defun :SS>OBJECT-LIST (ss / ind r)
   (setq ind 0)
   (repeat (sslength ss)
      (setq r (cons (vlax-ename->vla-object (ssname ss ind) ) r) )      (setq ind (+ 1 ind) )
   )
   (reverse r)
)
(defun :VLA-EXPLODE-SS (ss / new-obj-lst ss-obj-lst)
   (setq ss-obj-lst (:SS>OBJECT-LIST ss) )
   (mapcar '(lambda    (x-obj)
                     (if(vlax-method-applicable-p x-obj 'explode)
                        (progn
                           (setq new-obj-lst (append (vlax-invoke x-obj 'explode) new-obj-lst ) )
                           (vla-delete x-obj)
                        )
                     )
            )
              ss-obj-lst
   )
   new-obj-lst
)
(defun c:test ( / ll-pt ss1 ss2 ur-pt)
   (setq ll-pt (getpoint "\nLOWER LEFT point :"))
   (initget 32)
   (setq ur-pt (getcorner ll-pt "\nUPPER RIGHT point :"))
   (setq ss1 (ssget "_C" ll-pt ur-pt) )
   (:VLA-EXPLODE-SS ss1)
   (setq ss2 (ssget "_C" ll-pt ur-pt) )
)

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: vla-explode and delay
« Reply #4 on: May 09, 2021, 04:40:25 AM »
Quote
I think he wants to have a selection (SS2) even if there are no objects to explode...

yes

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: vla-explode and delay
« Reply #5 on: May 09, 2021, 04:42:16 AM »
Quote
I have tried several times without the DELAY and always I get a selection.

in acad 2020 ?

without the DELAY, I NEVER get a selection !

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: vla-explode and delay
« Reply #6 on: May 09, 2021, 04:43:38 AM »
Quote
(eq '() nil) => T
(null '())   => T
(not '())    => T
(not nil)    => T
(null nil)   => T
(type '()) => nil
(type nil) => nil

Why do you post this ?

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: vla-explode and delay
« Reply #7 on: May 09, 2021, 05:14:56 AM »
Quote
(eq '() nil) => T
(null '())   => T
(not '())    => T
(not nil)    => T
(null nil)   => T
(type '()) => nil
(type nil) => nil

Why do you post this ?
locals are always nil or '()   >>>   (eq '() nil) => T

(setq r '())
(setq new-obj-lst '() )

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: vla-explode and delay
« Reply #8 on: May 09, 2021, 05:19:42 AM »
Quote
I have tried several times without the DELAY and always I get a selection.

in acad 2020 ?

without the DELAY, I NEVER get a selection !
A2020:
Command: TEST
LOWER LEFT point :
UPPER RIGHT point :<Selection set: 19>

Command:
Command:  TEST

LOWER LEFT point :
UPPER RIGHT point :<Selection set: 20>

Command:
Command:  TEST

LOWER LEFT point :
UPPER RIGHT point :<Selection set: 27>

Command:
Command:  TEST

LOWER LEFT point :
UPPER RIGHT point :<Selection set: 2e>

Command:
Command:  TEST

LOWER LEFT point :
UPPER RIGHT point :<Selection set: 35>

Command:
Command:  TEST

LOWER LEFT point :
UPPER RIGHT point :<Selection set: 3c>

Command:
Command:  TEST

LOWER LEFT point :
UPPER RIGHT point :<Selection set: 43>

Command:
Command:  TEST

LOWER LEFT point :
UPPER RIGHT point :<Selection set: 4a>

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: vla-explode and delay
« Reply #9 on: May 09, 2021, 06:03:24 AM »
Quote
locals are always nil or '()   >>>   (eq '() nil) => T

(setq r '())
(setq new-obj-lst '() )

I know that local vars are always NIL.

I write (setq r '()) or (setq new-obj-lst '() )

just to show to myself, that I initializing a new var to nil . . .

But It has no sense ! . . .


domenicomaria

  • Swamp Rat
  • Posts: 725
Re: vla-explode and delay
« Reply #10 on: May 09, 2021, 06:26:01 AM »
Quote
A2020:
Command: TEST
LOWER LEFT point :
UPPER RIGHT point :<Selection set: 19>

Command:
Command:  TEST

LOWER LEFT point :
UPPER RIGHT point :<Selection set: 20>

Command:
Command:  TEST

LOWER LEFT point :
UPPER RIGHT point :<Selection set: 27>

Command:
Command:  TEST

LOWER LEFT point :
UPPER RIGHT point :<Selection set: 2e>

Command:
Command:  TEST

LOWER LEFT point :
UPPER RIGHT point :<Selection set: 35>

Draw 4 or 5 polylines.

Copy them 4-5 times.

And repeat the test . . .

When they are exploded, (ss1 contains only polylines)
ss2 is NIL

If there is no polyline to explode,
ss2 is a selection set.

The problem
(I believe)
is the SEQUENCE
that is NOT RESPECTED.

(setq ss2 (ssget "_C" ll-pt ur-pt) )
does NOT WAIT that
(:VLA-EXPLODE-SS ss1) has finished !

If ss1 does not contain EXPLODABLE objects,
(:VLA-EXPLODE-SS ss1)
needs less time to finish.

And this time is enough.

And
(setq ss2 (ssget "_C" ll-pt ur-pt) )
gets the selection set !

It is very strange !
If I enable the DELAY

I get ALWAYS a selection set.

If NOT,
i get a selection set,
only if the selection does not contain explodable objects.

« Last Edit: May 09, 2021, 06:32:39 AM by domenicomaria »

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: vla-explode and delay
« Reply #11 on: May 09, 2021, 07:02:21 AM »
Playing with words...

Quote
only if the selection does not contain explodable objects.

only if the selection does contain not explodable objects.
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: vla-explode and delay
« Reply #12 on: May 09, 2021, 07:13:37 AM »
Playing with words...

Quote
only if the selection does not contain explodable objects.

only if the selection does contain not explodable objects.

If you want change the text
you have to write :
only if the selection does contains not explodable objects.

But this is not the main question.

ribarm

  • Gator
  • Posts: 3274
  • Marko Ribar, architect
Re: vla-explode and delay
« Reply #13 on: May 09, 2021, 07:32:50 AM »
You want everything to be written for you...

Have you tried :

Code: [Select]
(defun c:test ( / ll-pt ss1 ss2 ur-pt )
   (initget 1)
   (setq ll-pt (getpoint "\nLOWER LEFT point :"))
   (initget 33)
   (setq ur-pt (getcorner ll-pt "\nUPPER RIGHT point :"))
   (setq ss1 (ssget "_C" ll-pt ur-pt))
   (if (:VLA-EXPLODE-SS ss1)
     (setq ss2 (ssget "_C" ll-pt ur-pt))
     (setq ss2 (ssget "_C" ll-pt ur-pt))
   )
   (setq r ss2)
)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

domenicomaria

  • Swamp Rat
  • Posts: 725
Re: vla-explode and delay
« Reply #14 on: May 09, 2021, 10:18:06 AM »
only this :
(setq ss2 (ssget "_C" ll-pt ur-pt))

no need of "if"

as in the original code
...