.NET

Reply
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 1 of 4 (248 Views)

Groups

248 Views, 3 Replies
06-03-2005 12:18 PM
Anybody got a few lines of code to create a group and add entities to it?

Thanks
*Albert Szilvasy
Message 2 of 4 (248 Views)

Re: Groups

06-06-2005 09:41 AM in reply to: Mikko
Here you go:

public class GroupCreator
{
[CommandMethod("mygroup")]
public void DoIt()
{
Editor ed =
Application.DocumentManager.MdiActiveDocument.Editor;
PromptSelectionResult res = ed.GetSelection();
if (res.Status != PromptStatus.OK)
return;
Database db =
Application.DocumentManager.MdiActiveDocument.Database;
using (Transaction t = db.TransactionManager.StartTransaction())
{
DBDictionary groupDict =
(DBDictionary)t.GetObject(db.GroupDictionaryId,OpenMode.ForWrite);
//create group
using (Group gr = new Group("This is Mikko's example
group",true))
{
groupDict.SetAt("Mikko",gr);
t.AddNewlyCreatedDBObject(gr,true);
ObjectId[] ids = res.Value.GetObjectIds();
for (int i=0;i gr.Append(ids);
}
t.Commit();
}
}
}
wrote in message news:4865255@discussion.autodesk.com...
Anybody got a few lines of code to create a group and add entities to it?

Thanks
Valued Contributor
sivashanmugam
Posts: 58
Registered: ‎03-05-2006
Message 3 of 4 (248 Views)

Re: Groups

03-22-2006 06:27 AM in reply to: Mikko
Thanks a lot I will try it.
Contributor
sbenedetti
Posts: 14
Registered: ‎01-10-2006
Message 4 of 4 (248 Views)

Re: Groups

03-24-2006 01:49 AM in reply to: Mikko
Given a group is it possible to get all entities in that group via the GetAllEntityIds method of the Group object.

Is it possible the reverse? Given an entity is it possible to know in which group it belongs to?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.