Selectable/Unselectable Group

Selectable/Unselectable Group

hericson
Advocate Advocate
618 Views
3 Replies
Message 1 of 4

Selectable/Unselectable Group

hericson
Advocate
Advocate
Then using AutoCAD you can switch a group selectable/unselectable in the Object grouping dialog. But how to accomplish the same thing using VBA? Any ideas? I can't found it in the Group object properties.
0 Likes
619 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
I was only able to do such a thing using AutoLISP code:




;;; Quickly makes non-selectable groups selectable again



(defun C:REGROUP ()

(setq grpdic (dictsearch (namedobjdict) "ACAD_GROUP") ; group dictionary

gdenam (cdar grpdic) ; g d entity name

grpnam (assoc 3 grpdic) ; group name

);setq

(if grpnam ; group found

(while grpnam ; loop thru all groups

(prompt (strcat "Group \"" (cdr grpnam) "\""))

(setq grplst (dictsearch gdenam (cdr grpnam))) ; group data

(if (= (cdr (assoc 71 grplst)) 1) ; selectability flag

(prompt " is selectable.\n")

(progn

(prompt " is not selectable. Correcting...")

(setq grplst (subst (cons 71 1) (cons 71 0) grplst))

(if (not (null (entmod grplst))) ; modify group

(prompt "done.\n")

(alert "ERROR!")

);if

);progn

);if

(setq grpdic (cddr (member grpnam grpdic))) ; next loop or group

(setq grpnam (assoc 3 grpdic))

);while

(prompt "No groups found.\n")

);if

(princ)

)

0 Likes
Message 3 of 4

hericson
Advocate
Advocate
Thank you very much, your code worked and can be useful but at the moment I want to use VBA because my whole project is written in VBA. If I use LISP code to make a group, how to pass a group name from VBA as a parameter?

As an option I can use SendCommand like this:

ThisDrawing.SendCommand "-group" & vbCr & "selectable" & vbCr & "test_group" & vbCr & "yes" & vbCr

But this way I can't determine if the group is selectable or not.
0 Likes
Message 4 of 4

Anonymous
Not applicable
With the LISP file loaded, you can run REGROUP as a command (use SendCommand from VBA).

Or, the LISP code could be modified to accept a parameter or two:
(defun C:REGROUP (YourParameter)
then called from SendCommand as "(C:REGROUP YourParameter)" etc.

But, like you say, it'll be somewhat difficult to pass data back and forth between VBA and AutoLISP. The only way I know of to do that is the VLAX Class for VBA. I remember it tended to crash if it was run too often. Also, I'm not even sure where you can find it anymore.

One last gasp might be to utilize the USERxxx System Variables to pass data between VBA and AutoLISP.

Does anybody else have any ideas?
0 Likes