TheSwamp

Code Red => VB(A) => Topic started by: Humbertogo on March 16, 2006, 07:25:55 AM

Title: Hatch
Post 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
Title: Re: Hatch
Post by: Bryco on March 16, 2006, 10:18:40 AM
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.
Title: Re: Hatch
Post by: Humbertogo on March 16, 2006, 12:21:28 PM
Still have the err
Title: Re: Hatch
Post by: Bob Wahr on March 16, 2006, 12:36:34 PM
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?
Title: Re: Hatch
Post by: Humbertogo on March 16, 2006, 12:56:07 PM
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)
Title: Re: Hatch
Post by: Bryco on March 16, 2006, 01:21:05 PM
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)
Title: Re: Hatch
Post by: Humbertogo on March 16, 2006, 01:40:44 PM
At the end of the last arc i close the loop (Optional blnHatch As Boolean = False)
Title: Re: Hatch
Post by: Bryco on March 16, 2006, 04:02:20 PM
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