BLOACH85 Posted February 26, 2009 Posted February 26, 2009 Hey guys im working on this new lisp that will draw a polyline rectangle around text and anything inside of it will trim and boom the rectangle magically disappears. I am kinda held up at figuring out how to get it to trim. Being that lisp does not recognize the extrim command (i guess because its an express tool?) So i will need some help so any of you expert lisper's out there feel free to help, cuss, spit, or whatever it is you do!!! Any ideas? Quote
Lee Mac Posted February 26, 2009 Posted February 26, 2009 There is a trick with trim that some people use and that is to zoom in so that everything on screen is inside of the rectangle and then invoke the trim command and it should trim the entity inside of the rectangle. Quote
Lee Mac Posted February 26, 2009 Posted February 26, 2009 If anyone can suggest a better way to do this, then I would be very interested to see how, as it bugs me having to zoom in and out to trim Quote
BLOACH85 Posted February 26, 2009 Author Posted February 26, 2009 Well is there a way to put it in lisp? but it would have to involve all the points huh? (by the way you like to ride bikes too?) Quote
Lee Mac Posted February 26, 2009 Posted February 26, 2009 (by the way you like to ride bikes too?) haha, a little off topic, but yes, I have ridden a motorbike since I was about 10 (mostly off-roading and trials riding of course), and have two bikes presently. As for the LISP coding, I would advise first getting the dims of the rectangle and deleting the text that it surrounds. Then use an ssget with a window and select all the objects that lie totally inside the rectangle and delete those. Then, I would do another ssget, with a crossing window, and perform a trim to all these entities. Quote
lpseifert Posted February 26, 2009 Posted February 26, 2009 If this is a learning exercise for you, don't look... from Joe Burke at the Swamp 38 years since I last didn't have a motorcycle... waiting for Spring again CookieCutter2 v1.1.zip Quote
Lee Mac Posted February 26, 2009 Posted February 26, 2009 Thanks for that Larry, I can see it would probably have taken a lot more coding than my LISP suggestions... Bloach, see here: http://www.cadtutor.net/forum/showthread.php?t=31788 Quote
uddfl Posted February 26, 2009 Posted February 26, 2009 Hey guys im working on this new lisp that will draw a polyline rectangle around text and anything inside of it will trim and boom the rectangle magically disappears. [...] There is a trick with trim that some people use and that is to zoom in so that everything on screen is inside of the rectangle and then invoke the trim command and it should trim the entity inside of the rectangle. If anyone can suggest a better way to do this, then I would be very interested to see how [...] 1. To create the selection set of objects to be trimmed, you should be able to use the "fence" option (maybe combine it with the offset command, provided you can identify a point inside the rectangle). By doing this you should be able to almost duplicate the EXTRIM function. 2. Why not just mask it? I mean, I don't know what kind of drawings you produce, but text masking can be a good practice as it allows you to keep the geometry of the model intact in case you need the annotation not to be shown. Quote
Lee Mac Posted February 27, 2009 Posted February 27, 2009 Many thanks for your suggestions Uddfl - masking is a great idea and imo should be used more, as you say, the actualy model stays in tact and the text is more of an information overlay. Thanks Lee Quote
BLOACH85 Posted March 2, 2009 Author Posted March 2, 2009 Ok guys so this is how far ive got. i have the textbox routine that will draw a rectangle at any angle around text it will then offset it 1 and delete the source object. then it will select the rectangle and let the user pick any crossing lines automatically, trim it then disappear. My question is when it lets the user pick the lines that are crossing, is there anything that i can put in this routine that will select the crossing lines and trim them automatically? or even lines that don't even intersect? but thats another thing in itself. Any guidance would be much appreciated. Quote
Lee Mac Posted March 2, 2009 Posted March 2, 2009 I suppose you could use a routine to find all intersections between the rectangle and other objects - but this would mean iterating through every entity in the drawing I would presume. Quote
Lee Mac Posted March 2, 2009 Posted March 2, 2009 Something like this will return all intersections between selected objects - I suppose you could modify it and use an 'ssget "X" ' to collect objects other than the rectangle (defun ssInter (ss / i y Ent1 Ent2 iArr iLst) (setq i (sslength ss)) (while (not (minusp (setq y (1- i) i (1- i)))) (setq Ent1 (vlax-ename->vla-object (ssname ss i))) (while (not (minusp (setq y (1- y)))) (setq Ent2 (vlax-ename->vla-object (ssname ss y)) iArr (vlax-variant-value (vla-IntersectWith Ent1 Ent2 acExtendNone))) (if (> (vlax-safearray-get-u-bound iArr 1) 0) (progn (setq iLst (vlax-safearray->list iArr)) (while (not (zerop (length iLst))) (setq ptLst (cons (list (car iLst) (cadr iLst) (caddr iLst)) ptLst) iLst (cdddr iLst)))))))) (defun c:test (/ ptLst) (vl-load-com) (ssInter (ssget)) (alert (vl-princ-to-string ptLst)) (princ)) Quote
BLOACH85 Posted March 2, 2009 Author Posted March 2, 2009 why not just use the points list or entlast? Quote
Lee Mac Posted March 2, 2009 Posted March 2, 2009 why not just use the points list or entlast? Sorry, I understand what you mean? Quote
BLOACH85 Posted March 2, 2009 Author Posted March 2, 2009 Well to have the rectangle drawn you have to have a points list of the four corners which once the rectangle is drawn can you use entlast or the points list as a base for anything intersecting the last object (entlast) to be trimmed? Quote
BLOACH85 Posted March 2, 2009 Author Posted March 2, 2009 Here is the main code (defun c:TB(/ Cnt# EntName^ Osmode# Pt PtsList@ SS& ss ln1 ln2 eln1 eln2 pln1 pln2 ln1p1 ln1p2 ln2p1 ln2p2 p1 p2 p3 p4 cmd osm) (setq Osmode# (getvar "OSMODE")) (princ "\nSelect Text, Mtext or Dimension for Text Box") (if (setq SS& (ssget '((-4 . "<OR")(0 . "TEXT")(0 . "MTEXT")(0 . "DIMENSION")(-4 . "OR>")))) (progn (command "UNDO" "BEGIN") (setvar "OSMODE" 4) (setq Cnt# 0) (repeat (sslength SS&) (setq EntName^ (ssname SS& Cnt#)) (setq PtsList@ (append (Text-Box EntName^) (list "C"))) (setq Cnt# (+ 4 Cnt#)) (command "PLINE" (foreach Pt PtsList@ (command Pt))) (command "_offset" "_erase" "_yes" 1 (entlast) "0,0,0" "exit") );repeat (command "_trim" "_last" "" "_crossing"(while(> (getvar "cmdactive")0)(command pause) ptslist@)"" "_erase" "_previous" "" "") (command "_multiple" "tb") (command "UNDO" "END") (setvar "OSMODE" Osmode#) (redraw) );progn (princ "\nNo Text, Mtext or Dimension selected.") ) (princ) ) Quote
Lee Mac Posted March 2, 2009 Posted March 2, 2009 Not sure we're on the same wavelength here Bloach, but try this: (defun ssinter (ss rec / vlst i j obj1 iarr) (setq i (length ss)) (while (not (minusp (setq i (1- i)))) (setq obj1 (nth i ss) iarr (vlax-variant-value (vla-intersectwith obj1 rec acextendnone))) (if (> (vlax-safearray-get-u-bound iarr 1) 0) (setq eLst (cons (vlax-vla-object->ename obj1) eLst))))) (defun c:test (/ rect eLst) (vl-load-com) (setq rect (car (entsel "\nSelect Rectangle..."))) (ssinter (mapcar 'vlax-ename->vla-object (vl-remove-if '(lambda (x) (eq x rect)) (mapcar 'cadr (ssnamex (ssget "X" (list (cons 410 (getvar "CTAB")))))))) (vlax-ename->vla-object rect)) (alert (vl-princ-to-string eLst)) (princ)) The above will return a list of all the entities intersecting your rectangle... Quote
BLOACH85 Posted March 2, 2009 Author Posted March 2, 2009 sorry dude i cant get my head on straight. been a bad weekend. sat morning an f2 tornado ripped through our community and sunday we had 6 inches of snow. so.... Quote
Lee Mac Posted March 2, 2009 Posted March 2, 2009 sorry dude i cant get my head on straight. been a bad weekend. sat morning an f2 tornado ripped through our community and sunday we had 6 inches of snow. so.... Blimey - I wouldn't be on top of my game either if that had just happened... 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.