PDA

View Full Version : Solved: AUTOCAD - DrawOrder for hatches



ALe
05-30-2011, 08:14 AM
Hi everybody.

Is there any way to set via VBA the draworder of a created hatch?

I have this piece of code that creates a hatch associated to a closed polyline.
The code works and a hatch is created. The problem is that the hatch covers all other objects...
I'd like to see them and have the hatch as a background.


Sub TestAddHatch(MyPoly As AcadLWPolyline)
Dim hatchObj As AcadHatch
Dim patternName As String
Dim PatternType As Long
Dim bAssociativity As Boolean
Dim outerloop(0 To 0) As AcadEntity
'Dim innerloop(0 To 0) As AcadEntity

Dim color As AcadAcCmColor
Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.17")
' Define the hatch
patternName = "SOLID"
PatternType = 0
bAssociativity = True

' Create the associative Hatch object
Set hatchObj = ThisDrawing.ModelSpace.AddHatch _
(PatternType, patternName, bAssociativity)

' Create the outer boundary for the hatch
Set outerloop(0) = MyPoly
hatchObj.AppendOuterLoop (outerloop)

Call color.SetRGB(255, 255, 205) ' Basso Rischio -> GIALLO
hatchObj.TrueColor = color

hatchObj.Evaluate

ThisDrawing.Regen True
End Sub

ALe
05-30-2011, 09:13 AM
found solution.

in case you're interested:
http://www.theswamp.org/index.php?topic=8724.0

thank you

qdeer
01-19-2012, 02:26 AM
thanks