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: 

Projecting objects to profile in vb.net

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
eadonan
3552 Views, 5 Replies

Projecting objects to profile in vb.net

New to C3D .net, long time C3D user. Guess I thought I would take matters into my own hands and really pop the hood. So I've managed to create a Survey Project, Network, Points, Figures, Alignment, and a Profile with a view; all from a couple of xml files of survey data. All right that's all going well enough.

I need to project some of the points and figures to the profile view and I'm not making any progress. I found the ProfileProjection class in the object browser, but I'm not sure how to handle the first argument (ByVal unmanagedPointer AsSystem.IntPtr,) or even if I'm on the right path. I'm guessing that it should work similar to other Create() methods by referencing an ID, then later calling a projObject.Draw() or something similar. An example would be great. 

 

Below is a snippet of the survey point section. I'm iterating through each survey point in the xml data. I hope to create the projObj for each CL shot as a starting place. I think the figures would be similar if I can get a point to work. 

 

Using C3D 2012

 

'Survey Points     ================================================================
                'Create Non-Control Points for network
                Dim oNonControlPt As AeccSurveyNonControlPoint

                'Dim xNumber As Integer = 0
                For Each xPoint In pFile...<Point>

                    Dim xNumber As Integer = xPoint.<Number>.Value
                    Dim xName As String = xPoint.<Name>.Value
                    Dim xDescription As String = xPoint.<Code>.Value
                    Dim xEast As Double = xPoint.<Grid>.<East>.Value / 3.28083333333333
                    Dim xNorth As Double = xPoint.<Grid>.<North>.Value / 3.28083333333333
                    Dim xElevation As Double = xPoint.<Grid>.<Elevation>.Value / 3.2808333333333

                    oNonControlPt = oSurveyNetwork.NonControlPoints.Create( _
                                            xNumber,
                                            xName, _
                                            xDescription, _
                                            xEast, _
                                            xNorth, _
                                            xElevation)


                    Dim projPointID As System.IntPtr = oNonControlPt.ID

                    'Fatal Error Here!!!!
                    If oNonControlPt.Description.Contains("CL") Then
                        'project each CL point to profile
                        Dim projObject As ProfileProjection = ProfileProjection.Create(projPointID, False)
                    End If

                Next

                '?oSurveyNetwork.UpdateNetwork()


                'Survey Figures    ================================================================

 

Any help or direction will be appreaciated.

Thanks,

Eric

5 REPLIES 5
Message 2 of 6
Partha.Sarkar
in reply to: eadonan

Hi Eric,

 

Please refer to the Civil 3D .NET API Ref document, ProfileProjection class has only few properties exposed, create() is not exposed for public usage, sorry.

 

Few years ago I had written the following VBA code which will draw a point on a selected location on the surface and then project the same point in the Profile View (long profile). I think you can use this concept and use the .NET API now to project the objects to Profile View.

 

