TheSwamp

Code Red => .NET => Topic started by: UWPMVG on October 05, 2012, 05:03:12 AM

Title: Create a QuickProfile in Civil3D 2012 using .net
Post by: UWPMVG on October 05, 2012, 05:03:12 AM
Is it possible to create a QuickProfile in Civil3D 2012 using .NET?

I have searched the internet and not found anything about QuickProfile.

In the API reference guide I found "SettingsCmdCreateQuickProfile" but did not understand how to use that information.

http://docs.autodesk.com/CIV3D/2013/ENU/API_Reference_Guide/html/a8aa4925-aa63-d1cf-dfbe-44bd04ffd238.htm (http://docs.autodesk.com/CIV3D/2013/ENU/API_Reference_Guide/html/a8aa4925-aa63-d1cf-dfbe-44bd04ffd238.htm)

Please anyone!?
Title: Re: Create a QuickProfile in Civil3D 2012 using .net
Post by: huiz on October 05, 2012, 12:29:04 PM
SettingsCmd.... refers to settings which can be set in the Settings Tab of the ToolSpace.

I don't know if you can create a QuickProfile with .Net, but you can create a Surface Profile from a Surface. Why not simulate the Quick Profile with an app that creates a real Profile?

An example of such an app (which I made): http://www.youtube.com/watch?v=o3y1hoJCtog


Title: Re: Create a QuickProfile in Civil3D 2012 using .net
Post by: UWPMVG on October 05, 2012, 02:18:17 PM
Interesting approach! I'm going to try the same strategy.

Would it be possible to obtain a copy from part of your code? I fully understand if you donīt want to.

Thanks for your reply!
Title: Re: Create a QuickProfile in Civil3D 2012 using .net
Post by: huiz on October 05, 2012, 02:34:29 PM
I fully understand if you donīt want to.

It is commercial software, you could buy it :-)
Title: Re: Create a QuickProfile in Civil3D 2012 using .net
Post by: UWPMVG on October 09, 2012, 04:15:50 AM
I have now programmed a similar app but I need to be able to update starting and ending point of the fixed line in the alignment using vb.net.

Does anyone know how that is accomplished?

I tried using "MoveGripPointsAt" but did not managed.
Title: Re: Create a QuickProfile in Civil3D 2012 using .net
Post by: VVeli on October 09, 2012, 04:54:05 AM
Hi,
could you show the code to explain what you are try to do?
I have a short sample to create profile from surface.
This is not so secret code...  8-)
Cheers
Veli V.

Public Function CreateProfileFromSurface(ByVal alignName As String, _
                                                 ByVal surfaceName As String, _
                                                 ByVal profileName As String, _
                                                 ByVal profileStyleName As String, _
                                                 ByVal layerName As String) As AeccProfile
            Dim ed As Autodesk.AutoCAD.EditorInput.Editor = Application.DocumentManager.MdiActiveDocument.Editor
            Dim oProfile As AeccProfile
            Dim oAlign As AeccAlignment = Me.GetAlignment(alignName)
            If oAlign.Name = alignName Then
                Try
                    oProfile = oAlign.Profiles.Item(profileName)
                Catch exArg As ArgumentException
                    Debug.WriteLine("Couldnīt find profile " + profileName)
                End Try
                If oProfile Is Nothing Then
                    Dim oProfileStyle As AeccProfileStyle = Me.GetOrCreateProfileStyle(profileStyleName)
                    Dim oSurface As IAeccSurface = Me.GetSurfaceByName(surfaceName)
                    If oSurface.Name = surfaceName Then
                        oProfile = oAlign.Profiles.AddFromSurface(profileName, AeccProfileType.aeccExistingGround, oProfileStyle.Name, oSurface.Name, oAlign.StartingStation, oAlign.EndingStation, layerName)
                    Else
                        ed.WriteMessage(vbLf + "Surface " + surfaceName + " doesnīt exist.")
                    End If
                Else
                    ed.WriteMessage(vbLf + "Profile " + profileName + " already exist.")
                End If
            End If
            Return oProfile
        End Function
Title: Re: Create a QuickProfile in Civil3D 2012 using .net
Post by: UWPMVG on October 09, 2012, 06:10:16 AM
I want to change the coordinates of previous added fixed line. The Alignment only consists of one fixed line. I donīt want to erase the entity first and then create a new one.

Code: [Select]
Dim oAlignmentId As ObjectId = ObjectId.Null

                Try
                    oAlignmentId = Alignment.Create(m_doc, "SectionViewer", "Site 1", "0", "Linjeberäkning - utskrift", "Visa inte - etiketter")
                Catch ex As System.Exception
                    ed.WriteMessage(ex.Message + Convert.ToChar(10))
                    Return
                End Try

                If (oAlignmentId.IsNull) Then
                    ed.WriteMessage("Sample Alignment:  Error creating alignment: " & Err.Description & " - " & Err.Number & Convert.ToChar(10))
                    Return
                End If

            sectionAlignment = trans.GetObject(oAlignmentId, AcDb2.OpenMode.ForWrite)

            Dim point1 As Point3d = New Point3d(start_easting, start_northing, 0.0)
            Dim point2 As Point3d = New Point3d(end_easting, end_northing, 0.0)Try
                   
            Dim oAlignmentTangent As AlignmentLine
                    oAlignmentTangent = sectionAlignment.Entities.AddFixedLine(point1, point2)
                Catch ex As System.Exception
                    ed.WriteMessage(ex.Message + Convert.ToChar(10))
                    Return
                End Try
Title: Re: Create a QuickProfile in Civil3D 2012 using .net
Post by: VVeli on October 09, 2012, 08:56:20 AM
I have no other solution to do that. This example using COM API.
vertexes have the points that are going to change for alignment.
If you find other solution I like to hear that too.  :-D

vertexes = New Point3dCollection(...) 'Init points to this collection
Dim count As Integer = 0
        Dim i As Integer = 0
        Dim pt1, pt2 As Point3d

        Dim strStat As Double = oAlignment.StartingStation
        Dim endStat As Double = oAlignment.EndingStation
        oAlignment.Entities.RemoveAll()
       
        pt1 = vertexes(i)
        count = vertexes.Count
        For i = 1 To count - 1
            pt2 = vertexes(i)
            oAlignment.Entities.AddFixedLine1(pt1.ToArray(), pt2.ToArray())
            pt1 = pt2
        Next
        oAlignment.Update()