Can you create Catchment Objects from the API?

Can you create Catchment Objects from the API?

ralstogj
Collaborator Collaborator
1,179 Views
6 Replies
Message 1 of 7

Can you create Catchment Objects from the API?

ralstogj
Collaborator
Collaborator

Hi

 

Can you create Catchment Objects from the API or does any one know how to update the SSA file to include your catchment data?

 

Regards

Justin Ralston
http://c3dxtreme.blogspot.com/
0 Likes
1,180 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

Hi Justin,

 

From the API help file, I don't see an way to create Catchment object. However, Civil 3D .NET API Catchment class has exposed members to access some of the properties.

 

does any one know how to update the SSA file to include your catchment data?

>>> I would suggest you to ask this in Civil 3D user group as this has nothing to do with API.

 

Thanks,

0 Likes
Message 3 of 7

ralstogj
Collaborator
Collaborator

Partha

 

Seeing it in not in the managed API I have just been having a play with trying to use the send command to send CREATECATCHMENTFROMOBJECT to the command line and then passing the last object that I have set as a polyline pulled out of a parcel object.

 

Then I am using sendkeys to try and tab thru the dialog box but Civil3d gets the focus. Can I stop this happening or set up a hook in and event that watches for the "Create Catchment from Object dialog"" to appear to grab back the focus back along the lines of these links?

 

http://miamicoder.com/2008/how-to-spy-on-a-windows-program-tracking-main-window-activation/

http://through-the-interface.typepad.com/through_the_interface/2008/05/filtering-windo.html

 

I did do it years ago 2002-2003 in vba and by starting an external .exe watching for the window handle and name but will have to hunt down the code and expect it will not work with 64 Bit system anyway.

 

Any suggestions on I simpler way. The end goal I am trying to achieve is to get my parcels which represent catchments linked to structures allready (a couple of hundred) into catchments and out to SSA.

 

    Public Sub MakeCatchment()
        Dim document As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = document.Editor
        Dim db As Database = document.Database

        ''Select a polyline to turn into a catchment object

        Dim peo1 As New PromptEntityOptions(vbLf & "Select a Catchment Object : ")

        peo1.SetRejectMessage(vbLf & "Invalid selection...")
        peo1.AddAllowedClass(GetType(Autodesk.Civil.Land.DatabaseServices.Catchment), True)

        Dim pEntrs As PromptEntityResult = ed.GetEntity(peo1)
        If PromptStatus.OK <> pEntrs.Status Then
            Return
        End If

        Dim ParcelId As ObjectId = pEntrs.ObjectId

        '*******************************************

        Dim app As AcadApplication
        app = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication
        'app.ActiveDocument.SendCommand("AddNetworkPartsToProf" & vbCr & "Select" & vbCr & "P" & vbCr & vbCr & "(handent ""faa8f"")" & vbCr)
        app.ActiveDocument.SendCommand("CREATECATCHMENTFROMOBJECT" & vbCr & "Last" & vbCr & Chr(27) & Chr(9) & Chr(9)) ''The 'chr(27)' means ESC key.
        '' 11 tab keys
        SendKeys.Send("{TAB 13}")

Regards

Justin Ralston
http://c3dxtreme.blogspot.com/
0 Likes
Message 4 of 7

augusto.goncalves
Alumni
Alumni

Hi Justin,

 

I saw your comment on my blog post, but it's not there anymore...

 

Anyway, the thing about sending messages to Windows Dialogs is that we cannot do it from the main AutoCAD thread, like from inside a command. You need to start a second thread that will watch the dialog opened and then send keys to it.

 

After SendCommand, start another thread, wait until the dialog is ready, the call SendKey to it.

 

Regards,

 

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 5 of 7

ralstogj
Collaborator
Collaborator

Augusto

 

Do you have or could you point me in the direction of an example of how to start a second theard from in Autocad.

 

Justin

Regards

Justin Ralston
http://c3dxtreme.blogspot.com/
0 Likes
Message 6 of 7

augusto.goncalves
Alumni
Alumni

Justin,

 

There are several samples on the web, this is a .NET feature. Try this http://stackoverflow.com/questions/10182563/create-a-new-thread-in-vb-net

 

Important: as AutoCAD Civil 3D is not multi-thread, we cannot directly sync back to AutoCAD. So inside the 2nd thread, you can use User32 FindWindow (http://www.pinvoke.net/default.aspx/user32.findwindow) to get the dialog, then get the Handle to SendKey.

 

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 7 of 7

ralstogj
Collaborator
Collaborator

Thanks Augusto, I will have a look into it and see if I can get something working.

Regards

Justin Ralston
http://c3dxtreme.blogspot.com/
0 Likes