Public Sub DrawPointInProfileView()

    Dim oApplication As AcadApplication
    Set oApplication = ThisDrawing.Application
    Const sAppName = "AeccXUiLand.AeccApplication"
    Set g_oCivilApp = oApplication.GetInterfaceObject(sAppName)
    Set g_oAeccDoc = g_oCivilApp.ActiveDocument
    Set g_oAeccDb = g_oAeccDoc.Database
   
    ' Select an Alignment
    ' Select a point on the surface and find out the Station with respect to an Alignment
    Dim oPoint As AeccPoint
    Dim objEnt As AeccAlignment
    Dim varPick As Variant
    ThisDrawing.Utility.GetEntity objEnt, varPick, "Select an Alignment "
    If objEnt Is Nothing Then
        Exit Sub
    ElseIf TypeOf objEnt Is AeccAlignment Then
            Dim pt As Variant
            Dim stn As Double, off As Double
            Dim oSurf As AeccSurface
            Dim dElevationAtPoint As Double
            Set oSurf = g_oAeccDb.Surfaces.Item(0)
            pt = ThisDrawing.Utility.GetPoint(, "Select the Point")
           
            dElevationAtPoint = oSurf.FindElevationAtXY(pt(0), pt(1))
            objEnt.StationOffset pt(0), pt(1), stn, off
            pt(2) = dElevationAtPoint
            MsgBox "Station = " & stn
            MsgBox "Elevnation of Selected Point = " & pt(2)
           
            ThisDrawing.SetVariable "PDMODE", 34
            Set oPoint = g_oAeccDb.Points.Add(pt)
            MsgBox " Point is Drawn at Selecetd Location"
    Else
        Exit Sub
    End If
   
   
    ' select the Profile View where you want to Project the Point
   
    Dim acadObj As AcadObject
    Dim pnt As Variant
    Dim oProfileView As AeccProfileView

    ThisDrawing.Utility.GetEntity acadObj, pnt, "Select a Profile View"
    If acadObj Is Nothing Then
        Exit Sub
    ElseIf TypeOf acadObj Is AeccProfileView Then
        Set oProfileView = acadObj
    Else
        Exit Sub
    End If
    On Error Resume Next
    MsgBox " Profile View Name = " & oProfileView.Name
   
   
    Dim x As Double, y As Double
    oProfileView.FindXYAtStationAndElevation stn, dElevationAtPoint, x, y
    Dim point As AcadPoint
    Dim location(0 To 2) As Double
    location(0) = x
    location(1) = y
    location(2) = 0#
   
    ' Create the point in Profile View
    Set point = ThisDrawing.ModelSpace.AddPoint(location)
    MsgBox " Point is Drawn in Profile View "

End Sub

 

Does it help ?

 

Thanks,

 



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 3 of 6
eadonan
in reply to: Partha.Sarkar

It took me a while to get back to working on this issue, but I've got so much help from the groups that I wanted to post reply. So, yes the vba code did lead me to the answer Partha, thanks.

 

As implemented in my code for vb.net. I'm labeling a filtered set of survey points on the profile. Here I'm in a For Each statement using linq with a xml file. Below I'm using the similar StationOffset to get the plan station value and offset from the X, Y values of the points.

'Return the station and offset for the current point
currentAlignment.StationOffset(xEast, xNorth, 0.25, planStaVal, planOffVal)

 ...

'Return the profile view's current X,Y equilivant for a given station and elevation
oProfileView.FindXYAtStationAndElevation(planStaVal, minElev, lblPOTx, lblPOTy)

The one issue I have with this solution is the text, lines, blocks, etc I've drawn on the profile aren't relative or dynamic to the profile view. So if the view moves or even the style gets changed the entities are disconnected and must be redrawn. I haven't put in place a solution for that yet.

Would anyone care to recommend a suggestion to "bind" these entities to the view?

I've thought about maybe grouping them all or maybe putting xData on each item to reference back to the start of the profile or a known Station, Elevation tic.

Message 4 of 6
Partha.Sarkar
in reply to: eadonan

I am glad to know that it was helpful to you.

 

Text, Lines, blocks are not part of Civil 3D object family and hence are not dynamic. Could you consider them replacing with Civil 3D objects Like Lables, Feature Line etc. ?

 

Thanks,

Partha



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 5 of 6
theEntity
in reply to: Partha.Sarkar

Even if the points were cogo. they will not reflect change on plan dynamically.

Just drawing points on the profile is far from what i'd call a solution.

 

I wish we had a method to project objects to profile view.. 

 

I cant even use SetImpliedSelection() to a Doc.SendStringToExecute("ProjectObjectsToProf", True, False, True)

becuase you have to select the profile 1st.

 

no resolution here?

 

 

 

Message 6 of 6
veli_vaisanen
in reply to: eadonan

Hi Eric,

if you have to project basic AutoCAD entities to specific plane then you can use following function:

Autodesk.AutoCAD.DatabaseServices.Curve.GetProjectedCurve

 

it returns circle, ellipse or line against to the specific plane depends on entity figure and direction.

 

-Veli

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report