BlacK_SmokE Posted March 28, 2018 Author Share Posted March 28, 2018 ron, i don't know why, but it gives error sometimes when i select a rectangle (even when not in a blocked layer) and it only prompts me to select one rectangle, but doesn't let me make another selection to count how many rectangles, equal to the one i previously selected, are in the slection set Quote Link to comment Share on other sites More sharing options...
ronjonp Posted March 28, 2018 Share Posted March 28, 2018 ... and it only prompts me to select one rectangle, but doesn't let me make another selection to count how many rectangles, equal to the one i previously selected, are in the slection set Not sure I understand this statement. The code worked in the sample drawing you posted. Quote Link to comment Share on other sites More sharing options...
BlacK_SmokE Posted March 28, 2018 Author Share Posted March 28, 2018 i think that i'm the one who's not understanding your code then =( i meant i need to select the rectangle and then make another selection to count how many equal rectangles are there but your code only prompts me to select a rectangle and doesn't return me anything (which variable u assigned to give me a value?) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted March 28, 2018 Share Posted March 28, 2018 Try replacing: (sssetfirst nil n) with: (if (= 0 (sslength n)) (alert "Nothing in selection!") (progn (sssetfirst nil n) (alert (strcat (itoa (sslength n)) " objects in selection!"))) ) Quote Link to comment Share on other sites More sharing options...
BlacK_SmokE Posted March 28, 2018 Author Share Posted March 28, 2018 thanks ron, now i'm understanding a little better what your code does the variable n retrieves me the amount of objects but your code is finding the rectangle in the whole drawing, i want to find the rectangle inside another selection set, is that possible? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted March 28, 2018 Share Posted March 28, 2018 Try this: (defun c:foo (/ r o n s) (cond ((and (setq o (car (nentsel "\nPick your little rectangle: "))) (setq o (vlax-ename->vla-object o)) (vlax-property-available-p o 'area) (setq r (vla-get-area o)) (setq s (ssget '((0 . "*polyline")))) (setq n (ssadd)) ) (foreach b (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))) (cond ((and (vlax-property-available-p b 'area) (equal (vla-get-area b) r 1e-2)) (ssadd (vlax-vla-object->ename b) n) (vl-catch-all-apply 'vla-put-color (list b 1)) ) ) ) (if (= 0 (sslength n)) (alert "Nothing in selection!") (progn (sssetfirst nil n) (alert (strcat (itoa (sslength n)) " objects in selection!"))) ) ) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
BlacK_SmokE Posted March 28, 2018 Author Share Posted March 28, 2018 excellent ron! we're almost reaching a perfect resolution for my problem your code is working smoothly But just so u can understand better what i need, this part of your code is not needed: (if (= 0 (sslength n)) (alert "Nothing in selection!") (progn (sssetfirst nil n) (alert (strcat (itoa (sslength n)) " objects in selection!"))) ) what i need is the value that the variable n is returning to me in your code! but that's okay, i can remove this last part Now, the last big deal: i see that your using the 'area' property to find the same rectangles... so is there a way to add some other property to refine that filter a bit, like rectangles with the same area AND same length? or same maybe, same area AND same position in X or same position in Y? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted March 28, 2018 Share Posted March 28, 2018 Sorry .. this is the extent I'm willing to do for free. If you want to try and make changes , I'll help when I can ... but I have real work to do now. Quote Link to comment Share on other sites More sharing options...
BlacK_SmokE Posted March 28, 2018 Author Share Posted March 28, 2018 ok ron, i understand, but thank you so much for your patience and contribution on the code, u have helped a lot sorry if i bothered you 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.