My C# application needs to create both cells from a cell library and other elements (cones, boxes, etc.) I am currently creating the cells using Interop and the other items using Bentley.GeometryNet and Bentley.DgnPlatformNET.
After creation in memory all of these items need to be manipulated/transformed as a group with every mouse move so I would prefer to not use Interop to create the cells. Can this be done? I looked at the documentation for CellHeaderElement but I don't see a create method that utilizes a cell library. I also didn't find any examples that used CellHeaderElement in the MicroStationCONNECTSDK
As Jan mentioned, it is not very easy to plot a cell using strictly the DgnPlatformNET.Here is how I am placing basic cells.. Perhaps this could be expanded upon to have better support for things like parametrics.It is not perfect, but it works for the majority of cases that I need.
if (cellInfo == null || cellInfo.Model == null) { Debug.Print("Cell Info does not contain a model. Returning null"); return null; } // Iterate over every element of the cells model and recreate it in our active model. IEnumerator<Element> elements = cellInfo.Model.GetElements().GetEnumerator(); // Calculate the conversion factor from the cell model to the active model. ModelInfo cellModelInfo = cellInfo.Model.GetModelInfo(); UnitDefinition cellMasterUnits = cellModelInfo.GetMasterUnit(); ModelInfo activeModelInfo = Ms.GetActiveModel().GetModelInfo(); UnitDefinition activeMasterUnits = activeModelInfo.GetMasterUnit(); activeMasterUnits.GetConversionFactorFrom(out double scale, cellMasterUnits); // Unitless whole cells need to be scaled for some reason... if (cellMasterUnits.IsStandardUnit == StandardUnit.UnitlessWhole) { double cellToMasterScale = cellModelInfo.UorPerMaster / activeModelInfo.UorPerMaster; scale *= cellToMasterScale; } // Scale the element to the model units. DTransform3d trns = new DTransform3d(scale, 0, 0, position.X, 0, scale, 0, position.Y, 0, 0, scale, position.Z); TransformInfo tInfo = new TransformInfo(trns); List<Element> cellChildren = new List<Element>(); while (elements.MoveNext()) { Element ele = elements.Current; if (ele == null) continue; // If we include these elements, microstation crashes. :( I think it is just the DgnApplicationData (Meta data attached to DGN) if (ele.ElementType == MSElementType.MicroStation || ele.ElementType == MSElementType.Table || ele.ElementType == MSElementType.TableEntry || ele.ElementType == MSElementType.ReferenceAttachment || ele.ElementType == MSElementType.DgnStoreHeader || ele.IsInvisible) //ele.ElementType == MSElementType.ReferenceAttachment continue; // These elements also cause a crash... ignore them. if (ele is ExtendedNonGraphicsElement ) continue; Element newEle = ele.Clone(); newEle.FromUor(cellInfo.Model); newEle.ApplyTransform(tInfo); newEle.ToUor(); cellChildren.Add(newEle); } elements.Dispose(); DPoint3d origin = position.ToUor(); CellHeaderElement cellElement = new CellHeaderElement(_model, cellInfo.Name, origin, DMatrix3d.Identity, cellChildren); if (ViewIndependent) elem.IsPointCell = true; trns = DTransform3d.FromUniformScaleAndFixedPoint(origin, userScale); tInfo = new TransformInfo(trns); cellElement?.ApplyTransform(tInfo); return cellElement;
Maury said:Here is how I am placing basic cells
I take my hat off to your diligence! But this is why the API exists and why it should provide a CreateCellInstance(string cellName, DgnFile cellLibrary) method.
CreateCellInstance(string cellName, DgnFile cellLibrary)
Jan Ĺ legr said: It has been asked and discussed several times, but as far as I remember, without clear vision or promise from Bentley.
Nor an explanation of why such a basic yet fundamental method is absent.
Regards, Jon Summers LA Solutions
Jon Summers said:Nor an explanation of why such a basic yet fundamental method is absent.
Robert Hook ?
Maury said:Robert Hook ?
I guess somebody from Sunand Sandurkar's team would be better contact, because I guess it's power platform functionality. But ... any info from anybody will be welcomed :-)
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
FYI. Mayuresh Kanade created Enhancement 1095519 to address this request.
Has any work been done on creating this functionality yet? I'm currently on CE 10.17 and still can't find a
I just check and Enhancement 1095519 is not being working on. but from my inquiry they are looking at potentially scheduling this work. Hopefully we can get some movement on this.