The MicroStationAPI and the DgnPlatformNet have a CreateSharedCellElement() method (as of Update 10). It creates an instance, or placement, of a shared cell element in a DGN model.
CreateSharedCellElement()
Why isn't there a C++ .NET similar method for creating instances of normal cells? Consider these existing methods:
CreateCellElement2
mdlCell_getElmDscr
Hi Jon,
Jon Summers said:The MicroStationAPI and the DgnPlatformNet have a CreateSharedCellElement() method (as of Update 10).
In documentation I see "only" CreateSharedCellElement<x>() methods, not one CreateSharedCellElement(). Are they methods you wrote about or I missed something?
CreateSharedCellElement<x>()
CreateSharedCellElement
These methods come from Interop, so I treat them as obsolete and maintained for backward compatibility (and for access from external applications ;-).
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Jon Summers said:Create Normal Cell
To create a new cell (not from cell library), I think CellHeaderElement class can be used.
Jan Šlegr said:To create a new cell (not from cell library), I think CellHeaderElement class can be used
I asked the question because, not for the first time, someone has asked how to create a new normal cell instance using .NET. That is, how do we place a cell instance by copying the cell from a cell library? Currently, the poster is attempting to reinvent the wheel for lack of a straightforward create-instance-of-normal-cell-from-library method.
Regards, Jon Summers LA Solutions
Jon Summers said:the poster is attempting to reinvent the wheel for lack of a straightforward create-instance-of-normal-cell method.
I am feeling I do not quite understand this sentence probably, because what is the straighforward create cell method? Can you explain it better what does it mean e.g. for you?
To prepare the cell content as IList<> collection and to create the cell instance using CellHeaderElement constructor seems "straightforward enough" for me.
Jan Šlegr said:what is the straighforward create cell method?
VBA: CreateCellElement2
MicroStationAPI: mdlCell_getElmDscr
Jon Summers said:VBA: CreateCellElement2
Well, so you don't want to create the cell, but to load existing cell from cell library. I do not want to be a stickler, but tt something different than what your original question was about.
As far as I know Bentley.Interop.MicroStationDGN.CreateCellElement2() method is still the recommended way and it's equal to CreateSharedCellElement2()method you mentioned in your original question. The problem of both methods is they return Interop Element type that cannot be used directly in new NET API.
Bentley.Interop.MicroStationDGN.CreateCellElement2()
CreateSharedCellElement2()
Jan Šlegr said:It's something different than what your original question was about
I take your point: I've amended the thread headline.
Hi Jon Summers,
DgnPlatform provides a CreateCellElement method (signature below) that can be used to create a normal cell.
static DGNPLATFORM_EXPORT void CreateCellElement ( EditElementHandleR eeh, WCharCP cellName, DPoint3dCR origin, RotMatrixCR rMatrix, bool is3d, DgnModelRefR modelRef )
There are two (parametric) cell creation examples located in the Contraints\constraint2ddemo example here:
Constraints\constraint2ddemo\constraint2ddemo.cpp:1082:static void exampleFunctionalCell () Constraints\constraint2ddemo\constraint2ddemo.cpp:1158:static void exampleFunctionalCellFromDgn ()
I will see if we can provide a code snip for creating a simple cell element around this and post here.
HTH,Bob
UPDATE: I see your mention to be able to place existing from Cell library as normal. I will look into that aspect more. For now, the approach used (not ideal) in CellExplorer is to set the active parameter Cell Name, then execute the place cell command. This should be consistent w/product behavior and using native code, though not the public API code desired, nor a simple call (yet) I can provide.
FILE: Elements\CellExplorer\cellexp.cpp:896: ActiveParams::SetValue (pWString, ACTIVEPARAM_CELLNAME); SNIP: ... ActiveParams::SetValue (pWString, ACTIVEPARAM_CELLNAME); ... mdlDialog_cmdNumberQueue (false,CMD_PLACE_CELL_ICON,L"",MSInputQueuePos::INPUTQ_EOQ);
Robert Hook said:DgnPlatform provides a CreateCellElement method
Yes, but that's not copying the cell from a cell library. It creates a cell header element (type CELL_HEADER_ELM) to which one may add graphic components.
Hi Bob,
Robert Hook said:I will look into that aspect more.
it would be nice. More complex case I can imagine (not based on any current needs) is to be able to load a cell from cell library, but not to place it immediately (so your update cannot be used), to use in-memory cell element in own dynamics and when it's placed, to attach custom data (XAttributes, EC data etc.) in one transaction, so Undo will work as expected.
With regards,