Public Sub Vhvt() On Error GoTo Err_Vhvt Dim P1 As Variant Dim a As Double P1 = ThisDrawing.Utility.GetPoint(, "Chon mot diem: ") a = ThisDrawing.Utility.GetDistance(, "nhap canh cua hinh vuong: ") ' Xac dinh toa do cac dinh M,N,K con lai cua hinh vuong Dim M(0 To 2) As Double Dim N(0 To 2) As Double Dim K(0 To 2) As Double M(0) = P1(0) + a: M(1) = P1(1): M(2) = P1(2) N(0) = P1(0) + a: N(1) = P1(1) + a: N(2) = P1(2) K(0) = P1(0): K(1) = P1(1) + a: K(2) = P1(2) ' ve cac canh cua hinh vuong Dim canh1 As AcadLine, canh2 As AcadLine, canh3 As AcadLine, canh4 As AcadLine Set canh1 = ThisDrawing.ModelSpace.AddLine(P1, M) Set canh2 = ThisDrawing.ModelSpace.AddLine(M, N) Set canh3 = ThisDrawing.ModelSpace.AddLine(N, K) Set canh4 = ThisDrawing.ModelSpace.AddLine(K, P1) ' thay doi huong nhin trong toa do 3D Dim NewDirection(0 To 2) As Double NewDirection(0) = 1 NewDirection(1) = -1 NewDirection(2) = 1 ThisDrawing.ActiveViewport.Direction = NewDirection ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport Exit_Vhvt: Exit Sub Err_Vhvt: MsgBox "Loi, khong thuc hien duoc!", vbCritical, "Thong bao" Resume Exit_Vhvt ZoomAll End Sub