Cad] 변곡 강연선(Tendon) 배치 VBA

Cad] 변곡 강연선(Tendon) 배치 VBA

 

 

강연선(Tendon)배치시, 변곡선 구간은 2개의 원으로 만나는 점이 꺽이지 않아야 합니다. 두 원의 접선이 일치해야 합니다.

두 원이 만나는 점(접선이 일치하는)은 아래점과 윗점의 중앙에 생기며 식은 다음과 같습니다. a가 원의 반지름입니다.

VBA 코드입니다.
Sub te2()
 
    Dim Pnt1, Pnt2 As Variant '2points
    
    Pnt1 = ThisDrawing.Utility.GetPoint(, "1st Point")
    Pnt2 = ThisDrawing.Utility.GetPoint(, "2nd Point")
        
    Dim l, h As Double
       
    l = Pnt2(0- Pnt1(0)
    h = Pnt2(1- Pnt1(1)
    
    
    Dim a As Double 'circle R
    
    a = (h * h + l * l) / (4 * h)
               
    Dim circlePnt1(2As Double
    Dim circlePnt2(2As Double
    
    circlePnt1(0= Pnt1(0)
    circlePnt1(1= Pnt1(1+ a
    
    circlePnt2(0= Pnt2(0)
    circlePnt2(1= Pnt2(1- a
    
    Dim m As Double 'inclined
   
    m = (h / 2 - a) / (l / 2)
    
    Dim strA, endA As Double
    
    strA = 3.14159265358979 * 1.5
    endA = Atn(m) + 2 * 3.14159265358979
    
    Dim strA2, endA2 As Double
    
    strA2 = 3.14159265358979 * 0.5
    endA2 = Atn(m) - 3.14159265358979
    Dim arcObj As AcadArc
    
    If l > 0 And h > 0 Then
        Set arcObj = ThisDrawing.ModelSpace.AddArc(circlePnt1, a, strA, endA)
        Set arcObj = ThisDrawing.ModelSpace.AddArc(circlePnt2, a, strA2, endA2)
    Else
        MsgBox "Only from left & bottom to right & Up!!!"
    
    End If
    
End Sub
 
cs

command line에서 te2 명령어로 사용할 수 있는 텍스트입니다.

 

(defun c:te2()(command "-vbarun" "te2")(princ))

댓글

Designed by JB FACTORY