maahee Posted April 4 Posted April 4 (edited) (setq ln (ssget "f" pts '((0 . "LINE") (62 . 1)(62 . 5)))) where pts is a list of points that can not select red and blue lines within the selection set (setq ln (ssget "_X" (list '(0 . "LWP*") '(-4 . "=,=,*") (list 10 (car p1) (cadr p1) 0.0)))) cant select the line that passes through the coordinate x ordinate 5 and y x ordinate 12 Edited April 4 by maahee Quote
Saxlle Posted April 4 Posted April 4 (edited) Hi @maahee, Try with this: (setq ln (ssget "_F" pts '((0 . "LINE") (-4 . "<NOT") (-4 . "<OR") (62 . 1) (62 . 5) (62 . 256) (-4 . "OR>") (-4 . "NOT>")))) This will reject selecting "LINE" entities which are colored in red, blue and bylayer (62 . 256) (bylayer present that LINE which cross over the red and blue LINE's). Use this reference to all "ssget" function reference: ssget. Edited April 4 by Saxlle 1 Quote
GLAVCVS Posted April 4 Posted April 4 Hi Maahee If what you're looking for is a mix of the two, maybe this is what you're looking for? (ssget "_X" (list (cons 0 "LWP*") '(-4 . "<and") '(-4 . "<not") '(-4 . "=,=,*") (list 10 (car p1) (cadr p1)) '(-4 . "not>") '(-4 . "<or") '(62 . 1) '(62 . 2) '(-4 . "or>") '(-4 . "and>") ) ) 1 Quote
maahee Posted April 4 Author Posted April 4 (edited) 6 hours ago, Saxlle said: Hi @maahee, Try with this: (setq ln (ssget "_F" pts '((0 . "LINE") (-4 . "<NOT") (-4 . "<OR") (62 . 1) (62 . 5) (62 . 256) (-4 . "OR>") (-4 . "NOT>")))) This will reject selecting "LINE" entities which are colored in red, blue and bylayer (62 . 256) (bylayer present that LINE which cross over the red and blue LINE's). Use this reference to all "ssget" function reference: ssget. hi Saxlle (setq ln (ssget '((0 . "LINE") (-4 . "<OR") (62 . 5) (62 . 1) (-4 . "OR>") ))) this line selects red and blue color lines, but it does not pick a red or blue layer object Edited April 4 by maahee Quote
maahee Posted April 4 Author Posted April 4 6 hours ago, GLAVCVS said: Hi Maahee If what you're looking for is a mix of the two, maybe this is what you're looking for? (ssget "_X" (list (cons 0 "LWP*") '(-4 . "<and") '(-4 . "<not") '(-4 . "=,=,*") (list 10 (car p1) (cadr p1)) '(-4 . "not>") '(-4 . "<or") '(62 . 1) '(62 . 2) '(-4 . "or>") '(-4 . "and>") ) ) Hiiii GLAVCVS Select only the pline that passes through the given co-ordinary, Thank you for the additional knowledge, Quote
Saxlle Posted April 4 Posted April 4 You didn't mention that you want a polylines. Just susbtitue (0 . "LINE") with (0 . "LWP*"). (setq ln (ssget '((0 . "LWP*") (-4 . "<OR") (62 . 5) (62 . 1) (-4 . "OR>") ))) 1 Quote
Lee Mac Posted April 4 Posted April 4 24 minutes ago, maahee said: (setq ln (ssget '((0 . "LINE") (-4 . "<OR") (62 . 5) (62 . 1) (-4 . "OR>") ))) this line selects red and blue color lines, but it does not pick a red or blue layer object To include the layer colour, you'll need to iterate over the layer table first and construct an appropriate filter (or check the layer colour for each object within the selection and prune the selection). Here's an example - (defun c:test ( / def lay lst ) (setq lst '(1 5)) ;; Target colours (while (setq def (tblnext "layer" (null def))) (if (member (abs (cdr (assoc 62 def))) lst) (setq lay (cons (cons 8 (LM:escapewildcards (cdr (assoc 2 def)))) lay)) ) ) (sssetfirst nil (ssget "_X" (append '( (000 . "LINE") (-04 . "<OR") ) (mapcar '(lambda ( x ) (cons 62 x)) lst) (if lay (append '( (-04 . "<AND") (062 . 256) (-04 . "<OR") ) lay '( (-04 . "OR>") (-04 . "AND>") (-04 . "OR>") ) ) '( (-04 . "OR>") ) ) ) ) ) (princ) ) ;; Escape Wildcards - Lee Mac ;; Escapes wildcard special characters in a supplied string (defun LM:escapewildcards ( str ) (vl-list->string (apply 'append (mapcar '(lambda ( c ) (if (member c '(35 64 46 42 63 126 91 93 45 44)) (list 96 c) (list c) ) ) (vl-string->list str) ) ) ) ) (princ) 1 Quote
GLAVCVS Posted April 4 Posted April 4 (edited) I had a hard time understanding you. Let's see if I can get it this time: (setq c nil) (ssget "_X" (list '(0 . "LWP*") (cons 8 (while (setq c (tblnext "LAYER" (if c nil (not (setq r nil))))) (setq r (if (member (cdr (assoc 62 c)) '(1 5)) (if r (strcat r "," (cdr (assoc 2 c))) (cdr (assoc 2 c))) r)) ) ) '(-4 . "=,=,*") (list 10 (car p1) (cadr p1)) ) ) Edited April 4 by GLAVCVS 1 Quote
GLAVCVS Posted April 4 Posted April 4 (edited) A brief explanation: 1) The line of code '(setq c nil)' is for if you have variable 'c' assigned because the 'while' clause of 'ssget' requires it to be initially 'nil'. 2) I've kept the filter to select only polylines that pass through point 'p1'. If you want to disable this filter, just disable the last two lines in the 'ssget' list. I hope I made myself clear. Edited April 4 by GLAVCVS 1 Quote
GLAVCVS Posted April 4 Posted April 4 If, in addition, the selection must take into account the objects on those layers and that have their color set to "bylayer", then... (ssget "_X" (list '(0 . "LWP*") (cons 8 (while (setq c (tblnext "LAYER" (if c nil T))) (setq r (if (member (cdr (assoc 62 c)) '(1 5)) (if r (strcat r "," (cdr (assoc 2 c))) (cdr (assoc 2 c))) r)) ) ) '(-4 . "=,=,*") (list 10 (car p1) (cadr p1)) '(62 . 256) ) ) 1 Quote
GLAVCVS Posted April 4 Posted April 4 But remember: 'c' and 'r' must be 'nil' before running this 'ssget' 1 Quote
maahee Posted 21 hours ago Author Posted 21 hours ago (defun C:or (/ dst) (prompt "\set UCS at 0,0") (while (setq w (getpoint)) (setq m (getpoint)) (setq x (car w)) (setq y (cadr w)) (setvar "osmode" 0) (if (< X 10) (command "dimordinate" w M ) (progn (setq e (ssget "X" (list '(0 . "DIMENSION") (CONS 42 X)))) (command "dimordinate" w M ) (command "_.CHPROP" e "" "_color" 1 "") ;;;;code;;;; ) ;progn ) ;if ) ;while (setvar "osmode" 511) ) (setq e (ssget "X" (list '(0 . "DIMENSION") (CONS 42 X)))) It does not create any selection set, dimension passing through only x-cordinate Quote
GLAVCVS Posted 19 hours ago Posted 19 hours ago Your question seems a little confusing to me. What do you want to achieve? Quote
maahee Posted 17 hours ago Author Posted 17 hours ago (edited) I only want to select the dimension that goes through the specific x-axis point and y-axis is veriable. example point (13,17) (15, 18) co-ordinate greater than 10, select dimension which goes through co-ordinate 13, 15. Edited 17 hours ago by maahee Quote
GLAVCVS Posted 14 hours ago Posted 14 hours ago Try (defun C:or (/ dst w m x y cj e n) (prompt "\nSet UCS at 0,0") (while (setq w (getpoint "\nFirst point")) (setq m (getpoint w) x (car w) y (cadr w) n nil ) (setvar "osmode" 0) (command "_dimordinate" w M) (if (> X 10) (if (setq cj (ssget "_F" (list w m) (list (cons 0 "DIMENSION")))) ;if (while (and cj (setq e (ssname cj (setq n (if n (1+ n) 0))))) (entmod (append (entget e) (list (cons 62 1)))) ) ) ) ) ;while (setvar "osmode" 511) ) 1 Quote
GLAVCVS Posted 4 hours ago Posted 4 hours ago According to your original code, the dimension drawn when the command is executed isn't changed. Only the existing dimensions are. Therefore, the call to DIMORDINATE should be made at the end of the loop, like this: (defun C:or (/ dst w m x y cj e n) (prompt "\nSet UCS at 0,0") (while (setq w (getpoint "\nFirst point")) (setq m (getpoint w) x (car w) y (cadr w) n nil ) (setvar "osmode" 0) (if (> X 10) (if (setq cj (ssget "_F" (list w m) (list (cons 0 "DIMENSION")))) ;if (while (and cj (setq e (ssname cj (setq n (if n (1+ n) 0))))) (entmod (append (entget e) (list (cons 62 1)))) ) ) ) (command "_dimordinate" w M) ) ;while (setvar "osmode" 511) ) 1 Quote
Steven P Posted 1 hour ago Posted 1 hour ago Your looking at DXF code 42 - which is "Actual Measurement" If X is say 1.2345 your selection set will look for dimensions measuring 1.2345 units, not passing through X coordinate 1.2345. Modified from Glavcvs code above: (ssget "_X" (list (cons 0 "DIMENSION") ; Filter for dimension '(-4 . "=,=,*") ; List filter modifiers (list 10 X Y ) ; Dimensions: '= 10' '= X' 'Anything Y' ) ; end list ) ; end ssget List filter modifiers could also be < or > '(-4 . "=,>,*") ; List filter modifiers (list 10 10 Y ) ; Dimensions: '= 10' 'X coord > 10' 'Anything Y' Weekend, beers last night, CAD is definitely off today so no testing done to check if I am typing rubbish or not. 1 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.