Lt Dan's legs Posted August 19, 2011 Share Posted August 19, 2011 what am I doing wrong? (setq test1 (vlax-safearray-fill (vlax-make-safearray vlax-VBobject (cons 0 0)) (list (vlax-ename->vla-object (car (entsel)))) ) ) (setq test2 (vlax-make-variant test1) ) ;;both of these will not add an item to the activeselectionset ;test1 (vla-additems (vla-get-activeselectionset *acdoc*) test1) ;test2 (vla-additems (vla-get-activeselectionset *acdoc*) test2) Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 19, 2011 Share Posted August 19, 2011 Aside from the personal challenge aspect, may I ask why go through all of the extra work? Admittedly, I am not so good when it comes to SafeArrays, Variants, and the like - That's why I love using vlax-3d-point! LoL Anyways, I ask because it seems simpler to just use SSADD, for example: (defun c:FOO () ((lambda (acDoc) (vla-startundomark acDoc) (vlax-for x (vla-get-activeselectionset acDoc) (vla-put-color x acred)) (vla-endundomark acDoc)) (vla-get-activedocument (vlax-get-acad-object))) (princ)) (defun E->SS (e ss) (ssadd e ss)) (defun c:E2SS () (sssetfirst nil (E->SS (car (entsel)) ss)) (princ)) (setq ss (ssget)) Use that last line to make an initial selection set (global var "ss" for this example), then run E2SS multiple times. Edit: FOO will just turn the items in the (current) selection set red, undo to run E2SS again, and see the changes. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 19, 2011 Share Posted August 19, 2011 This works for me: (defun c:test ( / acdoc acsel acutl obj ) (setq acdoc (vla-get-activedocument (vlax-get-acad-object)) acutl (vla-get-utility acdoc) ) (if (ssget) (progn (setq acsel (vla-get-activeselectionset acdoc)) (princ (strcat "\nSelSet Count: " (itoa (vla-get-count acsel)))) (while (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getentity (list acutl 'obj 'pnt "\nSelect Object to Add: ") ) ) ) (vla-additems acsel (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbobject '(0 . 0)) (list obj) ) ) ) (princ (strcat "\nSelSet Count: " (itoa (vla-get-count acsel)))) ) ) ) (princ) ) Note that entsel/vlax-ename->vla-object could be used, but I wanted to mix things up Quote Link to comment Share on other sites More sharing options...
Lt Dan's legs Posted August 19, 2011 Author Share Posted August 19, 2011 I happened to notice additems in the method section when (vlax-dump-object (vlax-get (vlax-get (vlax-get-acad-object) 'ActiveDocument) 'Activeselectionset) t) I just wanted to try it. It really bugs me when I can't get something to work. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 19, 2011 Share Posted August 19, 2011 (vlax-dump-object (vlax-get (vlax-get (vlax-get-acad-object) 'ActiveDocument) 'Activeselectionset) t) Great Scott! He's gone Vital LISP on us!?!? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 19, 2011 Share Posted August 19, 2011 This works for me: <snip> Note that entsel/vlax-ename->vla-object could be used, but I wanted to mix things up Cool Lee - I couldn't get it (my version) to work when I was putting one together before posting the ssadd bit. But I did notice the options and paused on vlax-vbobject. It's nice to see a working example of something you struggle with figuring out. It really helps with the learning process. Quote Link to comment Share on other sites More sharing options...
Lt Dan's legs Posted August 19, 2011 Author Share Posted August 19, 2011 vlax-dump code posted above Just having some fun Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 19, 2011 Share Posted August 19, 2011 It's nice to see a working example of something you struggle with figuring out. It really helps with the learning process. 1+ Happy to Help 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.