Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting all profile parts for a particular profile view with .NET?

8 REPLIES 8
Reply
Message 1 of 9
ltmullen
1201 Views, 8 Replies

Getting all profile parts for a particular profile view with .NET?

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.

8 REPLIES 8
Message 2 of 9
joantopo
in reply to: ltmullen

What is ProfileViewParts? ¿? Do you refer to profiles?
Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 3 of 9
ltmullen
in reply to: joantopo

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.

Message 4 of 9
Jeff_M
in reply to: ltmullen

It looks like the GraphOverrides Collection holds this data. It uses the part name as the Profile Name.

 

GraphOverride.png

Jeff_M, also a frequent Swamper
EESignature
Message 5 of 9
ltmullen
in reply to: Jeff_M

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.

Message 6 of 9
ltmullen
in reply to: Jeff_M

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

Message 7 of 9
Jeff_M
in reply to: ltmullen

Yeah, I'm not sure what is going on with that. The first profileview I checked returned everything I thought it would. Then I created a new one, of the same alignment, with no pipe network parts, both the EG & FG profiles listed, then I added just 1 pipe to the profile, and the GraphOverrides still only showed the EG & FG, no pipe. I added more pipes & structures and they all were correctly listed. So I was hoping Partha would jump in here with some insight on this.
Jeff_M, also a frequent Swamper
EESignature
Message 8 of 9
Partha.Sarkar
in reply to: Jeff_M

Jeff,

 

I will investigate this ....

 

Thanks,

Partha



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 9 of 9
tyronebk
in reply to: ltmullen

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 );
   }
}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report