I decided to try this in VBA...it worked :-/ (I'll post that code if anyone cares to see it)
I then said, well let's see what happens in VB.NET... it WORKED! I'm using nearly identical code for the VB & C# versions, yet the C# version throws that stupid build error.
Here's a stripped down test, both the Vb & C# references (as shown in the pic) are the same:
VB.NET
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common
Imports System.Runtime.InteropServices
Imports System.Runtime.InteropServices.Marshal
Imports Autodesk.AECC.Interop.Land
Imports Autodesk.AECC.Interop.UiLand
Public Class Class1
Public WithEvents m_AcadApp As AcadApplication
Public oCivilApp As AeccApplication
<CommandMethod("TestStyle")> _
Public Sub TestStyle()
Try
m_AcadApp = GetActiveObject("AutoCAD.Application.17.1")
oCivilApp = m_AcadApp.GetInterfaceObject("AeccXUiLand.AeccApplication.5.0")
If oCivilApp Is Nothing Then
MsgBox("Error creating " & "AeccXUiLandLib.AeccApplication" & ", exit.")
GoTo exit_here
Else
''MsgBox("Civil 3D instance connected" & m_AcadApp.ActiveDocument.Name.ToString)
Dim oCivilDoc As AeccDocument
oCivilDoc = oCivilApp.ActiveDocument
Dim oPtGroups As AeccPointGroups
Dim oPoint As AeccPoint
oPoint = oCivilDoc.Points.Item(747)
Dim oGrp As AeccPointGroup
oPtGroups = oCivilDoc.PointGroups
For Each oGrp In oPtGroups
If oGrp.ContainsPoint(oPoint.Number) Then
MsgBox("Point 747 is in PtGroup: " & oGrp.Name & vbCrLf & _
"The Pointstyle for the group is: " & oGrp.PointStyle.Name)
End If
Next
End If
Catch
MsgBox(Err.Description() & Err.Number)
End Try
exit_here:
End Sub
End Class
And the C# counterpart
using System;
using System.Collections.Generic;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Interop;
using Autodesk.AECC.Interop.Land;
using Autodesk.AECC.Interop.UiLand;
using acadApp = Autodesk.AutoCAD.ApplicationServices.Application;
namespace PointGroupDataTest
{
public class Class1
{
public Class1()
{
}
#region Command
[CommandMethod("PtGrp")]
static public void PtGrptCode()
{
Document doc = acadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
string m_sAeccAppProgId = "AeccXUiLand.AeccApplication.5.0";
AcadApplication m_oAcadApp = (Autodesk.AutoCAD.Interop.AcadApplication)Application.AcadApplication;
AeccApplication m_oAeccApp = (AeccApplication)m_oAcadApp.GetInterfaceObject(m_sAeccAppProgId);
AeccDocument m_oAeccDoc = (AeccDocument)m_oAeccApp.ActiveDocument;
AeccDatabase m_oAeccDb = (AeccDatabase)m_oAeccDoc.GetType().GetProperty("Database").GetValue(m_oAeccDoc, null);
AeccPoints oPoints = (AeccPoints)m_oAeccDoc.Points;
AeccPoint oPoint = oPoints.Item(747);//hardcoded Point#
AeccPointGroups oGroups = m_oAeccDoc.PointGroups;
foreach (AeccPointGroup oGrp in oGroups)
{
if (oGrp.ContainsPoint(oPoint.Number))
{
ed.WriteMessage("\nPoint 747 is in PointGroup: " + oGrp.Name);
ed.WriteMessage("\nThe style used by " + oGrp.Name + " = " + oGrp.PointStyle.Name);
}
}
}
#endregion
}
}
The C# version will error when building, pointing to the oGrp.Pointstyle in this line:
ed.WriteMessage("\nThe style used by " + oGrp.Name + " = " + oGrp.PointStyle.Name);
I sure can't tell any difference in the use of this property, or how I obtain the Objects. Can anyone enlighten me?
Please don't say "Well just do it in VB.NET or VBA...."