DGRL Posted March 25, 2018 Share Posted March 25, 2018 Hi Coders Was wondering if it is possible using visual lisp to select multiple objects from a list containing insertion points only So list contains multiple insertion points of different objects that needs to be selected one by one and if implemented in my routines do something with it Quote Link to comment Share on other sites More sharing options...
Grrr Posted March 25, 2018 Share Posted March 25, 2018 Yes - if the objects are blocks/texts, then iterate thru all and check their insertionpoint property. Else if the objects do not support such property, use the 'expanding circle' approach to select the nearest objects on the given fuzz value. Quote Link to comment Share on other sites More sharing options...
rlx Posted March 25, 2018 Share Posted March 25, 2018 (edited) just a quicky before bedtime ; near point - written for DGRL - rlx 25-3-2018 ; pl is point list '((x y)(x y)...) , fz is fuzz factor (defun c:tst ( / pl fz ss) (setq pl '((10 50)(20 50)(30 50)(40 50)(50 50)) fz 1 ss (ssget '((0 . "INSERT")))) (if ss (mapcar '(lambda (x) (princ "\n")(princ (getip x))) (chk (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))) (princ) ) (defun chk (%ss / l) (mapcar '(lambda (x) (if (near-member (getip x) pl fz) (setq l (cons x l)))) %ss) l) (defun near-member (l1 l2 tol) (vl-some (function (lambda (l3) (vl-every '(lambda (n1 n2)(equal n1 n2 tol)) l1 l3))) l2)) (defun getip (e) (list (cadr (assoc 10 (entget e)))(caddr (assoc 10 (entget e))))) (vl-load-com) ;(near-member '(20 50) '((10 50) (20 50) (30 50) (40 50)(50 50)) 0.1) -> T ;(near-member '(20 51) '((10 50) (20 50) (30 50) (40 50)(50 50)) 0.1) -> nil gr.Rlx Edited March 25, 2018 by rlx Quote Link to comment Share on other sites More sharing options...
DGRL Posted March 26, 2018 Author Share Posted March 26, 2018 @rlx Thanks for the example Appreciate it :-D Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 26, 2018 Share Posted March 26, 2018 Note that such groups can be filtered directly from the ssget filter list Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted March 26, 2018 Share Posted March 26, 2018 Note that such groups can be filtered directly from the ssget filter list FWIW, i prefer relational test pro: simple, reliable & efficient cons: no fuzz (setq [b] pl [/b]'((10. 50.)(20. 50.)(30. 50.)(40. 50.)(50. 50.))[color="green"]; point list[/color] ss (ssget (append (vl-list* '(0 . "CIRCLE,TEXT,INSERT"); filter '(-4 . "<OR") (apply 'append (mapcar ''((x) (list '(-4 . "=,=,*") (cons 10 x))) [b]pl [/b])) ) '((-4 . "OR>")) ) ) ) ) Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted March 26, 2018 Share Posted March 26, 2018 Note that such groups can be filtered directly from the ssget filter list oh.. Lee beat me to it before submit post Quote Link to comment Share on other sites More sharing options...
rlx Posted March 26, 2018 Share Posted March 26, 2018 Note that such groups can be filtered directly from the ssget filter list Last night my near-member function came to me saying he wanted a job because he was bored ... so I gave him one... Quote Link to comment Share on other sites More sharing options...
rlx Posted March 26, 2018 Share Posted March 26, 2018 FWIW, i prefer relational testpro: simple, reliable & efficient cons: no fuzz Reason I used fuzz was cause of a function I use to copy an entire array or 'table' of strings , rows and colums , from one set to another and had problems with mixed alignments. So one column used middle left , another just middle etc. and 'quickly' found out neither group 10 or 11 could always be trusted. So decided to use a fuzze factor and most or all my problems were gone. If coordinates are truly reliable then you're right and a 'simple' ssget filter is adequate. gr. Rlx Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 26, 2018 Share Posted March 26, 2018 FWIW, i prefer relational testpro: simple, reliable & efficient cons: no fuzz A fuzz factor is still possible in this scenario, for example: (defun ssget-by-pointlist ( lst fuz ) (ssget "_X" (append '( (0 . "ARC,CIRCLE,ELLIPSE,INSERT,TEXT,MTEXT,POINT") ;; Objects for which DXF 10 is meaningful (-4 . "<OR") ) (apply 'append (mapcar '(lambda ( x ) (list '(-4 . "<AND") '(-4 . ">=,>=,>=") (cons 10 (mapcar '- x (list fuz fuz fuz))) '(-4 . "<=,<=,<=") (cons 10 (mapcar '+ x (list fuz fuz fuz))) '(-4 . "AND>") ) ) lst ) ) '( (-4 . "OR>") ) ) ) ) Last night my near-member function came to me saying he wanted a job because he was bored ... so I gave him one... Haha! Quote Link to comment Share on other sites More sharing options...
Grrr Posted March 26, 2018 Share Posted March 26, 2018 A fuzz factor is still possible in this scenario, for example: Nice! Lee deserves a beer! Rlx just a 2c for near-member (equal works on nested lists): (defun near-member (l1 l2 tol) (vl-some (function (lambda (l3) (equal l1 l3 tol))) l2)) I'm guessing its another old function of yours. Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted March 26, 2018 Share Posted March 26, 2018 A fuzz factor is still possible in this scenario, for example: (defun ssget-by-pointlist ( lst fuz )... Thanks Lee Nice! Great Tips of the day ..If coordinates are truly reliable then you're right and a 'simple' ssget filter is adequate.gr. Rlx fuzz is the key, Lee is the unlocker Nice!Lee deserves a beer! agree Quote Link to comment Share on other sites More sharing options...
rlx Posted March 27, 2018 Share Posted March 27, 2018 well ok then... waiter , beers for everyone and 2 cents for Grrr! new project , probably thousands of loops so time to dust off the old loop-generator... gr.Rlx Quote Link to comment Share on other sites More sharing options...
DGRL Posted March 27, 2018 Author Share Posted March 27, 2018 GOT IT ALREADY https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-AutoLISP/files/GUID-7E85CB8F-B4DA-42F3-ABD3-89342A11EF9B-htm.html Thanks to all of you Though the answers raised a question What is a fuz factor? Quote Link to comment Share on other sites More sharing options...
rlx Posted March 27, 2018 Share Posted March 27, 2018 (edited) GOT IT ALREADY https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-AutoLISP/files/GUID-7E85CB8F-B4DA-42F3-ABD3-89342A11EF9B-htm.html Thanks to all of you Though the answers raised a question What is a fuz factor? fuzz or fuzzy is just another word for tolerance , just look at lisp helpfile for difference between = , eq and equal gr. Rlx Edited March 27, 2018 by rlx Quote Link to comment Share on other sites More sharing options...
rlx Posted March 27, 2018 Share Posted March 27, 2018 Nice!Lee deserves a beer! Rlx just a 2c for near-member (equal works on nested lists): (defun near-member (l1 l2 tol) (vl-some (function (lambda (l3) (equal l1 l3 tol))) l2)) I'm guessing its another old function of yours. Depends , what is old haha ... but , after I posted , I did have a little nagging voice asking me if I really needed the extra vl-every , but then the lights went out , bedtime... Anyways , I liked this function before and now I like it even more , thanks Grrr! gr. Rlx Quote Link to comment Share on other sites More sharing options...
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.