.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Draworder in an Overrule

3 REPLIES 3
Reply
Message 1 of 4
dtsa.us
388 Views, 3 Replies

Draworder in an Overrule

Hi all,

Just learning a bit about the new Overrule API in 2010 and I have a question about controlling the draworder in which objects are displayed. I'm basically adding a hatch to a polyline (really a curve), with the WorldDraw code below, but the hatch is obscuring the polyline. Can someone offer some guidance on changing the display order so I can see the polyline?

Thanks in advance for your help,
-Danny

{code}
Public Overloads Overrides Function WorldDraw(ByVal d As Drawable, ByVal wd As WorldDraw) As Boolean
If Not TypeOf d Is Curve Then
Return MyBase.WorldDraw(d, wd)
End If

Try
Dim c As Curve = d
Dim h As New Hatch()
Dim oic As New ObjectIdCollection
oic.Add(c.ObjectId)
h.SetDatabaseDefaults()
h.AppendLoop(HatchLoopTypes.Default, oic)
h.SetHatchPattern(HatchPatternType.PreDefined, "SOLID")
h.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 😎
h.WorldDraw(wd)
h.Dispose()
Catch ex As Exception
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.Message)
End Try
Return MyBase.WorldDraw(d, wd)
End Function
{code}
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: dtsa.us

Have you tried calling base.WorldDraw() before you draw your
custom graphics?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");


wrote in message news:6231166@discussion.autodesk.com...
Hi all,

Just learning a bit about the new Overrule API in 2010 and I have a question
about controlling the draworder in which objects are displayed. I'm
basically adding a hatch to a polyline (really a curve), with the WorldDraw
code below, but the hatch is obscuring the polyline. Can someone offer some
guidance on changing the display order so I can see the polyline?

Thanks in advance for your help,
-Danny

{code}
Public Overloads Overrides Function WorldDraw(ByVal d As Drawable, ByVal
wd As WorldDraw) As Boolean
If Not TypeOf d Is Curve Then
Return MyBase.WorldDraw(d, wd)
End If

Try
Dim c As Curve = d
Dim h As New Hatch()
Dim oic As New ObjectIdCollection
oic.Add(c.ObjectId)
h.SetDatabaseDefaults()
h.AppendLoop(HatchLoopTypes.Default, oic)
h.SetHatchPattern(HatchPatternType.PreDefined, "SOLID")
h.Color =
Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 😎
h.WorldDraw(wd)
h.Dispose()
Catch ex As Exception
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.Message)
End Try
Return MyBase.WorldDraw(d, wd)
End Function
{code}
Message 3 of 4
dtsa.us
in reply to: dtsa.us

Hi Tony,

Thanks for the reply. I had not tried that, but I modified the code as shown below and that doesn't seem to change anything. The hatch still appears above the polyline. The parameters were required by the WorldDraw function.

Thanks again,
-Danny

{code}
Public Overloads Overrides Function WorldDraw(ByVal d As Drawable, ByVal wd As WorldDraw) As Boolean
If Not TypeOf d Is Curve Then
Return MyBase.WorldDraw(d, wd)
End If
Dim retVal as Boolean
Try
retVal = MyBase.WorldDraw(d,wd)
Dim c As Curve = d
Dim h As New Hatch()
Dim oic As New ObjectIdCollection
oic.Add(c.ObjectId)
h.SetDatabaseDefaults()
h.AppendLoop(HatchLoopTypes.Default, oic)
h.SetHatchPattern(HatchPatternType.PreDefined, "SOLID")
h.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 😎
h.WorldDraw(wd)
h.Dispose()
Catch ex As Exception
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.Message)
End Try

End Function
{code}
Message 4 of 4
dtsa.us
in reply to: dtsa.us

Tony, et al,

After many attempts to get something workable (with many quick exits and stack overflows in between), I finally came up with the code below. It correctly draws the curve on top of the hatch. Since I'm a newbie with Overrides and the concepts involved, I'm still not sure why this works, and whether it's the proper approach. If anyone has a comment on this, I would appreciate it.

Thanks again,
-Danny

{code}
Public Overloads Overrides Function WorldDraw(ByVal d As Drawable, ByVal wd As WorldDraw) As Boolean
If Not TypeOf d Is Curve Then
Return MyBase.WorldDraw(d, wd)
End If
Dim retVal as Boolean
Try
Dim c As Curve = d
Dim h As New Hatch()
Dim oic As New ObjectIdCollection
oic.Add(c.ObjectId)
h.SetDatabaseDefaults()
h.AppendLoop(HatchLoopTypes.Default, oic)
h.SetHatchPattern(HatchPatternType.PreDefined, "SOLID")
h.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, 😎
h.WorldDraw(wd)
h.Dispose()

Dim newD as Drawable = c.clone
Return newD.WorldDraw(wd)

Catch ex As Exception
Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.Message)
End Try

End Function
{code}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost