My code now looks like this:
string cellName = "BRND"; bool sharedCellDefPresent = false; SharedCellDefinitionCollection cellDefColl = Session.Instance.GetActiveDgnFile().GetNamedSharedCellDefinitions(); foreach (SharedCellDefinitionElement cellDefElmTemp in cellDefColl) { lifalib_dmsg("1: " + cellDefElmTemp.CellName); if (cellDefElmTemp.CellName == cellName) sharedCellDefPresent = true; } if (!sharedCellDefPresent) { SharedCellDefinitionElement cellDefElm = new SharedCellDefinitionElement(Session.Instance.GetActiveDgnModel(), cellName); cellDefElm.AddToModel(); } else lifalib_dmsg("SharedCellDefinition present"); cellDefColl = Session.Instance.GetActiveDgnFile().GetNamedSharedCellDefinitions(); foreach (SharedCellDefinitionElement cellDefElmTemp in cellDefColl) lifalib_dmsg("2: " + cellDefElmTemp.CellName); DPoint3d origin = new DPoint3d(100000.0, 100000.0); DPoint3d scale = new DPoint3d(10.0, 10.0, 10.0); SharedCellElement cellElm = new SharedCellElement(Session.Instance.GetActiveDgnModel(), null, cellName, origin, DMatrix3d.Identity, scale); DRange3d range; StatusInt rc1 = cellElm.CalcElementRange(out range); StatusInt rc = cellElm.AddToModel();
The function lifalib_dmsg just displays a message into the messages dialogbox...
I hope that you or someone else can give me a hint...
Regards, Evan