Hi, I can not figure out how to place a fence in C# on another model.
This is with Bentley Map 08.11.09.864
The process is :
1) Read the current fence information2) Switch to another model3) Place the fence in this model - same place as it was in the other one.
Here is what I'm trying :
BCOM.Fence oFence = null;BCOM.Element oElement = null;
if (KortAddin.ComApp.ActiveDesignFile.Fence.IsDefined){ oFence = KortAddin.ComApp.ActiveDesignFile.Fence; oElement = oFence.CreateElement(); foreach (BCOM.ViewGroup vg in KortAddin.ComApp.ActiveDesignFile.ViewGroups) { if ((vg.Name.Length >= 6) && (vg.Name.Substring(0, 6) == ModelName)) { if (!vg.Name.Contains("Temp Views")) { vg.Activate(); _wfsModel = KortAddin.ComApp.ActiveModelReference;
KortAddin.ComApp.ActiveDesignFile.Fence.Undefine(); KortAddin.ComApp.ActiveDesignFile.Fence.DefineFromElement(oFence.View, oElement);
The last line is not working - throwing this error :System.Runtime.InteropServices.COMException (0x80040000): Fence is not definedat Bentley.Interop.MicroStationDGN.Fence.get_View()
If I change the code - and comment out the "vg.Activate" - so the model is not changed - everything is working ok. But I need the defined fence in the current model - to be placed in another model.
Are the oFence and/or oElement destroyed somehow when switching the view/model ? and if so - how to make it work ?
Thanks for any input.