satishrajdev Posted March 29, 2015 Posted March 29, 2015 Hi all, Stuck with a problem I have a situation, I made a selection set A (Setq A (ssget)) and worked with it according to my need. then created 2nd selection set (setq B (sssget)) Now I want to make selection set A active to get (setq C (vla-get-activeselectionset ********)) how can i do this waiting for your reply Quote
pBe Posted March 29, 2015 Posted March 29, 2015 Why dont you just change the sequence? And why not use the repeat/ssname approach, why the need for vla-get-activeselectionset ? What is the main purpose of the routine? Quote
wkplan Posted March 29, 2015 Posted March 29, 2015 E.g. (setq A (ssget)) (setq C (vla-get-activeselectionset ********)) then do your work with "A" if that's done, create (setq B (sssget)) after this, you can work with "C" HTH Wolfgang edit: 2 minutes too late, pbE was quicker:lol: Quote
Tharwat Posted March 29, 2015 Posted March 29, 2015 Work on the filter of the ssget function , then you may not need for two selection sets . 1 Quote
pBe Posted March 29, 2015 Posted March 29, 2015 Work on the filter of the ssget function , then you may not need for two selection sets . Exactly! Hence my question of What is the main purpose of the routine? Quote
satishrajdev Posted March 29, 2015 Author Posted March 29, 2015 I want to create W block using Vla-Wblock that's why I need active selection set.... Quote
Lee Mac Posted March 29, 2015 Posted March 29, 2015 I want to create W block using Vla-Wblock that's why I need active selection set.... Here is an example demonstrating how to 'convert' the selection set returned by ssget to an ActiveX selection set as required by the wblock method: (defun c:mywb ( / doc idx lst sel ssc vsl ) (if (setq sel (ssget)) (progn (repeat (setq idx (sslength sel)) (setq lst (cons (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))) lst)) ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) ssc (vla-get-selectionsets doc) vsl (vla-add ssc (uniqueitem ssc "mywb")) ) (vla-additems vsl (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbobject (cons 0 (1- (length lst)))) lst ) ) ) (vla-wblock doc (vl-filename-mktemp (vl-filename-base (getvar 'dwgname)) (getvar 'dwgprefix) ".dwg" ) vsl ) (vla-delete vsl) ) ) (princ) ) (defun uniqueitem ( col key / int rtn ) (setq int 0) (while (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list col (setq rtn (strcat key (itoa (setq int (1+ int)))))) ) ) ) ) rtn ) (vl-load-com) (princ) Alternatively, you can populate the ActiveX Selection Set directly using the select method of a Selection Set object. Quote
satishrajdev Posted March 30, 2015 Author Posted March 30, 2015 Thank you genius:thumbsup: Understood it and solved my problem appropriately Quote
SPORTE0000 Posted November 21, 2023 Posted November 21, 2023 So I took the code example a step further. If anyone is willing to proof out any overkill that would be appreciated. ;;----------------------------------------------------------------------;; ;;C:ASR ;; Description: Select a group of objects and Wblock them. Use a file name based on the first objects layer ;; (defun C:ASR ( ;; cpy / *error* acapp acdoc acdocs acdocmodelspace ssc vsl _POPUP _EDITBOX _VL-Uniqueitem _MakeBlock ssetObj ssblk xent lst idx A1 Obj tmpfilznamz objsInModelSpace tempvarClearToProceed ) ;;-------FUNCTION SUPPORT GROUP-----------------------------------------;; (defun *error* ( msg ) (if RegExp (vlax-release-object RegExp)) (mapcar '_ReleaseObject (list acapp acdoc ssc vsl acdocs acdocmodelspace)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) ;;-------STANDART FUNCTION GROUP----------------------------------------;; (defun _Popup ( title flags msg / wsh res ) (vl-catch-all-apply (function (lambda nil (setq wsh (vlax-create-object "WScript.Shell")) (setq res (vlax-invoke-method wsh 'popup msg 0 title flags)) ) ) ) (if wsh (vlax-release-object wsh)) res );end defun (defun _EDITBOX ( str / han ) (IF (= str NIL) (SETQ str "")) (and (< 0 (setq han (load_dialog "acad"))) (new_dialog "acad_txtedit" han) (set_tile "text_edit" str) (action_tile "text_edit" "(setq str $value)") (if (zerop (start_dialog)) (setq str nil)) ) (if (< 0 han) (unload_dialog han)) str );end defun (defun _VL-Uniqueitem ( col key / int rtn ) (setq int 0) (while (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list col (setq rtn (strcat key (itoa (setq int (1+ int)))))) ) ) ) ) rtn );end defun (defun _ReleaseObject ( obj ) (and obj (eq 'VLA-OBJECT (type obj)) (not (vlax-object-released-p obj)) (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-release-object (list obj)) ) ) ) );end defun ;;-------STANDART GLOBAL VARIABLES--------------------------------------;; (vl-load-com) (setq acapp (vlax-get-acad-object) acdoc (vla-get-activedocument acapp) acdocs (vla-get-Documents acapp) acdocmodelspace (vla-get-ModelSpace acdoc)) ;;----------------------------------------------------------------------;; ;; Move all isolated objects to an external drawing using the wblock method (if (and (setq tempvarClearToProceed 2) (setq ssblk (ssget)) (setq a1 (cdr (assoc 8 (entget (setq xent (ssname ssblk 0)))))) ; layer color name to be base of wblock name ) (progn (if (= nil (findfile (setq tmpfilznamz (strcat (getvar "dwgprefix") (_EDITBOX a1 ) ".dwg")))) (progn (print "MSG: ASR-AEWBLOCKMAKE-NAMEDBY-LAYER || File name Unique") (print tmpfilznamz) (setq tempvarClearToProceed 1) );end progn (progn (print "MSG: ASR-AEWBLOCKMAKE-NAMEDBY-LAYER || File name Not Unique - User Correction Required") (print tmpfilznamz) );end progn );end if (if (= 1 tempvarClearToProceed) (progn (repeat (setq idx (sslength ssblk)) (setq lst (cons (vlax-ename->vla-object (ssname ssblk (setq idx (1- idx)))) lst)) ) (setq ;acdoc (vla-get-activedocument (vlax-get-acad-object)) ssc (vla-get-selectionsets acdoc) vsl (vla-add ssc (_VL-Uniqueitem ssc "mywb")) ) (vla-additems vsl (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbobject (cons 0 (1- (length lst)))) lst ) ) ) (vla-wblock acdoc tmpfilznamz vsl) (if (and (= 6 (_Popup "Object Interface:" "Would you like to Delete the Objects Previously Selected? " (+ 4 48 4096))) (> (vla-get-count vsl) 0) );end and (vlax-for Obj vsl (VLA-DELETE Obj) ) );end if delete objects from the file (vla-delete vsl) );end progn );end if );end progn );end if ;;-------END FUNCTION SUBROUTINES---------------------------------------;; (vla-Regen (vla-get-activedocument (vlax-get-acad-object)) acAllViewports) (mapcar '_ReleaseObject (list acapp acdoc ssc vsl acdocs acdocmodelspace )) ;;----------------------------------------------------------------------;; ) ;;----------------------------------------------------------------------;; 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.