Jump to content

View objects while changing


Recommended Posts

Posted

Hello experts

Below lisp routine will change all polyline to Linetype generation enabled

I want to Zoom to each polyline while the lisp route working, Just for fun 

(defun c:plga (/ ss n)
  (if (setq ss (ssget "_X" '((0 . "*POLYLINE") (-4 . "<NOT") (-4 . "&") (70 . 128) (-4 . "NOT>"))))
    (repeat (setq n (sslength ss))
      (setq pl (vlax-ename->vla-object (ssname ss (setq n (1- n)))))
      (if (and (= (logand (cdr (assoc 70 (tblsearch "layer" (vla-get-Layer pl)))) 4) 0)
               (/= (vla-get-ObjectName pl) "AcDb3dPolyline"))
   (vlax-put pl 'LinetypeGeneration -1))))
(princ))

(Cond 

          ((vla-zoomwindow to each entity while doing

 

I hope it is clear

Posted (edited)

This code is a simple way to do it, but unless you have a really big drawing it will go so fast that you won't get to enjoy it unless you put in a delay.

 

 Edit: Added in the delay function, then used (vla-ZoomWindow) method and a then a (redraw), and set the delay to about 200 msec.

 

(defun pjk-delay (sec / elsp dt secs)
	(setq dt (getvar "DATE") secs (* 86400.0 (- dt (fix dt))))
	(while dt
		(setq dt (getvar "DATE") elsp (* 86400.0 (- dt (fix dt))))
		(if (or (< (- elsp secs) 0.0)(>= (- elsp secs) sec))(setq dt nil))
	)
   (princ)
) ;; End Function (pjk-delay)

(defun c:plga (/ a b ao ss n n1 pl)
  (setq ao (vlax-get-acad-object))
  (if (setq ss (ssget "_X" '((0 . "*POLYLINE") (-4 . "<NOT") (-4 . "&") (70 . 128) (-4 . "NOT>"))))
    (repeat (setq n (sslength ss))
      (setq pl (vlax-ename->vla-object (setq n1 (ssname ss (setq n (1- n)))))); added variable "n1" to get ename.
      (if (and (= (logand (cdr (assoc 70 (tblsearch "layer" (vla-get-Layer pl)))) 4) 0)
               (/= (vla-get-ObjectName pl) "AcDb3dPolyline"))
        (Progn
           (redraw)
           (vla-getboundingbox pl 'a 'b)
           (vla-zoomwindow ao a b)
           (redraw)
           (vlax-put pl 'LinetypeGeneration -1)
           (pjk-delay 0.2)
        )
      )
    )
  )
  (princ)
)

 

Edited by pkenewell
Edited to add delay function. Edit2: Changed method to match RonJonp using (vla-ZoomWindow), Edit3: added a redraw.
  • Thanks 1
Posted

haven't got in on my phone (defun wait ( time ) ....) but you could put that between each zoom (so routine run its course) or (grread) so user can press any key to advance to next poly but think that will only be fun for the first ten thousand poly's 🥱

  • Like 1
Posted

Another way using vla-zoomwindow:

(defun c:plga (/ a ao b n n1 pl ss)
  (if (setq ss (ssget "_X" '((0 . "*POLYLINE") (-4 . "<NOT") (-4 . "&") (70 . 128) (-4 . "NOT>"))))
    (progn (setq ao (vlax-get-acad-object))
	   (repeat (setq n (sslength ss))
	     (setq pl (vlax-ename->vla-object (setq n1 (ssname ss (setq n (1- n))))))
	     (if (and (= (logand (cdr (assoc 70 (tblsearch "layer" (vla-get-layer pl)))) 4) 0)
		      (/= (vla-get-objectname pl) "AcDb3dPolyline")
		 )
	       (progn (vla-getboundingbox pl 'a 'b)
		      (vla-zoomwindow ao a b)
		      (vlax-put pl 'linetypegeneration -1)
	       )
	     )
	   )
    )
  )
  (princ)
)

 

  • Thanks 1
Posted (edited)

I added a delay function to the post above, but it doesn't work very well for me. The screen just blanks with an accumulative delay and I end up at the last zoom. I think it has to do with the screen regenerating. If you have a better solution - let me know. Perhaps using the (vla-ZoomWindow) will work better? I try it and see.

 

@ronjonp Yeah it turns out that the (vla-ZoomWindow) method works better with the delay. I will update my code above to match yours.

Edited by pkenewell
Posted

Updated code in my first post again to use (vla-ZoomWindow) and (vla-BoundingBox) like @ronjonp. It still does not work very well, not all the plines display. It might be possible to play with the delay time a bit to see what happens.

Posted

Got it to Work! Added a (redraw) to the top of each loop in the repeat. See my original post updated again.

Posted
On 3/20/2023 at 8:38 PM, pkenewell said:

This code is a simple way to do it, but unless you have a really big drawing it will go so fast that you won't get to enjoy it unless you put in a delay.

 Edit: Added in the delay function, then used (vla-ZoomWindow) method and a then a (redraw), and set the delay to about 200 msec.

On 3/21/2023 at 12:07 AM, ronjonp said:

Another way using vla-zoomwindow:

It seems to work perfectly!

Thank you all for you're help, I really appreciate it. 😀

Posted
5 hours ago, sivapathasunderam said:

It seems to work perfectly!

Thank you all for you're help, I really appreciate it. 😀

No problem. Glad it was helpful to you. 👍

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...