Silvercloak Posted March 28, 2012 Posted March 28, 2012 Please bear with me, I'm still really green on this. I'm trying to create a selection set that will choose only text and mtext. However it doesn't seem to be working for me. Is this correct? setq Tchg (ssget '((-4 . "<AND")(0 . "MTEXT")(0 . "TEXT"))) This is the complete code I've written, it's meant to just change text sizes that are selected, sort of a dummied down match prop command, as THAT particular command can sometimes do TOO much. (defun c:tchg () (setq CMD-ECHO (getvar "cmdecho")) (setvar "cmdecho" 0) (defun GetText () (setq en1 (car (entsel "\nChoose text entity to match with: "))) (setq OLDENT (entget en1)) (setq ENTCHANGE (assoc 40 OLDENT)) (setq ENTCHANGE (cdr ENTCHANGE)) ) ;;End get text (defun GetChange () (prompt "\nSelect all text entities you wish to change: ") (setq Tchg (ssget '((-4 . "<AND")(0 . "MTEXT")(0 . "TEXT"))) ) ) (GetText) ;(GetSize) (GetChange) (repeat (setq n (sslength Tchg)) (setq chg (ssname tchg (setq n (1- n)))) (setq Tval (cdr (assoc 40 (setq ts (entget chg))))) (entmod (subst (cons 40 entchange) (assoc 40 ts) ts)) ) (setvar "cmdecho" CMD-ECHO) ) Later at some point I might try to get it to include multileaders too, but I'll start with the simple stuff first. Silvercloak Quote
MSasu Posted March 28, 2012 Posted March 28, 2012 (edited) You forgot to close the logical construction: (ssget '((-4 . "<OR") (0 . "MTEXT")(0 . "TEXT") [color=red](-4 . "OR>")[/color])) But you may simplify that as: (ssget '((0 . "MTEXT,TEXT"))) Regards, Mircea Edited March 29, 2012 by MSasu code fixed Quote
Silvercloak Posted March 28, 2012 Author Posted March 28, 2012 Thank you, THAT was something they failed to teach me in class. Excellent. Quote
Silvercloak Posted March 28, 2012 Author Posted March 28, 2012 One other question that just occured to me. Is it possible to tell it to select by using either pick point OR crossing window or Window? Silvercloak Quote
MSasu Posted March 28, 2012 Posted March 28, 2012 Please check the help of SSGET function for available selection methods and combinations; also for filters with wild-characters check the WCMATCH function. Regards, Mircea Quote
Silvercloak Posted March 28, 2012 Author Posted March 28, 2012 Please check the help of SSGET function for available selection methods and combinations; also for filters with wild-characters check the WCMATCH function. Regards, Mircea Thank you, I read through that, but I'm still confused. Shouldn't this (setq Tchg (ssget "w"'((0 . "MTEXT, TEXT"))) allow the user to create a window and select only text and mtext? Silvercloak Quote
MSasu Posted March 28, 2012 Posted March 28, 2012 You should supply the points: (if (and (setq point1st (getpoint "\First corner: ")) (setq point2nd (getcorner point1st "\nOther corner: "))) (ssget "_W" point1st point2nd '((0 . "MTEXT, TEXT"))) ) Regards, Mircea Quote
Silvercloak Posted March 28, 2012 Author Posted March 28, 2012 You should supply the points: (if (and (setq point1st (getpoint "\First corner: ") point2nd (getcorner point1st "\nOther corner: "))) (ssget "_W" point1st point2nd '((0 . "MTEXT, TEXT"))) ) Regards, Mircea Thanks, I was kind of hoping that by leaving it without points, it would allow the user to click on either a point or blank space and then proceed with a crossing window or regular window. I'm discovering that AutoLISP is far less intuitive than I had hoped. Silvercloak Quote
MSasu Posted March 28, 2012 Posted March 28, 2012 If will call the function without a method - you may supply filter(s) or not - then the user will be allowed to use any of AutoCAD's standard selections method (i.e. pick, window, crossing, fence). I suggest you to follow some of the many tutorials available on SSGET function. Regards, Mircea Quote
Silvercloak Posted March 28, 2012 Author Posted March 28, 2012 I definitely will, thanks Mircea, it appears SSGET is more complex than it appears at first glance Quote
David Bethel Posted March 29, 2012 Posted March 29, 2012 Did you try an OR filter ? (setq Tchg (ssget '((-4 . "<OR")(0 . "MTEXT")(0 . "TEXT"))) =David Quote
irneb Posted March 29, 2012 Posted March 29, 2012 Did you try an OR filter ? (setq Tchg (ssget '((-4 . "<OR")(0 . "MTEXT")(0 . "TEXT"))) =David I also noticed that. The " Anyhow, you don't need the "" grouping in most cases (other than this one ) - it's already implied as such. It's only necessary when you have one or more OR's and portions thereof you want to have as AND's. Quote
marko_ribar Posted March 29, 2012 Posted March 29, 2012 What ab. "". I really have difficulties understanding XOR... Can someone explain with some example?... M.R. Quote
David Bethel Posted March 29, 2012 Posted March 29, 2012 What ab. "". I really have difficulties understanding XOR... Can someone explain with some example?... M.R. http://cplus.about.com/od/glossar1/g/xor.htm Basically XOR returns T if 1 and only 1 test of 2 operands returns T Quote
David Bethel Posted March 29, 2012 Posted March 29, 2012 (edited) I also noticed that. The " Anyhow, you don't need the "" grouping in most cases (other than this one ) - it's already implied as such. It's only necessary when you have one or more OR's and portions thereof you want to have as AND's. The AND test is normally used for 2 unique DXF group values, (-4 ". <AND") (0 . "CIRCLE) (40 . 1.0) (-4 . "AND>") You can also group AND filters within OR tests All of the logical filters (AND,OR,XOR,NOT) must be in balanced pairs Wildcards can get to be confusing when you start trying to combine "~" with "*" and "," sequences. Edited March 29, 2012 by David Bethel Quote
marko_ribar Posted March 29, 2012 Posted March 29, 2012 http://cplus.about.com/od/glossar1/g/xor.htm Basically XOR returns T if 1 and only 1 test of 2 operands returns T Thanks David... It's very understandable link... M.R. Quote
irneb Posted March 30, 2012 Posted March 30, 2012 The usual difficulty when working with and/or/xor is that most people (or rather most languages including English) doesn't define those words exactly as logical comparison defines them. Usually when people say "OR" what they mean is XOR (or Exclusive Or) - i.e. it's either the one or the other - not both. Logic Comp defines OR as "Any of the operands - even just one, but also more than one". Then you get to the AND ... which also sometimes gets confusing. Since people sometimes misuse the word in conversation - you end up with situations like these. In Logic Comp AND means "All the operands - not just some". The way lisp (and most other programming languages) work on these is the following: AND: Check if next operand returns True (or not nil in the case of Lisp). If the test is positive, continue. Else return False/Nil. If there's any more operands repeat from 1, else return True. OR: Check if next operand returns True (or not nil in the case of Lisp). If the test is positive, return True. Else continue. If there's any more operands, repeat from 1. Else return False/Nil. NOT: Basically an invert toggle. If the operand (only one - doesn't work on more) is False/Nil return True. If the operand is True/NotNil return False/Nil. XOR: This is how most people understand the word OR when spoken - i.e. as in "Either OR". Though Lisp doesn't have a XOR function, you can make one quite easily. The principle behind it would be to combine OR, NOT & AND. E.g.: (defun XOR (v1 v2 /) (and (or v1 v2) (not (and v1 v2))) ) Thus it returns an AND of an OR & (NOT) AND. I.e. True only if OR returns true, but AND returns FALSE - otherwise return False/Nil. Most other languages have built-in XOR functions/operators, but usually they'd be implemented similarly - just already done for you. Quote
irneb Posted March 30, 2012 Posted March 30, 2012 Wildcards can get to be confusing when you start trying to combine "~" with "*" and "," sequences.Not as confusing as when you try to use Regular Expressions ... but yes, you need your wits about you to understand what's going on. Quote
Lee Mac Posted March 30, 2012 Posted March 30, 2012 Three more variations of a possible XOR function, for fun: (defun XOR ( a b ) (or (and a (not b)) (and b (not a))) ) (defun XOR ( a b ) (and (or (not a) (not b)) (or a b)) ) (defun XOR ( a b ) (or (not (or (not a) b)) (not (or a (not b)))) ) Nice explanation Irne 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.