DeBroiler Posted June 6, 2019 Posted June 6, 2019 Hey all, i'm trying to "catch" a line with ssget. I know the x-coordinate of either the start- or the endpoint of the line i'm looking for, but i can't be sure wether it's gonna be the start- or endpoint having that certain x-coordinate. Also i want to include a certain "fuzz" factor, because the drawing is not super-accurate, with some of the entities not residing exactly where they should, but being "off" by about 0.00001 units or some such. So originally i went with the crossing option of ssget (i.e. (ssget "_C" 'pt1 'pt2)), but that didn't quite work right because the crossing option is dependant on objects being visible in the drawing area at the time of calling ssget and i want to iteratively catch lines scattered all over my drawing. So then i thought I'll just use (ssget "X") and filter for my lines, so this a minimal working example of what i've come up with: (defun c:get_line_by_start_or_endpoint ( x tol /) (ssget "X" (list '(-4 . "<OR") '(-4 . "<AND") '(-4 . "<=,*,*") (list 10 (+ x tol) 0.0 0.0) '(-4 . ">=,*,*") (list 10 (- x tol) 0.0 0.0) '(-4 . ">AND") '(-4 . "<AND") '(-4 . "<=,*,*") (list 11 (+ x tol) 0.0 0.0) '(-4 . ">=,*,*") (list 11 (- x tol) 0.0 0.0) '(-4 . ">AND") '(-4 . ">OR") '(0 . "LINE") '(8 . "MyLayer"))) ) Because i don't know wether it's gonna be the start- or the endpoint having the x-coordinate i'm looking, i have to use the whole "<or <and >and <and >and >or"-construct. Well the thing is it didn't work and as far as i can tell the problem seems to be, that the combination of "<and ... >and" with the relational ">=,*,*" / "<=,*,*" operatos. I tried catching lines only by the starting point omitting the whole <or <and and> <and and> or> construct and only using <=,*,* >=,*,* and it's working just fine: (defun c:get_line_by_startpoint ( x tol /) (ssget "X" (list '(-4 . "<=,*,*") (list 10 (+ x tol) 0.0 0.0) '(-4 . ">=,*,*") (list 10 (- x tol) 0.0 0.0) '(0 . "LINE") '(8 . "MyLayer"))) ) The problem is i honestly can't tell beforehand wether it's gonna be the start- or the endpoint having the specific x-coordinate. And of course i could just ssget for startpoints and ssget for endpoints and then combine the two selectionsets, but at this point this has become somewhat a matter of principle for me, because there just has to be a way to combine the operators that i need and make it work. So has anybody experience with combining logical and relational operators in a ssget function and might be able to point me in the right direction? Is there something i am missing? Any help would be greatly appreciated! Quote
marko_ribar Posted June 6, 2019 Posted June 6, 2019 The way you wrote your first (ssget) tells us that you are searching for zero length line with start/end points (list x 0.0 0.0)... Perhaps you should consider using 2 arguments x1 and x2, one for start and one for end vertex... Or if you have different coordinates of line at some angle, consider using searching of (list x1 y1 z1) and (list x2 y2 z2) with their corresponding DXF GC 10 or 11... Quote
marko_ribar Posted June 6, 2019 Posted June 6, 2019 7 minutes ago, marko_ribar said: The way you wrote your first (ssget) tells us that you are searching for zero length line with start/end points (list x 0.0 0.0)... Perhaps you should consider using 2 arguments x1 and x2, one for start and one for end vertex... Or if you have different coordinates of line at some angle, consider using searching of (list x1 y1 z1) and (list x2 y2 z2) with their corresponding DXF GC 10 or 11... Sorry, I overlooked that you are searching LINE by single vertex criteria - that's why <or ... or>... I don't know, but from what I see now the code seems to be fine and should work... My apology, regards... Quote
Roy_043 Posted June 6, 2019 Posted June 6, 2019 This really a spelling issue: (defun get_line_by_start_or_endpoint ( x tol /) (ssget "X" (list '(-4 . "<OR") '(-4 . "<AND") '(-4 . "<=,*,*") (list 10 (+ x tol) 0.0 0.0) '(-4 . ">=,*,*") (list 10 (- x tol) 0.0 0.0) '(-4 . "AND>") '(-4 . "<AND") '(-4 . "<=,*,*") (list 11 (+ x tol) 0.0 0.0) '(-4 . ">=,*,*") (list 11 (- x tol) 0.0 0.0) '(-4 . "AND>") '(-4 . "OR>") '(0 . "LINE") '(8 . "0") ) ) ) BTW: You should not use the 'C:' prefix for this type of function. 1 Quote
marko_ribar Posted June 6, 2019 Posted June 6, 2019 (edited) Yes, thanks Roy, I see it now : >AND, should be AND> >OR, should be OR> How you notice things amaze me... You are brilliant observer... Edited June 6, 2019 by marko_ribar 1 Quote
DeBroiler Posted June 6, 2019 Author Posted June 6, 2019 Goddman it and thank you so much roy, that was the problem! Now i feel like an iditot, thinking about how long i was trying to figure it out this morning, and all it was, was a stupid spelling error. My original code doesn't have a "c:" prefix for the function, that was just thought as a means to make it easier for potential problem-solvers to test my code. Quote
2dcd2b3d Posted June 13, 2019 Posted June 13, 2019 (edited) hi There, back in the day (1990) I wrote a lisp routine that combined "window" with "ssget" and called it "ssw". i cant find it now, been almost 30 years ago. (defun ssw) setq a ssget1 setq b selectbywindow This was before wpolygon options. only c or w (inters a b) ok This is totally vague but it was so handy. someone kept exploding hatching which ended up on Layer 0, hundreds of tiny dots & Lines. such a bummer. I hope this helps. good Luck. Edited June 13, 2019 by 2dcd2b3d 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.