2017-03-26 1 views
0

사용자 입력에 따라 포인트에서 시작하는 리더를 만들고 나서 두 번째 포인트는 x & y에서 50 유닛 떨어져 있습니다. 나는 개념이 작동해야한다고 생각하지만 배열 값에 50을 추가하는 데 문제가 있습니다.개별 배열 값에 값 추가하기

Set annotationObject = Nothing 
Dim StartPoint As Variant 
leaderType = acLineWithArrow 
Dim Count As Integer 
Dim points(0 To 5) As Double 

StartPoint = ACAD.ActiveDocument.Utility.GetPoint(, "Specify insertion point") 
MsgBox StartPoint(0) & "," & StartPoint(1) & "," & StartPoint(2) 

StartPoint(3) = StartPoint(0) + 50 
StartPoint(4) = StartPoint(1) + 50 
StartPoint(5) = StartPoint(2) 

Set leader1 = ACAD.ActiveDocument.ModelSpace.AddLeader(StartPoint, annotationObject, leaderType) 
+1

당신이 오류가 않고 오류를 얻을 때 시작점의 UBound 함수는 무엇인가 :

이 시도? –

+0

실제로 내가 범위 밖의 subscript 알려주고 라인에 그것을 얻을 StartPoint (3) = StartPoint (0) + 50 –

+0

나는 당신의 도움에 감사드립니다! 시작점과 점의 배열 사이에 섞여 있었어. –

답변

1

라인이 아래 변종 가변 시작점, 3 개 요소의 배열을 할당이 난이 난 형식 불일치를 얻고하는 것이다.

StartPoint = ACAD.ActiveDocument.Utility.GetPoint(, "Specify insertion point") 

다음 줄은 다른 요소를 StartPoint 변형에 추가하려고했습니다.

StartPoint(3) = StartPoint(0) + 50 

그러나 StartPoint가 이미 3 개의 요소가있는 단일 차원의 배열을 받았기 때문에 내부 표현이 이미 설정되어 있습니다. "Variant 변수는 저장하는 값의 내부 표현을 유지합니다 (Microsoft에서 제공)." 어떤 줄에

Dim StartPoint As Variant 
Dim LeaderPt(8) As Double 'a separate array for leader points 

'Specify insertion point 
StartPoint = ACAD.ActiveDocument.Utility.GetPoint(, "Specify insertion point") 

'-----Set points for the leader----- 
LeaderPt(0) = StartPoint(0) 
LeaderPt(1) = StartPoint(1) 
LeaderPt(2) = StartPoint(2) 

LeaderPt(3) = StartPoint(0) + 50 '2nd point x coordinate. 
LeaderPt(4) = StartPoint(1) + 50 '2nd point y coordinate. 
LeaderPt(5) = StartPoint(2) 

'add a third point so the last point of the leader won't be set to (0,0,0) 
LeaderPt(6) = LeaderPt(3) + 25  '3rd point x coordinate. Offset from second point 
LeaderPt(7) = LeaderPt(4)   '3rd point y coordinate. Same as the second point 
LeaderPt(8) = LeaderPt(5) 
'--- 


Set leader1 = ACAD.ActiveDocument.ModelSpace.AddLeader(LeaderPt, annotationObject, leaderType)