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: 

.NET api - Catchment reference structure

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
650 Views, 4 Replies

.NET api - Catchment reference structure

I'm looking to use VB.NET to export a list of catchments and referenced structures, but I can't find any way to get the referenced structure using the api's Catchment object.  Am I missing something?

 

http://docs.autodesk.com/CIV3D/2015/ENU/API_Reference_Guide/html/54440d04-8d43-9df3-bdd3-d5993aa9c27...

 

The attached image shows the "data" I'm looking to access via .NET

4 REPLIES 4
Message 2 of 5
Civil3DReminders_com
in reply to: Anonymous

Nope. The way I ended up getting information for the catchment is to add the information to the catchment label, explode it, read the resulting value. I do this in a transaction and then don't commit it. 

 

You can also try to get the info through reflection and finding the correct dll to load the method from, but that is way over my head unless I have like 8+ hours to kill. 

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
Message 3 of 5
Anonymous
in reply to: Civil3DReminders_com

Ah, well I'm glad I'm not missing something.  Thanks for the idea RE: exploding a label - that would definitely be the fastest workaround!

Message 4 of 5
Daniel.Du
in reply to: Anonymous

Hi,

 

You may find this tool - snoopdb- is helpful for your investigation: 

http://adndevblog.typepad.com/infrastructure/2013/04/snoop-civil-3d-2014-database.html 



Daniel Du
Developer Technical Services
Autodesk Developer Network

Message 5 of 5
messiasEHTD8
in reply to: Anonymous

Hi, 

 

Well, I know you have already solved it, but follow the code to do that.

 

Private Sub GetStructureInCatchment ()

        Dim DocCAD As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument

        Dim DocCivil As Autodesk.Civil.ApplicationServices.CivilDocument = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument

        Dim DataCAD As Database = DocCAD.Database

        Dim EditorCAD As Editor = DocCAD.Editor

        Dim SelectionCat As New PromptEntityOptions("select your Catchment ")

        SelectionCat.SetRejectMessage("")

        SelectionCat.AddAllowedClass(GetType(Autodesk.Civil.DatabaseServices.Catchment), True)

        Dim TrechoSel As PromptEntityResult = EditorCAD.GetEntity(SelectionCat)

        If Not TrechoSel.Status = PromptStatus.OK Then

            Exit Sub

        End If

        Using docLock As Autodesk.AutoCAD.ApplicationServices.DocumentLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument()

            Using TransCAD As Transaction = DataCAD.TransactionManager.StartTransaction

                Dim Cat As Catchment = TransCAD.GetObject(TrechoSel.ObjectId, OpenMode.ForRead)

                Dim CatLB As CatchmentLabel = TransCAD.GetObject(Cat.GetAvailableCatchmentLabelIds(0), OpenMode.ForRead)

                Dim LB As LabelStyleTextComponent = TransCAD.GetObject(CatLB.GetTextComponentIds(0), OpenMode.ForWrite)

                LB.Text.Contents.Value = "<[Reference Pipe Network Structure]>"

                Dim ListOBJExploded = FullExplode(CatLB)

                For Each ent As Entity In ListOBJExploded

                    If ent.GetType = GetType(DBText) Then

                        Dim text As DBText = TryCast(ent, DBText)

                        ' Alert with your structure :)
                        MsgBox(text.TextString)

                    End If

                Next

            End Using

        End Using


    End Sub

    Private Function FullExplode(ByVal ent As Entity) As List(Of DBObject)

        Dim fullList As List(Of DBObject) = New List(Of DBObject)()

        Dim explodedObjects As DBObjectCollection = New DBObjectCollection()

        ent.Explode(explodedObjects)

        For Each explodedObj As Entity In explodedObjects

            If explodedObj.[GetType]() = GetType(BlockReference) OrElse explodedObj.[GetType]() = GetType(MText) Then

                fullList.AddRange(FullExplode(explodedObj))

            Else

                fullList.Add(explodedObj)

            End If

        Next

        Return fullList

    End Function

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report