.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Please help! - How do I create a group in .NET?

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
316 Views, 2 Replies

Please help! - How do I create a group in .NET?

I am trying to add a group of objects to a group so that they can be selected as a unit. Here is my code. After this, when I select one of the slabs that is supposed to be in this group, it shows that nothing is grouped. What am I doing wrong?



Handle GroupMiniPanel()

{

Handle groupHandle = new Handle(0);

using (Transaction trans = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())

{

Database db = HostApplicationServices.WorkingDatabase;

DBDictionary groupDictionary = (DBDictionary)trans.GetObject(db.GroupDictionaryId, OpenMode.ForWrite,false);



string curLayer = AutodeskTransactionWrapper.GetCurrentLayer();

/////////////////////////////////////////////////

string miniPanelGroupDescription = string.Format("{0}_Group", curLayer);

groupHandle = groupDictionary.SetAt(_miniPanelGroup.Description, _miniPanelGroup).Handle;

//Add all of the minipanel items to the group

_miniPanelGroup.Append(_miniPanelArea.ObjectId);

for (int ii = 0; ii < _miniItems.Count; ii++)

{

ObjectId objId = HostApplicationServices.WorkingDatabase.GetObjectId(false, _miniItems[ii], 0);

_miniPanelGroup.Append(objId);

}

trans.AddNewlyCreatedDBObject(_miniPanelGroup, false);

trans.Commit();

}

return groupHandle;

}
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Never mind. I got it

This line:

trans.AddNewlyCreatedDBObject(_miniPanelGroup, false);

should be

trans.AddNewlyCreatedDBObject(_miniPanelGroup, true);
Message 3 of 3
Anonymous
in reply to: Anonymous



See attached file

tp


style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
I
am trying to add a group of objects to a group so that they can be selected as
a unit. Here is my code. After this, when I select one of the slabs that is
supposed to be in this group, it shows that nothing is grouped. What am I
doing wrong?



Handle GroupMiniPanel()

{

Handle
groupHandle = new Handle(0);

using (Transaction trans =
HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())

{

Database
db = HostApplicationServices.WorkingDatabase;

DBDictionary
groupDictionary = (DBDictionary)trans.GetObject(db.GroupDictionaryId,
OpenMode.ForWrite,false);



string curLayer =
AutodeskTransactionWrapper.GetCurrentLayer();

/////////////////////////////////////////////////

string
miniPanelGroupDescription = string.Format("{0}_Group",
curLayer);

groupHandle =
groupDictionary.SetAt(_miniPanelGroup.Description,
_miniPanelGroup).Handle;

//Add all of the minipanel items to the
group

_miniPanelGroup.Append(_miniPanelArea.ObjectId);

for (int
ii = 0; ii < _miniItems.Count; ii++)

{

ObjectId objId =
HostApplicationServices.WorkingDatabase.GetObjectId(false, _miniItems[ii],
0);

_miniPanelGroup.Append(objId);

}

trans.AddNewlyCreatedDBObject(_miniPanelGroup,
false);

trans.Commit();

}

return
groupHandle;

}

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost