In Civil 3D 2012 and earlier releases there were some issues in accessing some of the display styles (listed below) for a MassHaulViewStyle object:
MassHaulViewDisplayStyleType.MiddleAxis
MassHaulViewDisplayStyleType.MiddleAxisTitle
MassHaulViewDisplayStyleType.MiddleAxisAnnotationMajor
MassHaulViewDisplayStyleType.MiddleAxisAnnotationMinor
MassHaulViewDisplayStyleType.MiddleAxisTicksMajor
MassHaulViewDisplayStyleType.MiddleAxisTicksMinor
MassHaulViewDisplayStyleType.GridAtSampleLineStations
In 2013 release of Civil 3D .NET API, this issue is fixed and you can now access and set these displayStyles for a MassHaulViewStyle using .NET API.
Here is a C# code snippet :
using (Transaction tr = db.TransactionManager.StartTransaction())
{
MassHaulViewStyle style = tr.GetObject(oId, OpenMode.ForWrite) as MassHaulViewStyle;
DisplayStyle displayStyleMiddleAxis =
style.GetDisplayStylePlan(Autodesk.Civil.MassHaulViewDisplayStyleType.MiddleAxis);
DisplayStyle displayStyleMiddleAxisTitle =
style.GetDisplayStylePlan(Autodesk.Civil.MassHaulViewDisplayStyleType.MiddleAxisTitle);
DisplayStyle displayStyleMiddleAxisAnnotationMajor =
style.GetDisplayStylePlan(Autodesk.Civil.MassHaulViewDisplayStyleType.MiddleAxisAnnotationMajor);
DisplayStyle displayStyleMiddleAxisAnnotationMinor =
style.GetDisplayStylePlan(Autodesk.Civil.MassHaulViewDisplayStyleType.MiddleAxisAnnotationMinor);
DisplayStyle displayStyleMiddleAxisTicksMajor =
style.GetDisplayStylePlan(Autodesk.Civil.MassHaulViewDisplayStyleType.MiddleAxisTicksMajor);
// Works fine in Civil 3D 2013
try
{
ed.WriteMessage("\n" + displayStyleMiddleAxis.Layer);
displayStyleMiddleAxis.Layer = "0";
}
catch (System.Exception ex)
{
ed.WriteMessage("\n" + ex.Message);
}
try
{
ed.WriteMessage("\n" + displayStyleMiddleAxisTitle.Layer);
displayStyleMiddleAxisTitle.Layer = "0";
}
catch (System.Exception ex)
{
ed.WriteMessage("\n" + ex.Message);
}
// Similar way we can access or set other DisplayStyle properties of MassHaulViewStyle
//...
tr.Commit();
}
Hope this is useful to you!