Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to tell if a group exists?

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
913 Views, 8 Replies

How to tell if a group exists?

I would like to be able to create a unique group name for a number of
groups.
But I don't know how to check to see if a group name already exists.

Any thoughts?

Thanks!

--
Bob Q
Pentium 4 3.33 GHz
1GB RAM
XP Pro SP2
ATI Mobility Radeon 9000 IGP graphics.....
MDT 2004DX
8 REPLIES 8
Message 2 of 9
EC-CAD
in reply to: Anonymous

A simple search for 'group names' I found this one.

;; Jeff Mishler 26 July, 2006
(defun getgroups (/ groupnames)
(vl-load-com)
(vlax-for grp (vla-get-groups
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(setq groupnames (cons (vla-get-name grp) groupnames))
)
groupnames
)

(setq groups getgroups)
(if (not (member yourgroupname groups))
.. do your thing

Bob
Message 3 of 9
_gile
in reply to: Anonymous

Hi,

Another way (replace group_name by the name of the group you're checking for):

(member (cons 3 group_name) (dictsearch (namedobjdict) "ACAD_GROUP"))


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 4 of 9
Anonymous
in reply to: Anonymous


Thanks guys!


--
Bob Q
Pentium 4 3.33 GHz
1GB RAM
XP Pro SP2
ATI
Mobility Radeon 9000 IGP graphics.....
MDT 2004DX


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi,
Another way (replace group_name by the name of the group you're
checking for): (member (cons 3 group_name) (dictsearch (namedobjdict)
"ACAD_GROUP"))
Message 5 of 9
Anonymous
in reply to: Anonymous

; Marc'Antonio Alessi, Italy - http://xoomer.alice.it/alessi
;
; Credits: Tony Tanzillo
;
; Function: ALE_GetGroupNames
;
; Version 1.05 - 14/01/2006
;
; Description:
; returns a list of all the groups names of which EntNam is member
;
; Arguments:
; EntNam: Entity name [ENAME]
;
; Example:
; (ALE_GetGroupNames (entlast))
;
(defun ALE_GetGroupNames (EntNam / EntDat VlaObj OutLst)
(if (setq EntDat (member '(102 . "{ACAD_REACTORS") (entget EntNam)))
(while
(and
(setq EntDat (cdr EntDat))
(eq (caar EntDat) 330)
(eq
(vla-get-ObjectName
(setq VlaObj (vlax-ename->vla-object (cdar EntDat)))
)
"AcDbGroup"
)
)
(if (equal (cadr EntDat) '(102 . "}")) (setq EntDat nil))
(setq OutLst (cons (vla-get-Name VlaObj) OutLst))
)
)
)


"Bob Quinn" ha scritto nel messaggio
news:6129232@discussion.autodesk.com...
I would like to be able to create a unique group name for a number of
groups.
But I don't know how to check to see if a group name already exists.

Any thoughts?

Thanks!

--
Bob Q
Pentium 4 3.33 GHz
1GB RAM
XP Pro SP2
ATI Mobility Radeon 9000 IGP graphics.....
MDT 2004DX
Message 6 of 9
Anonymous
in reply to: Anonymous

> to check to see if a group name already exists

Wrong answer, I think. Sorry.

Marco
Message 7 of 9
Anonymous
in reply to: Anonymous

Do you have to assign a specific name? You can use an asterisk when
prompted at the command line within the group command.

"Bob Quinn" wrote in message
news:6129232@discussion.autodesk.com...
I would like to be able to create a unique group name for a number of
groups.
But I don't know how to check to see if a group name already exists.

Any thoughts?

Thanks!

--
Bob Q
Pentium 4 3.33 GHz
1GB RAM
XP Pro SP2
ATI Mobility Radeon 9000 IGP graphics.....
MDT 2004DX
Message 8 of 9
paullimapa
in reply to: Anonymous

Try this sequence:

 

(setq dwgname (strcase(substr (setq dwgname (getvar "dwgname")) 1 (- (strlen dwgname) 4)))) ; get current drawing name stripping file extension
(if(member (cons 3 dwgname) (dictsearch (namedobjdict) "ACAD_GROUP"))
 (command"-Group""_Create" dwgname "_Yes" dwgname) ; group exists and will need Yes to redefine
 (command"-Group""_Create" dwgname dwgname)
)

 

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator | Layer Apps | List on Steroids | VP Zoom Scales
Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 9 of 9
stevor
in reply to: Anonymous

One idea: make the group names a series, ie:

a constant prefix, and a variable suffix.

Example: prefix of "GN-" and

sufix of "1", "2" ...etc.

The name string by

(setq gnps "GN-" gnsi 1) ; ini

(setq gns (strcat gnps (itoa gnsi )) ) ; 1 name

 Subsequent names by indexing the gnsi

(setq gnsi (1+ gnsi))

And the existance of each should be tested

before creating the 'group' object;

as shown elsewhere in this thread.

S

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost