I am trying to Place a cell which is defined in a cell library.
In V8i this was easily accomplished, assuming the cell is in an attached cell library.
cell = _ComApp.CreateCellElement3(cellName, ref origin, true);
cell.ScaleUniform(ref origin, scaleFactor);
cell.RotateAboutZ(ref origin, rotation));
Using the CONNECT Api this seems to be less obvious.
I *believe* that I need to create a CellHeaderElement using the following:
CellHeaderElement cell = new CellHeaderElement(activeDgnModel, cellName, origin, DMatrix3d.Zero, cellElements);
The process seems to be that you create the Header and then add child elements to the cellElements parameter above.
My problem is, where to get these elements from. The obvious answer is from the library, and this is where I have ground to a halt.
Here is where I have got to so far…
public static void PlaceCellKeyin(string cellName) {
CellLibraryCollection cellLibraryCollection = new CellLibraryCollection(CellLibraryOptions.DefaultAll);
foreach(CellLibraryInfo cellLibraryInfo in cellLibraryCollection) {
if(cellLibraryInfo.Name == cellName) {
ModelIndexCollection modelIndexCollection = cellLibraryInfo.File.GetModelIndexCollection();
foreach (ModelIndex modelIndex in modelIndexCollection)
if (modelIndex.CellPlacementOptions == CellPlacementOptions.CanBePlacedAsCell && modelIndex.Name == cellName) {
//Now what?
}
}
}
The Cell Library file appears as a Dgn with a Model for each cell. I can iterate through the models using the ModelIndexCollection. What I cannot do is get at the cell model's graphics.
I am sure there must be a more straightforward way to do this. Please help.