sivapathasunderam Posted March 20, 2023 Posted March 20, 2023 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 Quote
pkenewell Posted March 20, 2023 Posted March 20, 2023 (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 March 20, 2023 by pkenewell Edited to add delay function. Edit2: Changed method to match RonJonp using (vla-ZoomWindow), Edit3: added a redraw. 1 Quote
rlx Posted March 20, 2023 Posted March 20, 2023 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 1 Quote
ronjonp Posted March 20, 2023 Posted March 20, 2023 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) ) 1 Quote
pkenewell Posted March 20, 2023 Posted March 20, 2023 (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 March 20, 2023 by pkenewell Quote
pkenewell Posted March 20, 2023 Posted March 20, 2023 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. Quote
pkenewell Posted March 20, 2023 Posted March 20, 2023 Got it to Work! Added a (redraw) to the top of each loop in the repeat. See my original post updated again. Quote
sivapathasunderam Posted March 23, 2023 Author Posted March 23, 2023 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. Quote
pkenewell Posted March 23, 2023 Posted March 23, 2023 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. Quote
Recommended Posts
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.