AddHatch

AddHatch

Anonymous
Not applicable
457 Views
4 Replies
Message 4 of 5

AddHatch

Anonymous
Not applicable
My first attempt at Hatching. Took this right out of the example. The
acPLine displays correctly. I can manually hatch it. Errors out at the
line "Set HatchObj =" with "object doesn't support this property or
method". Can anyone spot my error?

Thanks, Don

Set acPLine = ac.ActiveDocument.ModelSpace.AddLightWeightPolyline(Data)
acPLine.Color = acBlue
acPLine.Closed = True

'Create the outer boundary for the hatch:
Dim OuterLoop(0 To 0) As AcadEntity
Set OuterLoop(0) = acPLine

'Define the hatch:
Dim HatchObj As AcadHatch
Dim PatternType As AcPatternType
Dim PatternName As String
Dim Associativity As Boolean

PatternType = acHatchPatternTypePreDefined
PatternName = "ANSI31"
Associativity = False
Set HatchObj = ac.ModelSpace.AddHatch(PatternType, PatternName,
Associativity)
'Append the Outer Loop:
HatchObj.AppendOuterLoop (OuterLoop)
HatchObj.Evaluate
0 Likes
458 Views
4 Replies
Replies (4)
Message 1 of 5

Anonymous
Not applicable
Is ac a reference to the Application or the ActiveDocument? ModelSpace can
be fond in a document object, not the application object. Try this:
ac.ActiveDocument.ModelSpace.AddHatch

--
Visit me at: http://www2.stonemedia.com/franko

"Donald B. Larson" wrote in message
news:88v8c9$7te7@adesknews2.autodesk.com...
> My first attempt at Hatching. Took this right out of the example. The
> acPLine displays correctly. I can manually hatch it. Errors out at the
> line "Set HatchObj =" with "object doesn't support this property or
> method". Can anyone spot my error?
>
> Thanks, Don
>
> Set acPLine = ac.ActiveDocument.ModelSpace.AddLightWeightPolyline(Data)
> acPLine.Color = acBlue
> acPLine.Closed = True
>
> 'Create the outer boundary for the hatch:
> Dim OuterLoop(0 To 0) As AcadEntity
> Set OuterLoop(0) = acPLine
>
> 'Define the hatch:
> Dim HatchObj As AcadHatch
> Dim PatternType As AcPatternType
> Dim PatternName As String
> Dim Associativity As Boolean
>
> PatternType = acHatchPatternTypePreDefined
> PatternName = "ANSI31"
> Associativity = False
> Set HatchObj = ac.ModelSpace.AddHatch(PatternType, PatternName,
> Associativity)
> 'Append the Outer Loop:
> HatchObj.AppendOuterLoop (OuterLoop)
> HatchObj.Evaluate
>
>
>
0 Likes
Message 2 of 5

Anonymous
Not applicable
Frank,

Doh! That's it. The VBA procedures are in Excel, not AutoCad. So I've
defined:
Public ac As AcadApplication

So ac.ActiveDocument.ModelSpace.AddHatch is correct. Should'a typed it out
& the help boxes would have shown me this.

Trouble you with another?

PatternType = acHatchPatternTypePreDefined
PatternName = "EARTH"
Associativity = True
Set HatchObj = ac.ActiveDocument.ModelSpace.AddHatch(PatternType,
PatternName, Associativity)
'Append the Outer Loop:
HatchObj.AppendOuterLoop (OuterLoop)
HatchObj.PatternScale = 20
HatchObj.Evaluate

Errors at HatchObj.Evaluate with "pattern too dense". Doesn't seem to apply
the PatternScale Property. Any ideas?

Thanks again, Don
0 Likes
Message 3 of 5

Anonymous
Not applicable
I must confess, I've never done a hatch in VBA but if I was doing this
manually, I would set the scale prior to evaluating the hatch (take a look
at the hatch dialog to see what I'm talking about). Perhaps you should set
your PatternScale immediately after creating the hatch object.

--
Get free software and more at http://www2.stonemedia.com/franko

"Donald B. Larson" wrote in message
news:8915dp$coe19@adesknews2.autodesk.com...
> Frank,
>
> Doh! That's it. The VBA procedures are in Excel, not AutoCad. So I've
> defined:
> Public ac As AcadApplication
>
> So ac.ActiveDocument.ModelSpace.AddHatch is correct. Should'a typed it
out
> & the help boxes would have shown me this.
>
> Trouble you with another?
>
> PatternType = acHatchPatternTypePreDefined
> PatternName = "EARTH"
> Associativity = True
> Set HatchObj = ac.ActiveDocument.ModelSpace.AddHatch(PatternType,
> PatternName, Associativity)
> 'Append the Outer Loop:
> HatchObj.AppendOuterLoop (OuterLoop)
> HatchObj.PatternScale = 20
> HatchObj.Evaluate
>
> Errors at HatchObj.Evaluate with "pattern too dense". Doesn't seem to
apply
> the PatternScale Property. Any ideas?
>
> Thanks again, Don
>
>
>
0 Likes
Message 4 of 5

Anonymous
Not applicable
One other thing: depending on the size of your loops, a scale of 20 may
actually be too small. If my first tip doesn't work, try using a larger
scale.

--
Get free software and more at http://www2.stonemedia.com/franko
0 Likes