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: 

Missing the parameter "isclockwise " using Civil3D API

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
zhaojinmao
1263 Views, 11 Replies

Missing the parameter "isclockwise " using Civil3D API

I want to add fixedSpiral to the alignment using c#.net by calling Civil3D API.

7.png

 

 

 

I need to enter multiple parameters.  (shown in the screenshot below)

1)

8.png

2 )

9.png

 3)

10.png

 4)

11.png

 5)

12.png

 They are( 1)previousEntity,(2)spiralCurveType,(3)spiral direction(clockwise or counterclockwise),(4)spiral length, (5)spiral radius.

 

 

 

 

 

 

 In the Civil3D API, 5 methods are provided. (shown in the screenshot below)

1).2.png

 2).3.png

 

3).4.png

 

4).5.png

 

 

5).6.png

 According to the parameters in Civil3D, I should choose the second method in API.But  the parameter  "isclockwise "  is missing in this method, if i ignore it, just enter previousEntityId, radius,length,spiralCurveType,spiralDefinition,

the fixed spiral generated by programming is wrong,how can I solve this problem ?

 

 

 

Tags (1)
11 REPLIES 11
Message 2 of 12
465340553
in reply to: zhaojinmao

能否自己计算出spiralPI,

然后使用这个方法来实现?

public AlignmentSpiral AddFixedSpiral(
	int previousEntityId,
	Point3d startPoint,
	Point3d spiralPI,
	double radius,
	double length,
	SpiralCurveType spiralCurveType,
	bool isClockwise,
	SpiralType spiralDefinition
)

 

王磊
您认为此帖子是否有用?欢迎为此帖点赞。
您的问题是否已得到解答?请点击“接受解答”按钮。

EESignature

Message 3 of 12
zhaojinmao
in reply to: 465340553

感谢,但已尝试过这种方法,对于缓和曲线接缓和曲线这种情况,只能生成第一段缓和曲线,第二段缓和曲线无法生成。

Message 4 of 12
neyton_
in reply to: zhaojinmao

hello, i also had problems with that.


to solve, I simply created a temporary line before the spiral, thus obtaining an ID. With this id, it creates the spiral in the simplest methods

 

Of course it will depend on whether you are drawing a spiral with an initial radius greater or less than the final radius. If the starting radius is infinite, use a temporary straight line at the beginning. If it's any radius, prefer a temporary arc

 

After the spiral is drawn, erase the temporary line or arc

Message 5 of 12
zhaojinmao
in reply to: neyton_

Thank you!

But you may have misunderstood me.I want to draw an alignment end with two continuous spirals using .NET API(shown in the figure below),I can't do it with existing API(I tried different ways).Do you have any good suggestions or methods?

Image 2.png

Message 6 of 12
neyton_
in reply to: zhaojinmao

Try this:

 

Dim alinId As ObjectId = Alignment.Create(CivilDOC,
Alignment.GetNextUniqueName("test"),
ObjectId.Null,
DB.LayerZero,
CivilDOC.Styles.AlignmentStyles.First,
CivilDOC.Styles.LabelSetStyles.AlignmentLabelSetStyles.First)

 

Dim alin As Alignment = alinId.GetObject(OpenMode.ForWrite)

 

Dim line1 = alin.Entities.AddFixedLine(New Point3d(100, 100, 0), New Point3d(200, 100, 0))

