Jump to content

Additems to activeselectionset


Lt Dan's legs

Recommended Posts

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :playing:

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

(vlax-dump-object (vlax-get (vlax-get (vlax-get-acad-object) 'ActiveDocument) 'Activeselectionset) t)

 

Great Scott! He's gone Vital LISP on us!?!? :o:P

Link to comment
Share on other sites

This works for me:

 

<snip>

 

Note that entsel/vlax-ename->vla-object could be used, but I wanted to mix things up :playing:

 

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. :beer:

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...