Modifying the code half worked, now when the jig is drawn in ISO view it does not jig properly. But the leader text always looks like it is in top view. Here is what I have so far from modifying the code to work with an MLeader, not sure if it's 100% correct way to have modified it.
Private Shared Sub AddRegAppId(ByVal db As Database)
Using trans As Transaction =
db.TransactionManager.StartTransaction()
' First create our RegAppId (if it doesn't already exist)
Dim appTbl As RegAppTable =
trans.GetObject(db.RegAppTableId, OpenMode.ForRead)
If Not appTbl.Has(mXdataName) Then
Dim appTblRec As New RegAppTableRecord
appTbl.UpgradeOpen()
appTblRec.Name = mXdataName
appTbl.Add(appTblRec)
trans.AddNewlyCreatedDBObject(appTblRec, True)
End If
trans.Commit()
End Using
End Sub
<CommandMethod("ActivateBillboardOverrule")>
Public Shared Sub ActivateOverrule()
'We only want to create our overrule instance once,
' so we check if it already exists before we create it
' (i.e. this may be the 2nd time we've run the command)
If myOverrule Is Nothing Then
'Instantiate our overrule class
myOverrule = New BillboardAttributesOverrule
'Register the overrule
Overrule.AddOverrule(
RXClass.GetClass(GetType(MLeader)),
myOverrule, False)
End If
'Specify which Attributes will be overruled
myOverrule.SetXDataFilter(mXdataName)
'Make sure overruling is turned on so our overrule works
Overrule.Overruling = True
End Sub
And the class
Public Class BillboardAttributesOverrule
Inherits DrawableOverrule
'Returning False from WorldDraw tells AutoCAD this entity has
' viewport dependent graphics.
Public Overrides Function WorldDraw(ByVal drawable As Drawable,
ByVal wd As WorldDraw) As Boolean
Return False
End Function
' Called for each viewport so entity can draw itself differently
' depending on the view.
Public Overrides Sub ViewportDraw(ByVal drawable As Drawable,
ByVal vd As ViewportDraw)
' Cast drawable to type AttributeReference (we know it's an
' AttributeReference because that's the only class we register our
' overrule for).
Dim ml As MLeader = drawable
' Calculate the transformation matrix to rotate from the
' attribute's current orientation to the view.
' (Thank you to Gile from TheSwamp for correcting this
' transformation to account for insertion on a UCS rotated
' w.r.t. the WCS and for non-left-aligned justification).
Dim org As Point3d
'If ml.TextLocation = AttachmentPoint.BaseLeft Or
'mt.FlowDirection = AttachmentPoint.BaseAlign Or
' mt.FlowDirection = AttachmentPoint.BaseFit Then
' org = mt.Location
'Else
' org = mt.Location
'End If
org = ml.TextLocation
Dim viewMat As Matrix3d =
Matrix3d.PlaneToWorld(New Plane(org, vd.Viewport.ViewDirection)) *
Matrix3d.WorldToPlane(New Plane(org, ml.Normal)) *
Matrix3d.Rotation(-ml.BlockRotation, ml.Normal, org)
' Apply the transformation
vd.Geometry.PushModelTransform(viewMat)
'Draw the 'per viewport geometry
MyBase.ViewportDraw(drawable, vd)
' Remove the transformation - we don't want any other objects
' to draw themselves in the view plane.
vd.Geometry.PopModelTransform()
End Sub
' This function tells AutoCAD to dynamically update the
' AttributeReference during view transitions (e.g. 3DORBIT).
' Comment it out to improve graphic update performance.
Public Overrides Function SetAttributes(
ByVal drawable As Drawable,
ByVal traits As DrawableTraits) As Integer
Return MyBase.SetAttributes(drawable, traits) Or 2048
End Function
End Class