create a tangent without curves using the API

create a tangent without curves using the API

daniel_rosell_moreno
Participant Participant
1,273 Views
18 Replies
Message 1 of 19

create a tangent without curves using the API

daniel_rosell_moreno
Participant
Participant

Good morning, I've been trying all morning to find a way to do the following using the API:

  1. I have a profile view with 1 surfaces
  2. I select the profile view and select "profile creation tools"
  3. I leave the default settings and press accept
  4. The tools appear and I select "Draw tangent without curves"
  5. I select the points at which I want the tangent to be created (which coincide with the intersection of the surface with some vertical lines of the profile view)

I have something like this:

Captura de pantalla 2023-02-27 123837.png

 

My question is if the API is capable of doing that?

0 Likes
Accepted solutions (1)
1,274 Views
18 Replies
Replies (18)
Message 2 of 19

Jeff_M
Consultant
Consultant
I'm not quite sure what you are asking. The API allows you to create a profile with tangents based on station and elevation.
Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 3 of 19

Jeff_M
Consultant
Consultant

You can query the existing ground profile at specific stations for the elevation which can then be used to create the tangents.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 4 of 19

hosneyalaa
Advisor
Advisor

Hi @daniel_rosell_moreno 

Can you attached example drawing for your ideas 

0 Likes
Message 5 of 19

daniel_rosell_moreno
Participant
Participant

I attach a small video showing what I want to do

 

Thanks again for your answers

0 Likes
Message 6 of 19

hosneyalaa
Advisor
Advisor
Accepted solution

HI @daniel_rosell_moreno 

 

CAN YOU SEE THIS  WRITE BY @lu_an_jie 

 

 

 

/// https://forums.autodesk.com/t5/civil-3d-customization/creating-profile-from-file/m-p/8187626

public static void CreateProfileNoSurface(Alignment oAlignment)
        {
            CivilDocument civDoc = CivilApplication.ActiveDocument;

            using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
            {

                // use the same layer as the alignment
                ObjectId layerId = oAlignment.LayerId;

                // get the standard style and label set 
                // these calls will fail on templates without a style named "Standard"
                ObjectId styleId = civDoc.Styles.ProfileStyles["Standard"];
                ObjectId labelSetId = civDoc.Styles.LabelSetStyles.ProfileLabelSetStyles["Standard"];

                // create a new empty profile
                ObjectId oProfileId = Profile.CreateByLayout("MyProfile", oAlignment.Id, layerId, styleId, labelSetId);

                // Now add the entities that define the profile.
                Profile oProfile = ts.GetObject(oProfileId, OpenMode.ForRead) as Profile;

                Point2d startPoint = new Point2d(oAlignment.StartingStation, 40);
                Point2d endPoint = new Point2d(oAlignment.EndingStation, -70);
                ProfileTangent oTangent1 = oProfile.Entities.AddFixedTangent(startPoint, endPoint);

                ts.Commit();
            }
        }

 

 

0 Likes
Message 7 of 19

daniel_rosell_moreno
Participant
Participant
Lo acabo de ver y probar el codigo que me has pasado y consigue hacer los extremos pero no los puntos intermedios 😞

Gracias de todos modos
0 Likes
Message 8 of 19

Jeff_M
Consultant
Consultant

@daniel_rosell_moreno The code @hosneyalaa posted is an example of how to create a profile. It was not meant to be a solution to what you asked. Take that code and add the missing parts by finding the elevation at the midpoint of the alignment and use that for the end of the first segment and the start of the last segment.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 9 of 19

hosneyalaa
Advisor
Advisor

 

As explained @Jeff_M 

You must make changes to the code As you want

And if you encounter a problem

You should attach some code And an example drawing

0 Likes
Message 10 of 19

daniel_rosell_moreno
Participant
Participant

ok, i thing i have already have the tangent, but, how i  show the tangent in the profile view?

 

0 Likes
Message 11 of 19

Jeff_M
Consultant
Consultant
If there is a ProfileView existing for the alignment, the new profile will automatically be displayed in it.
Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 12 of 19

daniel_rosell_moreno
Participant
Participant

Ok already works, thanks for your help

0 Likes
Message 13 of 19

daniel_rosell_moreno
Participant
Participant

anyway, the previous instruction creates a profile for me that follows the tangent, but it is not a tangent as such.
In image 1, you see the type of tangent I want, which you can move its central vertex independently of the extremes. It also shows its slope.

daniel_rosel_0-1678104891695.png

 


In the image 2 is the tangent that I have created using the code of @lu_an_jie

daniel_rosel_1-1678104979535.png

 

0 Likes
Message 14 of 19

Anonymous
Not applicable

Just look at the API documentation under ProfileEntityCollection Members and you will find all possibilities for adding entities to your profile.

Adding the entities should reflect your manual workflow, first add the two fixed tangents with start- and endpoint for the straight entities and then you can use AddFreeCircularCurve to connect. Before you can do this, you may need to calculate and add the intersecting point of your fixed elements and add to the profile with AddPVI, AddCircularCurve has three different version for creating curve based on PassTroughPoint, Length or Radius.

You need o provide a clearer description of your process and goals.

 

Andreas (aka lu_an_jie) 

0 Likes
Message 15 of 19

Jeff_M
Consultant
Consultant

@daniel_rosell_moreno As I have previously said, you need to get the elevation of the existing ground at the midpoint of the alignment, then use that station/elevation for the end of the first tangent and the start of the second tangent. The sample code by @Anonymous only has one tangent as your image shows. It is up to you to modify the code to create the first tangent where you want it and to add the second tangent. 

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 16 of 19

hosneyalaa
Advisor
Advisor

Can you attached example drawing 

0 Likes
Message 17 of 19

Anonymous
Not applicable
I think, the workflow is:
1. Create two fixed tangents,
2. Calculate the POI for the curve and add it to profile
3. Add FreeCurveByPOIand Radius (or Length or PassThruPoint)

I am not aware about any API function that just take two entities and a radius. Do you a better approach?
0 Likes
Message 18 of 19

Jeff_M
Consultant
Consultant

@Anonymous The OP is not trying to add a vertical curve, that I can tell. Just merely 2 tangents with the grade break at the middle of the alignment and at the elevation of the EG at that point. 

 

Another way to do this, create the Profile, add the Start PI, End PI and Middle PI.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 19 of 19

daniel_rosell_moreno
Participant
Participant

in the end the error was my fault, sorry for the inconvenience

0 Likes