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
Jon Summers said:Create Normal Cell
To create a new cell (not from cell library), I think CellHeaderElement class can be used.
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
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
Hi Jon,
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.
Regards,
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,
Jan Ĺ legr said:when it's placed, to attach custom data (XAttributes, EC data etc.) in one transaction, so Undo will work as expected
That's a very good reason for wanting a built-in function (for all languages) to place a cell instance from the library.
The function call may hide a lot of activity under the water. For example, mdlCell_getElmDscr() not only reads a cell from a library, but also gets a set of tag definitions (if they exist). The programmer can attach those tag defs. as tag elements to the new cell instance, which is what MicroStation does.
mdlCell_getElmDscr()
We would like that new method to behave similarly, particularly with respect to Item Type instances attached to the cell model in the cell library. When the cell instance is created, the Item Types should be copied from the library and attached with element scope rather than model scope. See this idea.
i know this post is old but i wanted to note that if you attach any item types to your cell or (elements in your cell) and have text fields to display the values of properties in that attached item type in your cel lib and then try to use CreateCellElement2 and add it to your model the cell will be placed but all the text fields that link to an item property are broken.
the only way i was able to get placing a cell from library to work was with key ins. this has been a pretty frustrating process to figure out how to simply place a cell from a cell library.
John Drsek said: i wanted to note that if you attach any item types to your cell or (elements in your cell) and have text fields to display the values of properties in that attached item type in your cel lib and then try to use CreateCellElement2 and add it to your model the cell will be placed but all the text fields that link to an item property are broken
Bentley Systems tell us that Tags are obsolete because Item Types are better. However, you've observed one area where Item Types cannot be used successfully as a replacement for Tags.
Please vote for this idea, whose implementation would go towards solving that problem.
Robert Hook said:I see your mention to be able to place existing from Cell library as normal. I will look into that aspect more. For now
Bump!
Robert Hook
Its the later part of 2022 now and I still dont see a function to place a cell from cell library. is this ever going to be added? the question keeps coming up over and over, the demand seems pretty high for this