The MicroStationAPI and the DgnPlatformNet have a CreateSharedCellElement() method (as of Update 10).
Why isn't there a C++ .NET similar method for normal cells? Consider these existing methods:
Jon Summers said:Create Normal Cell
To create a new cell (not from cell library), I think CellHeaderElement class can be used.
Labyrinth 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 Summers,
DgnPlatform provides a CreateCellElement method (signature below) that can be used to create a normal cell.
static DGNPLATFORM_EXPORT void CreateCellElement ( EditElementHandleR eeh,
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.
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);
ActiveParams::SetValue (pWString, ACTIVEPARAM_CELLNAME);
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.
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.
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.
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.