Dim spi1 = alin.Entities.AddFloatSpiral(line1.EntityId, 100.0#, 30.0#, True, Autodesk.Civil.SpiralType.Clothoid)

Dim line2 = alin.Entities.AddFixedLine(New Point3d(100, 50, 0), New Point3d(200, 50, 0))

Dim spi2 = alin.Entities.AddFloatSpiral(line2.EntityId, 100.0#, 30.0#, False, Autodesk.Civil.SpiralType.Clothoid)

 

instead of using the AddFixedSpiral method, use AddFloatSpiral

Message 7 of 12
lu_an_jie
in reply to: zhaojinmao

Could you give some more details. What is wrong? Does it throw an exception? Does it produce wrong geometry.

It would be helpful to have the code and the alignment sample.

Could you archive it manually?

Regards

Andreas Luka (Lu An Jie)

http://www.luka-consult.de

Creator of the LX-Stair App for Civil 3D
Message 8 of 12
lu_an_jie
in reply to: lu_an_jie

You can mimic the counterclockwise be following process:

1. get the endpoint from the entity before (P1)

2. create a temporary fixed spiral  clockwise and get the endpoint (P2), delete the entity

3. create a temporary fixed tangent (whatever length), get the endpoint (P3) , delete the entity 

4. mirror the P2 with axis P1 to P2 as P4

5. Create fixed spiral from P1 to  P4

 

You could get the mirror axis also from the end point and direction of the entity before's last subentity

Regards

Andreas Luka (Lu An Jie)

http://www.luka-consult.de

Creator of the LX-Stair App for Civil 3D
Message 9 of 12
zhaojinmao
in reply to: neyton_

Thank you !

I try to Add Float Spiral to the alignment,the code as follows(C#):

                                                        ....

                Point3d p1 = new Point3d(518449.1529, 3014242.9764, 0);
                Point3d p2 = new Point3d(518467.7166, 3014023.4374, 0);
                aAlignmentCircle1=oCurAlignment.Entities.AddFixedCurve(p1, p2, 150, false);
                sAlignmentSpiral1=oCurAlignment.Entities.AddFloatSpiral(aAlignmentCircle1.EntityId,150, 134.5379, false, Autodesk.Civil.SpiralType.Clothoid);
                oCurAlignment.Entities.AddFloatSpiral(sAlignmentSpiral1.EntityId, 800, 91.125, true, Autodesk.Civil.SpiralType.Clothoid);

The circle could be drawn,but the spiral couldn't be drawn.Civil 3D displays :No solution!

Image 1.png

 

 

Message 10 of 12
zhaojinmao
in reply to: lu_an_jie

Thank you!

I want to draw the alignment using .NET API as shown in the figure below.

Image 3.png

The parameters are shown in the figure below:

Image 2.png

 The code is shown in the figure below:

                                 .....

                Point3d p1 = new Point3d(535541.148358431, 3927421.86155505, 0);
                Point3d p2 = new Point3d(535676.110015142, 3927479.89070189, 0);
                aAlignmentCircle1 =oCurAlignment.Entities.AddFixedCurve(p1, p2, 200, true);
                sAlignmentSpiral1=oCurAlignment.Entities.AddFixedSpiral(aAlignmentCircle1.EntityId,200, 45,SpiralCurveType.OutCurve, Autodesk.Civil.SpiralType.Clothoid);
                oCurAlignment.Entities.AddFixedSpiral(sAlignmentSpiral1.EntityId, 100, 45, SpiralCurveType.InCurve, Autodesk.Civil.SpiralType.Clothoid);

the result as follows:

Image 4.png

the second spiral is incorrect!

 

 

 

 

 

Message 11 of 12
lu_an_jie
in reply to: zhaojinmao

Please provide next time your code in a executable and testable form and not only a snippet. That would reduce the effort for the people looking at your problem.

 

Here is my solution:

I call the method that @465340553 suggested. I create temporarily a floating line, so I can find the second point (PI) of the second spiral.  

 

// (C) Copyright 2021 by  Andreas Luka (Lu An Jie)
//
using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;

using Autodesk.Civil;
using Autodesk.Civil.DatabaseServices;


[assembly: CommandClass(typeof(ALC_AlignmentAddEntity.MyCommands))]

namespace ALC_AlignmentAddEntity
{
    public class MyCommands
    {
        public static ObjectId SelectAlignment()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            ObjectId result = ObjectId.Null;

            PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect alignment: ");
            entOpts.SetRejectMessage("...not an Alignment, try again!:");
            entOpts.AddAllowedClass(typeof(Alignment), true);

            PromptEntityResult entRes = ed.GetEntity(entOpts);

            if (entRes.Status == PromptStatus.OK) result = entRes.ObjectId;
            return result;
        }




        [CommandMethod("ALCAddFixedSpiralCCW")]
        public void ALCAddFixedSpiralCCW()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = Application.DocumentManager.MdiActiveDocument.Database;

            ObjectId alignId = SelectAlignment();
            if (alignId == ObjectId.Null) return;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                try
                {
                    
                    Alignment align = (Alignment)alignId.GetObject(OpenMode.ForRead);
                    AlignmentEntity lastEntity = align.Entities.GetEntityByOrder(align.Entities.Count - 1);


                    AlignmentSpiral firstSpiral = align.Entities.AddFixedSpiral(lastEntity.EntityId, 200, 45, SpiralCurveType.OutCurve, SpiralType.Clothoid);

                    Point3d p0 = new Point3d (firstSpiral.EndPoint.X, firstSpiral.EndPoint.Y,0);

                    // temporary floating line for finding PI of the spiral
                    // need r as double to avoid ambigiuenes overload
                    AlignmentLine tempTangent = align.Entities.AddFloatingLine(firstSpiral.EntityId, 45.0);
                    Point3d pI = new Point3d (tempTangent.EndPoint.X, tempTangent.EndPoint.Y,0);
                    align.Entities.Remove(tempTangent);
                                      

                    AlignmentSpiral secondSpiral = align.Entities.AddFixedSpiral(firstSpiral.EntityId, 
                        p0, pI, 100, 45, SpiralCurveType.InCurve, false, SpiralType.Clothoid);

                    tr.Commit();

                }
                catch (Autodesk.AutoCAD.Runtime.Exception ex)
                {
                    ed.WriteMessage(ex.Message);

                }
            }
        }

    }
}

 

Regards

Andreas Luka (Lu An Jie)

http://www.luka-consult.de

Creator of the LX-Stair App for Civil 3D
Message 12 of 12
zhaojinmao
in reply to: lu_an_jie

As you suggested, it worked!Thank you very much!!!

 

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report