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

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: vla-explode and delay
« Reply #15 on: May 09, 2021, 10:27:21 AM »
Quote
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.
Yes it is correct… What do you want to achieve in the end? a list of VlaObj or a Selset?

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: vla-explode and delay
« Reply #16 on: May 09, 2021, 10:47:34 AM »
If you want to get rid of : delay, and achieve the same result as with delay, I am afraid, you'll have to go with (if), just like in example I showed...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: vla-explode and delay
« Reply #17 on: May 09, 2021, 11:26:06 AM »
Quote
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.
Yes it is correct… What do you want to achieve in the end? a list of VlaObj or a Selset?

1 - I select with "crossing" ll-pt ur-pt the first time, and get ss1
2 - I try to explode ss1
3 - I do the same previous selection ... "crossing" ll-pt ur-pt and I have to get ss2
     ... ss2 could contain or the same objects before they are exploded
      or the new objects after they are exploded or a mix ...

...anyway I have to get a selecion set...
... but sometimes it is NIL
... SS1 is a selection set
... SS2 is NIL
... with the same selection ... "crossing" ...

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

SS2 must get anyway something with the same selection  ... "crossing" ...

The question is NOT : what VLA-EXPLODE-SS returns.

The question is :
(setq ss1 (ssget "_C" ll-pt ur-pt))
if SS1 is not NIL,

why
(setq ss2 (ssget "_C" ll-pt ur-pt))
sometimes returns NIL ?

ONLY THIS !
« Last Edit: May 09, 2021, 11:37:42 AM by domenicomaria »

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: vla-explode and delay
« Reply #18 on: May 09, 2021, 11:30:32 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)
)

and what is the difference between this :
(if (:VLA-EXPLODE-SS ss1)
   (setq ss2 (ssget "_C" ll-pt ur-pt))
   (setq ss2 (ssget "_C" ll-pt ur-pt))
)


and this :
(:VLA-EXPLODE-SS ss1)
(setq ss2 (ssget "_C" ll-pt ur-pt))

?

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: vla-explode and delay
« Reply #19 on: May 09, 2021, 11:41:28 AM »
Quote
The question is :
(setq ss1 (ssget "_C" ll-pt ur-pt))
if SS1 is not NIL,

why
(setq ss2 (ssget "_C" ll-pt ur-pt))
sometimes returns NIL ?

ONLY THIS !

And  I believe that
this is because
(setq ss2 (ssget "_C" ll-pt ur-pt))
does not wait long enough
that (:VLA-EXPLODE-SS ss1)
finishes his work . . .
. . .
so if I ask to WAIT (DELAY)
it WORKS !
« Last Edit: May 09, 2021, 11:44:46 AM by domenicomaria »

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: vla-explode and delay
« Reply #20 on: May 09, 2021, 12:16:11 PM »
and what is the difference between this :
(if (:VLA-EXPLODE-SS ss1)
   (setq ss2 (ssget "_C" ll-pt ur-pt))
   (setq ss2 (ssget "_C" ll-pt ur-pt))
)


and this :
(:VLA-EXPLODE-SS ss1)
(setq ss2 (ssget "_C" ll-pt ur-pt))

?

The difference is just what you know : ss2 must wait until :VLA-EXPLODE finishes... The trick is that with just your second example, ss2 don't wait for checking return values of execution of :VLA-EXPLODE and so ss2 gets selection set as soon as there is nothing left behind after explode - if entities are not explodable, routine tries explosion, but unsucessful and originals are deleted and there are no checking for existance of leftovers. With first example (if) is checking for things left in collected list of new enitities, and if something is founded, ss2 gets both leftovers and what it finds beside it, else if there are no leftovers it gets just what it finds beside like there were no checking... So first exampe is somewhat more reliable than second, but all in all, in fact both should return something if first ss1 contains explodable entities, if not, (vla-explode) is useless and originals are removed, so ss2 is nil... You should be aware of what :VLA-EXPLODE do : in fact you should edit it so that only if entities are explodable (if (eq (vla-get-explodeble (vlax-ename->vla-object ename)) :vlax-true), it deletes originals, else it shouldn't do anything, neither explodeing, nor deleting them...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: vla-explode and delay
« Reply #21 on: May 09, 2021, 12:32:49 PM »
Quote
if entities are not explodable, routine tries explosion,
but unsucessful and originals are deleted
originals are deleted only if are explodable and exploded

