Author Topic: very fast code question ?  (Read 1321 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 291
very fast code question ?
« on: September 22, 2020, 05:56:38 AM »
hi
sorry i wonder some ~


i  am making some code
but in compex cad file ,  code is slow
so i would like to question

1.
(setq entall (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
   (vlax-map-collection entall '(lambda(x) (vla-put-visible x -1)))



2.
 (acet-ss-visible XX 0)     




QEUSTION :   


Is there any faster code than the one above?


Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: very fast code question ?
« Reply #1 on: September 22, 2020, 06:24:02 AM »
Try with a selection set:

;
Code: [Select]
Function: ALE_PutVisible
;
; Version 2.00
;
; TrueFl > :vlax-true = UnHide  -  :vlax-false = Hide
;
(defun ALE_PutVisible (SelSet TrueFl / VlaObj Countr Count2)
; (vl-load-com)
  (setq Count2 0)
  (repeat (setq Countr (sslength SelSet))
    (setq
      Countr (1- Countr)
      VlaObj (vlax-ename->vla-object (ssname SelSet Countr))
    )
    (and
      (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-visible (list VlaObj TrueFl)))
      (setq Count2 (1+ Count2))
    )
  )
  Count2
)

Dlanor

  • Bull Frog
  • Posts: 263
Re: very fast code question ?
« Reply #2 on: September 22, 2020, 06:42:00 AM »
hi
sorry i wonder some ~


i  am making some code
but in compex cad file ,  code is slow
so i would like to question

1.
(setq entall (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))))
   (vlax-map-collection entall '(lambda(x) (vla-put-visible x -1)))



2.
 (acet-ss-visible XX 0)     




QEUSTION :   


Is there any faster code than the one above?

Instead of checking every object, just find the invisible ones. Basically

Code - Auto/Visual Lisp: [Select]
  1. (setq ss (ssget "_X" '((60 . 1))))
  2. (cond (ss
  3.           (repeat (setq cnt (sslength ss))
  4.             (vlax-put (vlax-ename->vla-object (ssname ss (setq cnt (1- cnt)))) 'visible -1)
  5.           );end_repeat
  6.         )
  7. )
  8.  

I haven't tested but using (entmod) may be faster, but not by much.

dussla

  • Bull Frog
  • Posts: 291
Re: very fast code question ?
« Reply #3 on: September 22, 2020, 09:09:11 AM »
wow wow wow very fast

really really really thank yoyu

dussla

  • Bull Frog
  • Posts: 291
Re: very fast code question ?
« Reply #4 on: September 22, 2020, 09:09:47 AM »
wow wow wow very good very good

thank you thank you ~~