Ad

Monday, January 27, 2014

Profile View Bands

There appears to be a bug in adding a profile view band set to a profile view through the API in Civil 3D 2013 & 2014. The error is that the profiles, pipe network, and other information isn’t shown properly. In addition all of the settings don’t make sense. Here is some code that corrects the situation below. There is lots of code not shown, along with methods that are called that are included below. But the main concept is below.

ProfileViewBandSetStyle bandSet = profileBandSetId.GetObject(OpenMode.ForRead) as ProfileViewBandSetStyle;
ProfileViewBandItemCollection bottomBandItems = profileView.Bands.GetBottomBandItems();
ProfileViewBandItemCollection topBandItems = profileView.Bands.GetTopBandItems();

bottomBandItems.RemoveAll();
topBandItems.RemoveAll();

bottomBandItems = new ProfileViewBandItemCollection(profileView.ObjectId, Autodesk.Civil.BandLocationType.Bottom);
topBandItems = new ProfileViewBandItemCollection(profileView.ObjectId, Autodesk.Civil.BandLocationType.Top);

var bottomBandSetItems = bandSet.GetBottomBandSetItems();

foreach (var bandItem in bandSet.GetBottomBandSetItems())
{
bottomBandItems.Add(bandItem.BandStyleId);
}

int i = 0;
foreach (var bandItm in bottomBandItems)
{
bandItm.Gap = bottomBandSetItems[i].Gap;
bandItm.LabelAtEndStation = bottomBandSetItems[i].LabelAtEndStation;
bandItm.LabelAtStartStation = bottomBandSetItems[i].LabelAtStartStation;
if (bandItm.BandType != Autodesk.Civil.BandType.PipeNetwork)
{
bandItm.MajorInterval = bottomBandSetItems[i].MajorInterval == 0 ? 100 : bottomBandSetItems[i].MajorInterval;
bandItm.MinorInterval = bottomBandSetItems[i].MinorInterval == 0 ? 25 : bottomBandSetItems[i].MinorInterval;
bandItm.SetHorizontalGeometryPointsOptions(bottomBandSetItems[i].GetHorizontalGeometryPointsOptions());
bandItm.SetVerticalGeometryPointsOptions(bottomBandSetItems[i].GetVerticalGeometryPointsOptions());
bandItm.StaggerLabel = bottomBandSetItems[i].StaggerLabel;
if (bandItm.StaggerLabel != StaggerLabelType.None)
{
bandItm.StaggerLineHeight = bottomBandSetItems[i].StaggerLineHeight;
}
}
bandItm.ShowLabels = bottomBandSetItems[i].ShowLabels;
bandItm.Weeding = bottomBandSetItems[i].Weeding;
i += 1;
}

var topBandSetItems = bandSet.GetTopBandSetItems();

foreach (var bandItem in topBandSetItems)
{
topBandItems.Add(bandItem.BandStyleId);
}

i = 0;
foreach (var bandItm in topBandItems)
{
bandItm.Gap = topBandSetItems[i].Gap;
bandItm.LabelAtEndStation = topBandSetItems[i].LabelAtEndStation;
bandItm.LabelAtStartStation = topBandSetItems[i].LabelAtStartStation;
if (bandItm.BandType != Autodesk.Civil.BandType.PipeNetwork)
{
bandItm.MajorInterval = topBandSetItems[i].MajorInterval == 0 ? 100 : bottomBandSetItems[i].MajorInterval;
bandItm.MinorInterval = topBandSetItems[i].MinorInterval == 0 ? 25 : bottomBandSetItems[i].MinorInterval;
bandItm.SetHorizontalGeometryPointsOptions(topBandSetItems[i].GetHorizontalGeometryPointsOptions());
bandItm.SetVerticalGeometryPointsOptions(topBandSetItems[i].GetVerticalGeometryPointsOptions());
bandItm.StaggerLabel = topBandSetItems[i].StaggerLabel;
if (bandItm.StaggerLabel != StaggerLabelType.None)
{
bandItm.StaggerLineHeight = topBandSetItems[i].StaggerLineHeight;
}
}
bandItm.ShowLabels = topBandSetItems[i].ShowLabels;
bandItm.Weeding = topBandSetItems[i].Weeding;
i += 1;
}

UpdateBandProfileAndDataSource(PipeNetworkObjId, prof, bottomBandItems);
UpdateBandProfileAndDataSource(PipeNetworkObjId, prof, topBandItems);

profileView.Bands.SetBottomBandItems(bottomBandItems);
profileView.Bands.SetTopBandItems(topBandItems);

No comments:

LinkWithin

Blog Widget by LinkWithin

Ad