(defun setthecopyset (/ ctr ens1 ends1 ents1) (setq ss2 (ssadd) ctr 0 ens1 nil ends1 nil ents1 nil ) (repeat (sslength ss1) (setq ens1 (ssname ss1 ctr) ends1 (entget ens1) ents1 (cdr (assoc 0 ends1)) ctr (+ 1 ctr) ) (if (and (/= ents1 "DIMENSION")(/= ents1 "TEXT")(/- ents1 "MTEXT")(/= ents1 "LEADER")(/= ents1 "INSERT")) (progn (if (= ents1 "LWPOLYLINE") (progn (if (= (cdr (assoc 70 ends1)) 1)(ssadd ens1 ss2)) ) (ssadd ens1 ss2) ) ) ) ) (if (= ans "B")(command ".copy" ss2 "" ipt ipt)) (if (/= (sslength ss2) 0)(command ".chprop" ss2 "" "LA" ARCTHPATLAY "")) ) what I am doing - trying to create a selection subset from a larger set. Is the problem that acad doesn't like to sets at once? or the same object being in two sets? just curious - I can rewrite if needed. Jamie Duncan Consulting - If you're not part of the solution, there's good money in prolonging the problem.
How is it not working? Working with 2 (or more) selsets isn't a problem, as long as there aren't more than 126 of 'em. You can have the same entity in all of the 126 sets if you want. It appears that you are calling this inside another routine. If ss1 is set in the calling routine but is listed in the locals you won't be able to use it here unless you pass it as an argument. HTH, Jeff
Dont you have to say (setq ss2(ssadd ens1 ss2)) instead of just (ssadd ens1 ss2). Been a long time since I have used Lisp, but that is how I always did it. Also (maybe just a typo in here but) in your if condition for the type of object, the one for MTEXT is a /- instead of a /=.
That's it! thanks and (setq ss1 (ssadd)) creates an empty selection set. (ssadd ename ss1) adds entity named ename to ss1 - no setq required -- Jamie Duncan Consulting - If you're not part of the solution, there's good money in prolonging the problem.
Jamie, Another way to phrase it is: (if (not (member ents1 '("DIMENSION" "TEXT""MTEXT" "LEADER""INSERT"))) .... )
Yes thanks DB! I do that normally - set a variable in the beginning of the routin e with my exclusions - don't know why I didn't do it this time - would've saved a headache. The routine is part of a larger hatching routine that is for real size hatches ie bricks, metalroofing, pickets (for guards). The routine allows you to change the pattern, align the pattern , move the pattern, rotate, select a different boundary, create or not create additional boundary elements on the hatching layer, adjusts the layer automatically depending which hatch is selecteds, in the current UCS, all on the fly until the user is happy - and it now is working like a dream. The scaling of the pattern is automatic, and the preliminary insert point is the median of the bounding box of the objects selected. Uses an image menu for the swatches etc. cool eh? -- Jamie Duncan Consulting - If you're not part of the solution, there's good money in prolonging the problem.
Jamie Duncan wrote <snip> The 70 group code for lwpolylines and many other objects is a BCD (Binary-Coded Decimal) which usually, you do not look at using simple equality testing, because that is an all-inclusive test. For example, if your LWPOLYLINE is closed, and has its PLINEGEN flag enabled, the value of the 70 group code will not be 1, it will be 129 (plinegen = 128). So, the right way to do this is: (if (eq 1 (logand 1 (cdr (assoc 70 ends1)))) <the polyline is closed> <the polyline is open> ) Unlike (=), testing with (logand) allows you to mask out or ignore other bits that you're not interested in,
Eeeks, Gawd, I hate challenging you but ... Having dealt w/BCD in a previous life (I used to program PLCs for a living where BCDs are frequently used) I'd have to say I have a different understanding of what the BCD (Binary Coded Decimal) format is. The BCD format as I understand it, is a special (rather wasteful) data type where each digit in a number is represented by 4 bits. The plus side is that there are no round-off errors, the downside is of course the wasted bits. For example the number 2742. As stated, in BCD each digit is represented by 4 bits and then strung together, thus 2742: 2 = 0010 7 = 0111 4 = 0100 2 = 0010 ------------------- 0010 0100 0111 0010 (right->left which is atypical but more convenient for the following comparison) requires 16 bits. Whereas the "normal" binary representation of 2742: 0002 = 0000 0000 0000 0010 0004 = 0000 0000 0000 0100 0016 = 0000 0000 0001 0000 0032 = 0000 0000 0010 0000 0128 = 0000 0000 1000 0000 0512 = 0000 0010 0000 0000 2048 = 0000 1000 0000 0000 -------------------------- 2742 = 0000 1010 1011 0110 requires only 12 bits. I'd be surprised to find out AutoCAD is storing it's integer data in this (BCD) format though it could. I just don't understand why "they" would bother, as there would be no benefit as far as I can see (not for integers, different story for reals). In the PLC industry BCDs are sometimes used where high precision of fractional numbers is necessary (esp. where said numbers are used in accumulations), where a "lossy" format like single prec floats simply would contribute to significant compounding errors. Still, because of the overhead they are used sparingly. Anyway ... I would agree that the group 70 data is Bit Coded Integer data, utilizing individual bits to represent state. *No argument*. However, it's all about learning, so I welcome being found out wrong and apprised accordingly Tony. Thank you in advance for any thoughts you may have to share on this topic. Or any topic for that matter. Sincerely, Michael. "Tony Tanzillo" <tony.tanzillo/at/caddzone/dot/com> wrote in message </snip>
Tony, Thanks for pointing that out. I will make the change. I also see you use eq instead of =, Can I not say (= 1 (logand 1 (cdr (assoc 70 ends1)))) ? Thanks -- Jamie Duncan "How wrong it is for a woman to expect the man to build the world she wants, rather than to create it herself." - Anais Nin (1903-1977)
I use (eq) mostly out of habit, but you should know that if you wanted to compare to entity names, then (=) will not work. Another minor point is that the logic of that code could be condensed and made clearer: What the above test says, is 'if the entity is not an lwpolyine or is a closed lwpolyine, then add it to the selection set'. I might write it like this: (if (or (/= ents1 "LWPOLYLINE") (eq 0 (logand 1 (cdr (assoc 70 ends1)))) ) (ssadd ens1 ss2) ) While not a big deal, I generally find it easier to follow the logic of the latter version, even years later.
Is this about what the acronym BCD means? I couldn't tell you about any formal definition(s) of BCD, since I wasn't aware of them, and coined that one when I wrote the reply.
I might write it like this: Oops.. that should've been: (if (or (/= ents1 "LWPOLYLINE") (eq 1 (logand 1 (cdr (assoc 70 ends1)))) ) (ssadd ens1 ss2) )
I was going on (and on) about the Binary Coded Decimal format that I thought you were making reference to (which didn't fit in my mind), not so much the acronym per se. Anyway, I think I pretty much put everyone to sleep with that posting; kind of a Cliff Claven moment of sorts. Of course, this was a first. HAGWE.
Ok. Since I frequently assume the role of code police, you're certainly entitled to be the acronym police.
That's neatly done, and I appreciate neatness. Thanks for the help. -- Jamie Duncan "How wrong it is for a woman to expect the man to build the world she wants, rather than to create it herself." - Anais Nin (1903-1977)
This very geeky woman, although hopefully not always too geeky, thought it wasn't cliff claven at all. -- Jamie Duncan "How wrong it is for a woman to expect the man to build the world she wants, rather than to create it herself." - Anais Nin (1903-1977)
Thank you Jamie, you are very generous. <snip> I pretty much put everyone to sleep with that posting; kind of a Cliff Claven moment of sorts. </snip>