Hi,
I would like to delete/modify cell subelement.
This is my code so far.
CellHeaderElement cell = (CellHeaderElement)element.ParentElement; CellQuery oCellQuery = cell.AsCellQuery(); bool res1 = oCellQuery.IsEffectivelyLocked(true,true); bool result= oCellQuery.ExposeChildren(ExposeChildrenReason.Edit); ChildElementCollection oComponents = oCellQuery.GetChildren (); Element child = oComponents.ElementAt(0); bool res2=child.IsValid; ???????????????????????????????? How to remove child from cell? oCellQuery.ReplaceInModel (cell);
thanks
Nenad
Unknown said:I would like to delete/modify cell subelement
You could take this approach...
A benefit of this approach is that the transaction is easily undoable.
Regards, Jon Summers LA Solutions
Hi Jon,
I tried your approach and it works.
However, it seems to me that has to be a better way to do this.
It look little bit unpractical, being forced to use Bentley.Interop.MicroStationDGN .
Is there another way to drop a cell without using Bentley.Interop.MicroStationDGN ?
I have searched and only place I found "Drop" is in ElementAgenda but I think I am on wrong track here.
any ideas?
best regards
Unknown said: It seems to me that has to be a better way to do this. It look little bit unpractical, being forced to use Bentley.Interop.MicroStationDGN
It seems to me that has to be a better way to do this. It look little bit unpractical, being forced to use Bentley.Interop.MicroStationDGN
If it works, then it can't be unpractical! The idiom (duplicate-modify-replace) works well with MicroStation's undo/redo mechanism because it's a reversible transaction.
It might appear inelegant to use the InterOp API, but practicality trumps elegance! But I salute your appreciation of aesthetics when writing code.
Unknown said:I found "Drop" is in ElementAgenda
An ElementAgenda is a collection of unrelated elements. It doesn't represent a cell's contents. For example, you would obtain an ElementAgenda in a primitive command that processes a fence, selection set or that lets a user pick two or more elements.
You are right, it works and that is most important.
But, I am trying to learn something new, in this case NET API and how to manipulate sub-elements.
It is no problem to obtain ( example cell) sub-elements info as collection.
CellQuery and ChildElementCollection works fine.
However, any attempt to , for example, copy sub-element ( I tried using ElementCopyContext ) fails.
Some function or class that enables manipulation of sub-element must exist in NET API, don't you think so?
Also, you should be able to copy the sub element like so (I currently use this to copy sub elements from a cell that has not been plotted yet) :
Element newElement; using (ElementCopyContext copyContext = new ElementCopyContext(Ms.GetActiveModel())) { copyContext.WriteElements = false; copyContext.DisableAnnotationScaling = true; newElement = copyContext.DoCopy(elementToCopy); } return newElement;
Unknown said:Creating a cell element is a bit confusing
It's gradually becoming easier. From DgnPlatformNet for Update 4 (this may be in earlier versions)...
CellHeaderElement cell = new CellHeaderElement(DgnModel, String, DPoint3d, DMatrix3d, IList<(Of <<'(Element>)>>));
Create a new named CELL_HEADER_ELM with supplied origin and rotation. After creating the cell header the application should use AddChildElement to add child elements to the cell, and AddChildComplete once all children have been added to finish the cell creation.
Unknown said:The confusing areas are when dealing with the cell library
We now have MstnPlatformNet.CreateCellElement2 and MstnPlatformNet.CreateCellElement3. They strongly resemble the VBA methods available via an InterOp — but now you don't need the InterOp.
Unknown said:but now you don't need the InterOp.
Don't want to steal the discussio, but this is not correct. The mentioned CreateCellElement methods still come from Interop in the same way as in V8i:
But in my opinion it's not big issue: I'd like to leave Interop outside new code, but it's better to have it documented as a part of MstnPlatformNet API than to have nothing ;-)
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point