Hatch (Addhatch method) without using Autocad reference in VB.NET
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi. I want to draw Hatch using ADDHATCH method without importing any Autocad reference. I tried this method before in VBA (VB6). It didn't work in VB.NET.
The sample code is this:
' Defining hatch object as "Object" (instead of "AcadHatch") should prevent the code from requiring AutoCAD references.
' (It is working for other functions --> using "As Object" instead of "As AcadCircle" or "As AcadLWPolyline" or ...)
' But an error is risen when hatch is defined "As Object".
Dim hatchObj As Object
hatchObj = acaddoc.ModelSpace.AddHatch(1, "SOLID", True)
' Create the outer boundary for the hatch. (a circle)
Dim CircleCenter(2) As Double
CircleCenter(0) = 0 : CircleCenter(1) = 0 : CircleCenter(2) = 0
Dim CircleRadius As Double = 20
Dim outerLoop(0 To 0) As Object
outerLoop(0) = acaddoc.ModelSpace.AddCircle(CircleCenter, CircleRadius)
' !!! Error appears in the following line !!!
hatchObj.AppendOuterLoop(outerLoop)
hatchObj.Evaluate