Code - Auto/Visual Lisp: [Select]
  1. (if(vlax-method-applicable-p x-obj 'explode)
  2.    (progn
  3.       (setq new-obj-lst (append (vlax-invoke x-obj 'explode) new-obj-lst ) )
  4.       (vla-delete x-obj)
  5.    )
  6.  )

...

Quote
if not, (vla-explode) is useless and originals are removed, so ss2 is nil...
originals are deleted only if are explodable and exploded
...

Quote
(if (eq (vla-get-explodable (vlax-ename->vla-object ename)) :vlax-true)
is it not the same of :
(if(vlax-method-applicable-p x-obj 'explode) ?
...

Quote
The difference is just what you know : ss2 must wait until :VLA-EXPLODE finishes...
... and I am trying to understand WHY this happens ?

Quote
(if (:VLA-EXPLODE-SS ss1)
   (setq ss2 (ssget "_C" ll-pt ur-pt))
   (setq ss2 (ssget "_C" ll-pt ur-pt))
)

Any way, this one could be a good workaround . . .
I will give it a try.
...
But the main question is : WHY this happens ?

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: vla-explode and delay
« Reply #22 on: May 09, 2021, 12:45:19 PM »
Quote
(if (:VLA-EXPLODE-SS ss1)
   (setq ss2 (ssget "_C" ll-pt ur-pt))
   (setq ss2 (ssget "_C" ll-pt ur-pt))
)

anyway it doesn't work

it is not useful

(setq ss2 (ssget "_C" ll-pt ur-pt))

doesn't wait :VLA-EXPLODE-SS

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: vla-explode and delay
« Reply #23 on: May 09, 2021, 01:02:39 PM »
Domenico: What do you want to achieve in the end? a list of VlaObj or a Selset?
Code: [Select]
Comando: TEST
LOWER LEFT point :
UPPER RIGHT point :
10   ss1 Length
45   new-obj-lst Length
1   ss2 Length

Comando: TESTMR
LOWER LEFT point :
UPPER RIGHT point :
10   ss1 Length
1   ss2 Length
45   new-obj-lst Length
ONLY POLYLINES:
LOWER LEFT point :
UPPER RIGHT point :
9   ss1 Length
45   new-obj-lst Length; errore: tipo di argomento errato: lselsetp nil
Code: [Select]
(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 :"))
   (print (sslength (setq ss1 (ssget "_C" ll-pt ur-pt) )))  (princ "  ss1 Length ")
   (print (length (:VLA-EXPLODE-SS ss1))) (princ "  new-obj-lst Length")
   (print (sslength (setq ss2 (ssget "_C" ll-pt ur-pt) ))) (princ "  ss2 Length ")
   (princ)
)

(defun c:testMR ( / ll-pt ss1 ss2 ur-pt ObjLst)
   (initget 1)
   (setq ll-pt (getpoint "\nLOWER LEFT point :"))
   (initget 33)
   (setq ur-pt (getcorner ll-pt "\nUPPER RIGHT point :"))
   (print (sslength (setq ss1 (ssget "_C" ll-pt ur-pt) )))  (princ "  ss1 Length ")
   (if (setq ObjLst (:VLA-EXPLODE-SS ss1))
     (progn (print (sslength  (setq ss2 (ssget "_C" ll-pt ur-pt)))) (princ "  ss2 Length "))
     (progn (print (sslength  (setq ss2 (ssget "_C" ll-pt ur-pt)))) (princ "  ss2 Length "))
   )
   (print (length ObjLst)) (princ "  new-obj-lst Length")
   (princ)
)

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: vla-explode and delay
« Reply #24 on: May 09, 2021, 01:20:30 PM »
Try (vla-Update (vlax-get-acad-object)) instead of DELAY...

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: vla-explode and delay
« Reply #25 on: May 09, 2021, 01:43:23 PM »
Quote
Domenico: What do you want to achieve in the end? a list of VlaObj or a Selset?

I don't want achieve  anything.

I get a selection SS1 using "crossing", ll,  ur, ...

If SS1 is a selection set
after exploding or not exploding SS1
if I do the SAME SELECTION with the same method : ssget... crossing, ll, ur...

I have to get in anycase something.
SS2 MUST be a selection set and NOT NIL

SS2 HAS NO RELATION with what :VLA-EXPLODE-SS returns.

SS2 is the result of ssget, crossing . . .
But SOMETIMES, only sometimes, it is NIL.

If, after all, you execute
(setq ss2 (ssget "_"C" . . .))
using the same points
if SS1 was NOT NIL,
you wil get a selection set and NOT NIL ...
 . . .
I want achieve to KNOW, WHY I have to WAIT, to obtain that
(setq ss2 (ssget "_C" ll-pt ur-pt))
works correctly after (:VLA-EXPLODE-SS ss1)


errore: tipo di argomento errato: lselsetp nil
means that SS2 is NIL
because there is no SSLENGTH for NIL !

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: vla-explode and delay
« Reply #26 on: May 09, 2021, 01:52:46 PM »
Quote
Try (vla-Update (vlax-get-acad-object))
Code - Auto/Visual Lisp: [Select]
  1. (defun c:TEST ( / ll-pt ss ss1 ss2 ur-pt)
  2.    (setq ll-pt (getpoint "\nLOWER LEFT point :"))
  3.    (setq ur-pt (getcorner ll-pt "\nUPPER RIGHT point :"))
  4.    (setq ss1 (ssget "_C" ll-pt ur-pt) )
  5.    
  6.    (:VLA-EXPLODE-SS ss1)
  7.  
  8.    (setq ss2 (ssget "_C" ll-pt ur-pt) )
  9. )
  10.  
YES

It works ! ! !

But now,
the question is : why it works also with DELAY ?

Maybe DELAY, UPDATES the ACAD-OBJECT ?

It would be STRANGE !

Does the  ACAD-OBJECT  need time, to UPDATE itself AUTOMATICALLY ?

« Last Edit: May 09, 2021, 01:56:57 PM by domenicomaria »

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: vla-explode and delay
« Reply #27 on: May 09, 2021, 02:41:28 PM »
Code - Auto/Visual Lisp: [Select]
  1. (defun c:TEST ( / ll-pt ss ss1 ss2 ur-pt)
  2.    (setq ll-pt (getpoint "\nLOWER LEFT point :"))
  3.    (setq ur-pt (getcorner ll-pt "\nUPPER RIGHT point :"))
  4.    (setq ss1 (ssget "_C" ll-pt ur-pt) )
  5.    
  6.    (:VLA-EXPLODE-SS ss1)
  7.    (command "redraw")
  8.    ; (vla-Update (vlax-get-acad-object))
  9.    (setq ss2 (ssget "_C" ll-pt ur-pt) )
  10. )

(command "redraw")

Anyway, it seems that any call to a COMMAND,
produces the same effect .

Just to conclude :

when we use the "vla-xxxxx" functions,
mainly when new entities are created, modified or deleted,
we must not forget to update the drawing immediately afterwards.

If VLA-UPDATE exists, there is a good reason !
« Last Edit: May 10, 2021, 12:27:23 AM by domenicomaria »

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1451
  • Marco
Re: vla-explode and delay
« Reply #28 on: May 10, 2021, 03:59:33 AM »
When you use ssget selection methods ("C" "W" etc. which detect objects on the screen) the objects selected are the objects visible in the drawing area at the time of evaluation of the graphical selection, newly generated objects are not recognized by ssget until the drawing area is updated.

domenicomaria

  • Swamp Rat
  • Posts: 723
Re: vla-explode and delay
« Reply #29 on: May 10, 2021, 04:48:42 AM »
When you use ssget selection methods ("C" "W" etc. which detect objects on the screen) the objects selected are the objects visible in the drawing area at the time of evaluation of the graphical selection, newly generated objects are not recognized by ssget until the drawing area is updated.
RIGHT !