Good day all,
I haven't found a similar question to mine, so i decided to write one.
I am using VS 2017 Community Edition, version 15.9.4 and i used the InnovoCAD v8i C# Template as published on the VS Marketplace.
The problem I have is that when I debug in an MVBA project, I can see all the properties of an element, but when I do the same in C# using VS2017, it displays {System._ComObject}.
In C#, it will select and count all the Items I need, and highlight them, as is required in the code, but I dot have access to any of the Element properties, even if the program uses some of the properties to determine which items to select.
For instance the procedure I have:
1. it checks whether an element is a cell
2. determines cellname to search for among the cells
3. if cellname matches requirements, cell is selected.
Below is the C# Code of the procedure.
public static void selectNormalCells(string cellType)
{
BCOM.Element oElem;
BCOM.Fence oFence;
BCOM.ElementEnumerator oEnum;
string cellName;
Program.MSApp.ActiveModelReference.UnselectAllElements();
oFence = Program.MSApp.ActiveDesignFile.Fence;
oEnum = oFence.GetContents();
//Determine MicroStation Cellname from combobox selected text
switch (cellType)
{
case "LV Stays":
{
cellName = "001";
break;
}
case "LV Struts":
{
cellName = "002";
break;
}
case "MV Stays":
{
cellName = "003";
break;
}
case "MV Struts":
{
cellName = "004";
break;
}
case "LV Poles":
{
cellName = "009";
break;
}
case "MV Poles":
{
cellName = "010";
break;
}
case "MVLV Poles":
{
cellName = "011";
break;
}
case "LV Flying Stays":
{
cellName = "015";
break;
}
case "MV Flying Stays":
{
cellName = "017";
break;
}
case "TRFRS":
{
cellName = "TXTCS";
break;
}
default:
{
cellName = "000";
break;
}
}
//Iterate through all elements and select only the cell elements named 'CellName.
while (oEnum.MoveNext())
{
oElem = oEnum.Current;
if ((oElem.Type == BCOM.MsdElementType.CellHeader))
{
if ((oElem.AsCellElement().Name == cellName))
{
oElem.Redraw(BCOM.MsdDrawingMode.Hilite);
Program.MSApp.ActiveModelReference.SelectElement(oElem);
}
}
}
}
Below is a screenshot of the locals window in VS2017 Community.
![Sample Screenshot 01]()
Below is the VBA code in mvba project,
Sub selectNormalCells(ByVal CellType As String)
Dim oElem As Element
Dim ofence As Fence
Dim oEnum As ElementEnumerator
Dim CellName As String
ActiveModelReference.UnselectAllElements
Set ofence = ActiveDesignFile.Fence
Set oEnum = ofence.GetContents'Determine MicroStation Cellname from combobox selected text
Select Case CellType
Case "LV Stays"
CellName = "001"
Case "LV Struts"
CellName = "002"
Case "MV Stays"
CellName = "003"
Case "MV Struts"
CellName = "004"
Case "LV Poles"
CellName = "009"
Case "MV Poles"
CellName = "010"
Case "MVLV Poles"
CellName = "011"
Case "LV Flying Stays"
CellName = "015"
Case "MV Flying Stays"
CellName = "017"
Case "TRFRS"
CellName = "TXTCS"
Case Else
CellName = "000"
End Select'Iterate through all elements and select only the cell elements named 'CellName.
Do While oEnum.MoveNext
Set oElem = oEnum.Current
If (oElem.type = msdElementTypeCellHeader) Then
If (oElem.AsCellElement.Name = CellName) Then
oElem.Redraw msdDrawingModeHilite
ActiveModelReference.SelectElement oElem
End If
End If
Loop
End Sub
And a screenshot of the locals debug section in MVBA
![]()
I can clearly see items and properties of the elements in VBA, but not in the VS2017.
Is there a variable i have not set or some setup step I omitted?
Furthermore, the function in both instances works, and selects the appropriate cells, but in VS2017 I dont have access to the properties. I only see {System._ComObject}.
Kindly assist. I can send further information by request.
Regards,
Greg M
System details:
Microsoft Windows 10, 64-bit
MicroStation v8i (SS4), 08.11.09.832
8GB RAM