.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fillet two lines in .net

2 REPLIES 2
Reply
Message 1 of 3
Giri_kani
1723 Views, 2 Replies

Fillet two lines in .net

I need to fillet below lines in .net

 

UnFilletLines.png

 

as 

 FilletLines.png

Iam having the entities list..How to fillet those lines with radius using .net?

 

Please guide me if you know...

 

 

 

Advance thanks

2 REPLIES 2
Message 2 of 3

Hi,

 

As far as I know, there is no feature in the API that does that kind of job for you. You would need to come up with your custom logic to modify the lines and insert an arc at the correct position based on your fillet radius.

 

Maybe somebody can provide it's own code to achieve that.

 

One solution would be to invoke _FILLET command programmatically and pass in the handles of the lines you wish to fillet. Let me know if you are interested in that approach.

 

Sorry for not being more helpful at the moment.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
Allen_Hart
in reply to: Giri_kani

Here is a function I wrote recently to fillet two lines.  It seems more complicated then it should be.  Maybe it will help.

 

Allen

 

        Private Function FilletTwoLines(ByRef oLine1 As Line, ByRef oPickPt1 As Point3d,
                                        ByRef oLine2 As Line, ByRef oPickPt2 As Point3d,
                                        ByVal oFilletRadius As Double,
                                        ByRef oDataBase As Database) As Boolean

            'Determine the intersection point of given lines
            Dim oPC As New Point3dCollection()
            oLine1.IntersectWith(oLine2, Intersect.ExtendBoth, oPC, New System.IntPtr, New System.IntPtr)
            If Not oPC.Count = 1 Then
                Application.ShowAlertDialog("Lines are colinear or do not intersect.")
                Return False
            End If
            Dim oIP As Point3d = oPC(0)    'the intersect point

            'Make sure the line start point is at the intersect point.
            'Assume the end point nearest the user pick point should be the start point.
            oLine1.UpgradeOpen()
            If oLine1.StartPoint.DistanceTo(oPickPt1) > oLine1.EndPoint.DistanceTo(oPickPt1) Then
                oLine1.ReverseCurve()
            End If
            If Not oLine1.StartPoint.IsEqualTo(oIP) Then
                oLine1.StartPoint = oIP
            End If

            oLine2.UpgradeOpen()
            If oLine2.StartPoint.DistanceTo(oPickPt2) > oLine2.EndPoint.DistanceTo(oPickPt2) Then
                oLine2.ReverseCurve()
            End If
            If Not oLine2.StartPoint.IsEqualTo(oIP) Then
                oLine2.StartPoint = oIP
            End If

            'Determine the distance from the start point to the tangent point of fillet arc
            Dim oVec1 As Vector3d   'the direction vector of the line (from its start point)
            Dim oVec2 As Vector3d
            Dim oAB As Double       'the angle between the two vectors
            Dim oSideC As Double    'distance from Intesect point to tangent point of fillet arc
            oVec1 = oLine1.Delta
            oVec2 = oLine2.Delta
            oAB = oVec1.GetAngleTo(oVec2)
            oSideC = oFilletRadius / Math.Tan(oAB / 2)

            'Move each line start point to the tangent point
            Dim oTP1 As Point3d     'the tangent point of the fillet arc
            Dim oTP2 As Point3d
            oTP1 = oLine1.GetPointAtDist(oSideC)
            oLine1.StartPoint = oTP1
            oTP2 = oLine2.GetPointAtDist(oSideC)
            oLine2.StartPoint = oTP2

            'Determine the center point of fillet arc by
            ' constructing a perpindicular from each line then finding the intersection point
            Dim oPerp1 As Line3d = New Line3d(oTP1, oVec1.GetPerpendicularVector)
            Dim oPerp2 As Line3d = New Line3d(oTP2, oVec2.GetPerpendicularVector)
            Dim oCP As Point3d() = oPerp1.IntersectWith(oPerp2)

            'Draw a construction circle at the center point of the fillet arc
            Dim oCircle As CircularArc3d = New CircularArc3d(oCP(0), New Vector3d(0, 0, 1), oFilletRadius)

            'Find the point on the circle where it crosses a construction line from oIP to oCP
            Dim oPOC As Point3d() = oCircle.IntersectWith(New LineSegment3d(oIP, oCP(0)))

            'Draw a construction arc through the point and each tangent point
            Dim oArc As CircularArc3d = New CircularArc3d(oTP1, oPOC(0), oTP2)

            'Convert the construction arc into a real arc
            Dim oFilletArc As New Arc
            oFilletArc = Curve.CreateFromGeCurve(oArc)
            oFilletArc.Layer = oLine1.Layer

            If AddToModelSpace(oDataBase, oFilletArc).IsNull Then
                Return False
            End If

            Return True
        End Function

        Private Function AddToModelSpace(ByVal DBIn As Database, ByVal EntityIn As Entity) As ObjectId
            Using oTM As Transaction = DBIn.TransactionManager.StartTransaction
                Dim oBT As BlockTable = DBIn.BlockTableId.GetObject(OpenMode.ForRead)
                Dim oModelSpace As BlockTableRecord = oBT(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)
                oModelSpace.AppendEntity(EntityIn)
                oTM.AddNewlyCreatedDBObject(EntityIn, True)
                oTM.Commit()
                Return EntityIn.ObjectId
            End Using
        End Function

 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost