Jump to content

auto on/off an object


ehsantavassolian

Recommended Posts

auto on/off an object

i have an object or block drawn on a picture or map

i want to choose an object ,  and then for 10 times  (twice a second) , turn off and on the object , so i can compare the object with the picture below

Please advise me to improve the following code or alternate code

 

(defun c:onoff ()
  (setvar "cmdecho" 0)
  (setq s (ssget "_:L"))
  
  (while t
     (c:hideit)
    
     (redraw)
     (command "._delay" "300")
    
     (c:showit)
    
     (redraw)
     (command "._delay" "300")
  )

  (c:showit)
  (setvar "cmdecho" 0)
  (princ)
)

;;;;;;;;;;;;;;;;;;

(defun c:showit ( / i s )
    (if (setq s (ssget "_X" '((60 . 1))))
        (repeat (setq i (sslength s))
            (_substdxf 60 0 (entget (ssname s (setq i (1- i)))))
        )
    )
    (princ)
)
 
(defun c:hideit ( / i s )
    (if (setq s (ssget "_X" '((60 . 0))))
        (repeat (setq i (sslength s))
            (_substdxf 60 1 (entget (ssname s (setq i (1- i)))))
        )
    )
    (princ)
)
 
(defun _substdxf ( key value elst / pair )
    (if (setq pair (assoc key elst))
        (entmod (subst (cons key value) pair elst))
        (entmod (append elst (list (cons key value))))
    )
)

 

Link to comment
Share on other sites

i fond it 😁

 

(defun c:onoff (/ CurEnt CurObj CurSet)
(setq CurSet (ssget "_:L"))		;(ssget "P")
;(command "ZOOM" "OBJECT" CurSet "")
(setq CurEnt (ssname CurSet 0))
(setq CurObj (vlax-ename->vla-object CurEnt))
(repeat 6
;;; (vl-cmdf "._delay" "200")
(repeat 200000 (princ))
(vla-put-Visible CurObj :vlax-false)
(repeat 200000 (princ))
;;; (vl-cmdf "._delay" "200")
(vla-put-visible CurObj :vlax-true)
);repeat
(ssdel CurEnt CurSet)
(princ)
)

 

Edited by ehsantavassolian
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...