pBe Posted September 24, 2011 Posted September 24, 2011 (edited) Well what do you know. Jeff H. was right all along, now that the parameters are clear anyone can ptich in. SplitTolayers DRAFT1 (defun c:Ntest (/ bnd _sort wdwsize objts EntColl ent wave b_ sp RemItm enx lnm cnt lyn lylst) (vl-load-com) (defun bnd (ent / ll ur) (vla-getboundingbox ent 'll 'ur) (if (< (distance (vlax-safearray->list ll) (vlax-safearray->list ur) ) WdwSize ) (list (vlax-safearray->list ll) (vlax-safearray->list ur)) ) ) (defun _sort (lst) (vl-sort lst (function (lambda (y1 y2) ([color=blue]<[/color] (cadr (caadr y1))(cadr (caadr y2)))))) ) (setq wdwsize 200.00 layern "Base" cnt 1 lylst nil) (if (setq objts (ssget "_X" (list '(0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE")(cons 8 layern)))) (progn (repeat (setq i (sslength objts)) (setq ent (ssname objts (setq i (1- i)))) (if (setq b (bnd (vlax-ename->vla-object ent)) ) (setq EntColl (cons (list ent b) EntColl) ) (entmod (subst (cons 8 "Too_Large") (assoc 8 (entget ent)) (entget ent) ) ) ) ) (setq EntColl (_sort EntColl)) (while (setq b_ (car EntColl)) (setq wave (ssget "_W" (setq sp (caadr b_)) (polar sp 0.785398163 (* WdwSize 1.41421356)) (list '(0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE")(cons 8 layern)) )) (repeat (sslength wave) (setq enx (entget (ssname wave 0))) (entmod (subst (cons 8 (setq lnm (strcat layern "_" (itoa cnt)))) (assoc 8 enx) enx ) ) (if (not (member lnm lylst))(setq lylst (cons lnm lylst))) (setq wave (ssdel (setq RemItm (ssname wave 0)) wave) EntColl (vl-remove (assoc RemItm EntColl) EntColl)) ) (setq cnt (1+ cnt)) ) (if lylst (foreach lyr lylst (setq lyn (entget (tblobjname "LAYER" lyr))) (entmod (subst (cons 62 (atoi (vl-string-left-trim (strcat layern "_") lyr)) )(assoc 62 lyn) lyn)) ) ) ) (princ (strcat "\nNo objects found on Layer " layern)) ) (princ) ) Found a bug on this code: the result varies from one drawing to another: I think it needs a better sorting routine, lowest Y nearest to Leftmost X Any suggestions are welcome. That means you EDIT: Fixed it Edited September 24, 2011 by pBe Quote
luiscarneirorm Posted September 24, 2011 Author Posted September 24, 2011 thanks for the help, I can only test the function Monday ... Good weekend ...:D:D Quote
luiscarneirorm Posted September 26, 2011 Author Posted September 26, 2011 Hum.... with the drawing that I put the example above the function does exactly what it is supposed, but with a slightly more complex is no longer so perfect Experiment with drawing placa4(post #36), and see what you think Quote
luiscarneirorm Posted September 26, 2011 Author Posted September 26, 2011 I've been testing the function in various designs, and I get it better how it works. I understand it's hard to improve it, as she has to follow some logical. you can just put the option to choose the window size? Thank you for your good work Quote
pBe Posted September 26, 2011 Posted September 26, 2011 I will make another version for you. on top of what you had now. and yes i will put the prompt for window size back for you I'll keep you posted. sorta busy right now luis Cheers 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.