Hi All,
If at the time of placement a cell is flagged as "can be used as annotation" then that cell is placed as an "Annotation Cell". If subsequently the "can be used as annotation" flag is removed in the cell library, the cell continues to behave as an "Annotation Cell".
Is it possible to convert cells to "Annotation Cells" that exist in a particular dgn but have no corresponding entry in a cell library (and hence can't be flagged as "can be used as annotation")?
The best I can come up with at the moment is writing the cell out to a temporarily cell library, flagging "can be placed as annotation", replacing the original cell with the cell in the temporary library then removing the library. Is there a more elegant solution than this?
BTW, I am using the MDL and MicroStationAPI SDK's (C++).
Thanks
Liam
Unknown said:Is it possible to convert cells to "Annotation Cells" that exist in a particular dgn but have no corresponding entry in a cell library
A cell is a model. Add a model to the DGN file you're working on. Make that model a cell. Now you have a DGN file that has its own, rather small, cell library.
Regards, Jon Summers LA Solutions
Answer Verified By: wilks
Thanks Jon. I'll try that approach and let you know how I go.
Your solution works great!
I copy a model from a seed file, set the appropriate flags, place the cell, then remove the model.
Thanks again.
Wilks,
there is a isAnnotation flag in the cell_2d and cell_3d member of the MSElementUnion. In your special case it migth be worth trying to set this, rather than moving a bunch of data, including model creation and destruction for each of such a cell. At least as long as you don't want to make any other change or have additional influences (like a changed annotation scale)
Michael
Hi Michael,
I did try setting that flag. However, it appears that the flag needs to be set at the time of placement (rather than after the cell has already been placed). Otherwise, the cell is recognized as a normal cell rather than an annotation cell.
Once the cell is recognized as an annotation cell, I can then enable annotation on that cell.
Unknown said:it appears that the flag needs to be set at the time of placement
I have not used annotation cells for my own purposes, only remembered that there are a number of flags, which might be of help - or even not, if this is the case. Anyway, thanks for your feedback, this will be helpfull for later searche(r)s.
I logged this issue with Bentley, and their response is below:
It’s possible to convert existing ordinary cells in drawing into annotation cells by setting flags.isAnnotation property to TRUE in cell element.Please take a look at sample code below. It uses functions both from MDL and MicroStationAPI, so both includes are needed.
int cell_Callback (MSElementDescrP pElD, void *callbackArg, ScanCriteriaP scP)
{ //Does not work with shared cells if (CELL_HEADER_ELM == pElD->el.ehdr.type) { double const annotScale = 1.0; Bentley::Ustn::Element::XAttributeHandlerId annotScaleXAttr (XATTRIBUTEID_AnnotationScale, 0); Bentley::Ustn::Element::EditElemHandle elHnd (pElD, false, false); if (pElD->el.hdr.dhdr.props.b.is3d) { Cell_3d *cell = (Cell_3d *) &(pElD->el); cell->flags.isAnnotation = TRUE; elHnd.ScheduleWriteXAttribute(annotScaleXAttr, 0, sizeof(double), &annotScale); } else { Cell_2d *cell = (Cell_2d *) &(pElD->el); cell->flags.isAnnotation = TRUE; elHnd.ScheduleWriteXAttribute(annotScaleXAttr, 0, sizeof(double), &annotScale); } mdlElmdscr_rewrite(pElD, NULL, mdlElmdscr_getFilePos(pElD)); mdlElmdscr_freeAll(&pElD); }
return SUCCESS;}
Private void convertCells2Annotation(char *arg){ //Select all cells in current model ScanCriteriaP scan = mdlScanCriteria_create(); mdlScanCriteria_addSingleElementTypeTest (scan, CELL_HEADER_ELM); mdlScanCriteria_setModel(scan, ACTIVEMODEL); mdlScanCriteria_setElmDscrCallback(scan, cell_Callback, NULL); mdlScanCriteria_setReturnType (scan, MSSCANCRIT_ITERATE_ELMDSCR, FALSE,FALSE); mdlScanCriteria_scan(scan, NULL, NULL, NULL); mdlScanCriteria_free(scan);}
I noticed that converted cells start to react to annotation scale change only after drawing is reopened. Let me know if you have any further questions
Regards, Linas Burneika Technical Support Group Bentley Systems, Incorporated
I can verify that this approach works well. The only downside is that I have to reload the file at the end, thus loosing the ability to undo.
ThanksLiam