Function overloading

Function overloading

parikhnidi
Advocate Advocate
324 Views
1 Reply
Message 1 of 2

Function overloading

parikhnidi
Advocate
Advocate

Hi,

 

I have a function to draw a plan of a steel member as follows -

 

Public Function DrawPlan(pLocation As Point3d, pAngle As Double) As Boolean
     Dim mPi As Double = 4 * Atan(1)
     Dim mResult As Boolean
     Dim mLineType As String

     mLineType = "HIDDEN"

     mResult = Rectangle(pLocation, pAngle, MyBase.Length, MyBase.MemberWidth)
     mResult = DrawParallelLines(pLocation, pAngle, MyBase.Length, MyBase.WebThickness, mLineType)

     Return mResult
End Function

The rectangle function draws outline of steel member and DrawParallelLines function draws web with linetype HIDDEN.

 

Now I realize that I may need another variation of the same function as follows -

Public Function DrawPlan(pPoint1 As Point3d, pPoint2 As Point3d) As Boolean
     Dim mPi As Double = 4 * Atan(1)
     Dim mResult As Boolean
     Dim mLineType As String

     mLineType = "HIDDEN"
     'Replace first three parameters in following two functions as follows
     'Calculate pLocation as mid point of pPoint1 and pPoint2
     'Calculate pAngle as AngleFromXAxis for pPoint1 and pPoint2
     'Calculate MyBase.Length as distance between pPoint1 and pPoint2
     mResult = Rectangle(pLocation, pAngle, MyBase.Length, MyBase.MemberWidth)
     mResult = DrawParallelLines(pLocation, pAngle, MyBase.Length, MyBase.WebThickness, mLineType)

     Return mResult
End Function

My question is how do I summon the first function in the second variation.

 

Nimish

0 Likes
325 Views
1 Reply
Reply (1)
Message 2 of 2

norman.yuan
Mentor
Mentor

The overload function with 2 points as inputs only needs to do the calculations of location and angle and then call the first function:

 

Public Function DrawPlan(point1 As Point3d, point2 As Point3d) As Boolean

  Dim location As Point3d = CalculationLocation(point1, point2)

  Dim angle As Double = CalculateAngle(point1, point2)

  Return DrawPlan(locaton, angle)

End Function

 

HTH

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes