.NET

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

Groups

233 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 (233 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 (233 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 (233 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?

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community