In .NET, Is there a way to get a collection of all ProfileViewParts drawn in a given ProfileView? It seems like this should be something easily accomplished but I can't find an obvious way to do it by looking through the API reference guide.
I want to be able to access all parts drawn in a given profile view. If that doesn't make sense I'm not sure how else to word it. "ProfileViewPart" is the name of the class for a part drawn in a profile view in the .NET API.
Aha, that appears to be my answer, Jeff_M--thanks. I will try it out when I am working on the task I needed this for again.
OK...I couldn't get that to work. When I just tried to write some simple code to test it out and display the names of all the profiles in the graph overrides collection, it only displayed one name, and it was for an actual profile (not a part), and the profile wasn't even actually in that profile view, to boot!
Here's my code--any ideas?
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim db As Database = doc.Database
Using trans As Transaction = db.TransactionManager.StartTransaction
Dim geoptionspv As PromptEntityOptions = New PromptEntityOptions("Select profile view: ")
geoptionspv.SetRejectMessage("You didn't select a profile view.")
geoptionspv.AddAllowedClass(GetType(ProfileView), True)
geoptionspv.AllowNone = False
Dim geresultpv As PromptEntityResult = ed.GetEntity(geoptionspv)
If Not geresultpv.Status = PromptStatus.OK Then
ed.WriteMessage("Something went wrong.")
Exit Sub
End If
Dim thepvID As ObjectId = geresultpv.ObjectId
Dim thepv As ProfileView = thepvID.GetObject(OpenMode.ForRead)
Dim povercoll As ProfileOverrideCollection = thepv.GraphOverrides
For Each poverride As ProfileOverride In povercoll
ed.WriteMessage("Name of override: " & poverride.ProfileName & vbCr)
Next
End Using
End Sub
Jeff,
I will investigate this ....
Thanks,
Partha
If GraphOverrides doesn't work out, you can always get the parts drawn in a profile view by iterating through all parts in the drawing and calling the method GetProfileViewsDisplayingMe for each. I use a simple extension method something like the following.
public static ObjectIdCollection GetDisplayedPartIds( this ProfileView pv ) { var result = new ObjectIdCollection(); var cvDoc = CivilApplication.ActiveDocument; foreach ( ObjectId pnId in cvDoc.GetPipeNetworkIds() ) { var pn = (Network)pnId.GetObject( OpenMode.ForRead ); AddIdsDisplayedInProfileView( ref result, pv.ObjectId, pn.GetPipeIds() ); AddIdsDisplayedInProfileView( ref result, pv.ObjectId, pn.GetStructureIds() ); } return result; } private static void AddIdsDisplayedInProfileView( ref ObjectIdCollection displayedIds, ObjectId profileViewId, ObjectIdCollection partIdsToSearch ) { foreach ( ObjectId id in partIdsToSearch ) { var p = (Part)id.GetObject( OpenMode.ForRead ); if ( p.GetProfileViewsDisplayingMe().Contains( profileViewId ) ) displayedIds.Add( id ); } }