Can we have more information about ConsensusConnectionEdit class which is I believe the backbone of creating any civil object in ORD
I have a few questions about this class.
Thank you,
Richard
Hi Richard,
my personal (so subjective) experience with own code and what I see in SDK examples:
Richard Stima said:Is it safe to use multiple ConsensusConnectionEdit instances in more complex code or it is recommended to use one instance and pass it as parameter into another methods?
In my opinion ConsensusConnection is Disposable (so should be short-living) bridge between data model in DGN and GeometricModel class.
I always create it only when required, usually because I need to access GeometricModel content, and close and dispose it asap. When a user tool is implemented, OnPostInstall is the place where the connection is opened and OnExitTool the place where to close / dispose it.
Richard Stima said:There is no Commit() method therefore at what point in code the new civil element is added into the model?
I guess it's PersistTransient method functionality.
Richard Stima said:What is the function of two methods StartTransientMode() and PersistTransients()?
I am not sure why it is done this way (and there is no equal method in native API), but it's the way how to add civil object to DGN file:
Richard Stima said:Can we delete civil element by ConsensusConnectionEdit. Delete() method?
I am not sure, so far I have had no request to delete any civil object ;-)
Do you have any code / DGN file as an example? What do you pass as an argument? And maybe to use transient mode is necessary here?
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Jan,
Thank you and sorry for my late reply. I was unwell last week.
Jan Šlegr said:I always create it only when required, usually because I need to access GeometricModel content, and close and dispose it asap. When a user tool is implemented, OnPostInstall is the place where the connection is opened and OnExitTool the place where to close / dispose it.
This is great reminder that even with NET garbage collector we should not forget to clean up after yourself. Maybe topic for the future.
Jan Šlegr said:I guess it's PersistTransient method functionality.
I am still not sure with this. If I run below code with commented two lines, even then alignment is added into the model
public AlignmentEdit CreateBaseLine() { DPoint3d startPoint = new DPoint3d(0, 0); DPoint3d endPoint = new DPoint3d(1, 1); Line line = Line.Create1(startPoint, endPoint); ConsensusConnectionEdit con = ConsensusConnectionEdit.GetActive(); //con.StartTransientMode(); AlignmentEdit al = AlignmentEdit.CreateByLinearElement(con, line, true); //con.PersistTransients(); return al; }
Jan Šlegr said:Do you have any code / DGN file as an example? What do you pass as an argument? And maybe to use transient mode is necessary here?
I was only trying ConsensusConnectionEdit.Delete and as argument I passed Alignment object (inherited class CifNET.SDK.ConsensusItem)
Thanks,