TheSwamp
Code Red => VB(A) => Topic started by: Humbertogo on March 16, 2006, 07:25:55 AM
-
I use this function to create Arc.
I draw 3 arc an look fin but when i AppendOuterLoop the array i get err.
Can someone tell my what i do wrong..?
Function addArc(center() As Double, dRadius As Double, _
startAngle As Double, _
endAngle As Double, _
Group As String, _
strlayer As String, _
Pattern As String, _
Color As Integer, Optional blnHatch As Boolean = False)
Dim outerLoop() As AcadEntity
Dim Objhatch As AcadHatch
Dim patternName As String
Dim PatternType As Long
Dim bAssociativity As Boolean
' Define the hatch
patternName = "ANSI32"
PatternType = 0
bAssociativity = True
ReDim Preserve outerLoop(0 To Count) As AcadEntity
'Set objArc = ThisDrawing.ModelSpace.addArc(center, dRadius, startAngle, endAngle)
Set outerLoop(Count) = ThisDrawing.ModelSpace.addArc(center, dRadius, startAngle, endAngle)
outerLoop(Count).Color = Color
outerLoop(Count).layer = CheckLayer(strlayer)
outerLoop(Count).Linetype = CheckLineType(Pattern)
outerLoop(Count).Update
If Group <> "" Then Call Add2Group(Group, outerLoop(Count))
If blnHatch Then
' Create the associative Hatch object
Set Objhatch = ThisDrawing.ModelSpace.AddHatch(PatternType, patternName, bAssociativity)
' Append the outer loop to the hatch object, and display the hatch
Objhatch.AppendOuterLoop (outerLoop)
Objhatch.Evaluate
End If
Count = Count + 1
End Function
-
Try Dim outerLoop() As AcadEntity at the modular level, like you have done with the count. It is getting redimmed and therefore empty each time.
-
Still have the err
-
What error are you getting?
What line are you getting the error on?
Where/when/how is Count being Dimmed?
Is Count being assigned an initial value of 0 before this function is run?
-
I get the err at line Objhatch.AppendOuterLoop (outerLoop)
eer. run time err '-2145386493 (80200003)';
invalid input
The couter is working ok (Dim Count As Long)
-
The outer loop must be closed .
Objhatch.AppendOuterLoop (outerLoop) should be in the calling sub or a flag should be created when the outerloop is closed then do Objhatch.AppendOuterLoop (outerLoop)
dim isClosed as boolean
if isClosed then Objhatch.AppendOuterLoop (outerLoop)
-
At the end of the last arc i close the loop (Optional blnHatch As Boolean = False)
-
Oh yeah.
With
Private Count As Integer
Private outerLoop() As AcadEntity
at the modular level and a valid hatch pattern the funtion works for me. acad2006