Hi there,
Someone asked me to post an example of my
code for my "flickery jig".
Well here it is. I have used a very small jig to
create a slope for a fall line, and added lots of
"RUBBISH lines that twirl around the start point".
This is to show that the last few in the jig flicker
When you drag around in the command. If anyone
could shed some light on why this may be
happening that would be fab.
Thanks in advance,
Martin.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD
Public Class Slope
Inherits DrawJig
Dim StPnt As Point3d ' Center - Start
Dim EndPt As New Point3d ' Center - End
Dim EndPtH As Point3d
Dim LineDrg As New Line ' Center = Line
Dim myPR As PromptPointResult
Function StartJig() As PromptPointResult
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim ppr1 As PromptPointResult = ed.GetPoint(vbLf & "Specify Start: ")
StPnt = ppr1.Value
LineDrg.StartPoint = StPnt
' LineDrg.ColorIndex = 2
ppr1 = ed.Drag(Me)
Do
Select Case ppr1.Status
Case PromptStatus.OK
Return ppr1
Exit Do
End Select
Loop While ppr1.Status <> PromptStatus.Cancel
Return ppr1
End Function
Protected Overrides Function Sampler(ByVal prompts As JigPrompts) As SamplerStatus
myPR = prompts.AcquirePoint("Select End point:")
If myPR.Value.IsEqualTo(EndPt) Then
Return SamplerStatus.NoChange
Else
EndPt = myPR.Value
LineDrg.EndPoint = EndPt
Return SamplerStatus.OK
End If
End Function
Protected Overrides Function WorldDraw(ByVal draw As GraphicsInterface.WorldDraw) As Boolean
''''''''''''''''''''''' DRAG LINE ''''''''''''''''''''''''
Dim DrLnRst As New Line ' Drag Line
DrLnRst.StartPoint = StPnt
DrLnRst.EndPoint = EndPt
DrLnRst.ColorIndex = 4 ' Cyan
draw.Geometry.Draw(DrLnRst)
Dim SLAng As Double
SLAng = DrLnRst.Angle
''''''''''''''''''''' DRAG LINE END ''''''''''''''''''''''
''''''''''''''''''''' HORIZONTAL LINE ''''''''''''''''''''
EndPtH = New Point3d(EndPt.X, StPnt.Y, 0)
Dim HorzL As New Line
HorzL.StartPoint = StPnt
HorzL.EndPoint = EndPtH
HorzL.ColorIndex = 4
draw.Geometry.Draw(HorzL)
Dim HLLen As Double
HLLen = HorzL.Length
''''''''''''''''''' HORIZONTAL LINE END ''''''''''''''''''
'''''''''''''''''''''' VERTICAL LINE '''''''''''''''''''''
Dim VertL As New Line
VertL.StartPoint = EndPt
VertL.EndPoint = EndPtH
VertL.ColorIndex = 1
draw.Geometry.Draw(VertL)
Dim VLLen As Double
VLLen = VertL.Length
'''''''''''''''''''' VERTICAL LINE END '''''''''''''''''''
'''''''''''''''''''' show flicker '''''''''''''''''''''''
Dim A1 As Double = (20 / (180 / Math.PI)) + SLAng
Dim A2 As Double = (50 / (180 / Math.PI)) + SLAng
Dim A3 As Double = (120 / (180 / Math.PI)) + SLAng
Dim A4 As Double = (160 / (180 / Math.PI)) + SLAng
Dim A5 As Double = (200 / (180 / Math.PI)) + SLAng
Dim A6 As Double = (240 / (180 / Math.PI)) + SLAng
Dim A7 As Double = (260 / (180 / Math.PI)) + SLAng
Dim A8 As Double = (270 / (180 / Math.PI)) + SLAng
Dim A9 As Double = (280 / (180 / Math.PI)) + SLAng
Dim A10 As Double = (290 / (180 / Math.PI)) + SLAng
Dim tmp1 = StPnt.Add(New Vector3d(Math.Cos(A1) * 10, Math.Sin(A1) * 10, 0))
Dim tmp2 = StPnt.Add(New Vector3d(Math.Cos(A2) * 10, Math.Sin(A2) * 10, 0))
Dim tmp3 = StPnt.Add(New Vector3d(Math.Cos(A3) * 10, Math.Sin(A3) * 10, 0))
Dim tmp4 = StPnt.Add(New Vector3d(Math.Cos(A4) * 10, Math.Sin(A4) * 10, 0))
Dim tmp5 = StPnt.Add(New Vector3d(Math.Cos(A5) * 10, Math.Sin(A5) * 10, 0))
Dim tmp6 = StPnt.Add(New Vector3d(Math.Cos(A6) * 10, Math.Sin(A6) * 10, 0))
Dim tmp7 = StPnt.Add(New Vector3d(Math.Cos(A7) * 10, Math.Sin(A7) * 10, 0))
Dim tmp8 = StPnt.Add(New Vector3d(Math.Cos(A8) * 10, Math.Sin(A8) * 10, 0))
Dim tmp9 = StPnt.Add(New Vector3d(Math.Cos(A9) * 10, Math.Sin(A9) * 10, 0))
Dim tmp10 = StPnt.Add(New Vector3d(Math.Cos(A10) * 10, Math.Sin(A10) * 10, 0))
draw.Geometry.Draw(New Line(StPnt, tmp1))
draw.Geometry.Draw(New Line(StPnt, tmp2))
draw.Geometry.Draw(New Line(StPnt, tmp3))
draw.Geometry.Draw(New Line(StPnt, tmp4))
draw.Geometry.Draw(New Line(StPnt, tmp5))
draw.Geometry.Draw(New Line(StPnt, tmp6))
draw.Geometry.Draw(New Line(StPnt, tmp7))
draw.Geometry.Draw(New Line(StPnt, tmp8))
draw.Geometry.Draw(New Line(StPnt, tmp9))
draw.Geometry.Draw(New Line(StPnt, tmp10))
End Function
_
Public Sub DoJigA()
'Get the active document and begin a Transaction
Dim myDWG As Document = Application.DocumentManager.MdiActiveDocument
Using myTransMan As DatabaseServices.TransactionManager = myDWG.TransactionManager
Dim myTrans As Transaction = myTransMan.StartTransaction
'Open the BlockTable for Read
Dim myEd As Editor = myDWG.Editor
Dim myBT As BlockTable = myDWG.Database.BlockTableId.GetObject(DatabaseServices.OpenMode.ForRead)
Dim myBTR As BlockTableRecord = myBT(DatabaseServices.BlockTableRecord.ModelSpace).GetObject(DatabaseServices.OpenMode.ForWrite)
' Start Jig
Dim myJig As New Slope
Dim SelPt As Autodesk.AutoCAD.EditorInput.PromptPointResult
SelPt = myJig.StartJig()
' Points
Dim StPnt As Point3d = myJig.StPnt
Dim EndPt As Point3d = myJig.EndPt
Dim EndPtH As Point3d = myJig.EndPtH
Dim PtCol As New Point3dCollection
PtCol.Add(StPnt)
PtCol.Add(EndPt)
PtCol.Add(EndPtH)
Dim Pl As New Polyline2d(Poly2dType.SimplePoly, PtCol, 0, True, 0, 0, Nothing)
Pl.ColorIndex = 4 '1=Red 2=Yellow 3=Green 4=Cyan 5=Blue 6=Purple 7=White
Pl.Closed = True
myBTR.AppendEntity(Pl)
myTrans.AddNewlyCreatedDBObject(Pl, True)
Pl.Dispose()
myTrans.Commit()
myTrans.Dispose()
myTransMan.Dispose()
End Using
End Sub
End Class
My name is Martin.. 😄