Prod.: Engine, ver.: 6, ID: 60001464, HowTo : Different mid-vertex grip in vdPolyline using the VDF Wrapper

HowTo : Different mid-vertex grip in vdPolyline using the VDF Wrapper

Article60001464
TypeHowTo
ProductEngine
Version6
Date Added8/4/2011
Submitted byFrank Louis
Keywords

Subject

Different mid-vertex grip in vdPolyline using the VDF Wrapper

Summary

I like to use the new middle point grip feature. If a customer move such a grip we add a new Vertex. That is a much greater way to add vertexes to a Polyline, then in other systems like ACAD.

OK. Problem is: If the polyline is closed, then the user can't see a different between a "Real Vertex-Grip" and a "Virtual Middle Point Grip".

So we need a other presentation of the (virtual) middle point grips. The easiest way to do this ( I think), should be to set a different colour for them. (We need access through wrapper (RGB?) to it)

Can you please check this wish. Better ideas are welcome, too

Solution

You can use the DrawGripsEx event to draw the grips of the object (vdPolyline in this case) as you like. Try a code like :
Private Sub Load_Click()
    
    VDraw.ActiveDocument.New
    VDraw.DisplayFrames = ShowAll
    VDraw.EnableAutoGripOn = True
    VDraw.StatusBar = True
    VDraw.StatusBarMenu = True

    VDraw.CommandAction.CmdPolyLine Array(Array(0, 0, 0), Array(2, 0, 0), Array(2, 2, 0), Array(0, 2, 0))

    VDraw.FreezeDrawEntityEvents = False
    VDraw.FreezeDrawEvents 0
    Dim doc As VectorDraw_Professional.vdDocument
    
    Set doc = VDraw.ActiveDocument.WrapperObject
    doc.GlobalRenderProperties.EnableMiddleGripForPolylines = True
    
End Sub


Private Sub VDraw_DrawGripsEx(ByVal VdEntityObject As VDrawI5.vdFigure, ByVal Render As VDrawI5.vdRender, Cancel As Integer)
Dim doc As VectorDraw_Professional.vdDocument
Set doc = VDraw.ActiveDocument.WrapperObject
If doc.GlobalRenderProperties.EnableMiddleGripForPolylines <> True Then Exit Sub

If VdEntityObject.Type = "VDPOLYLINE" Then
    Dim poly As VDrawI5.vdPolyline
    Set poly = VdEntityObject
    Dim circ As VDrawI5.vdCircle

    Dim i As Long
    For i = 0 To UBound(poly.Grips)
        Set circ = VDraw.CreateInstance(VDrawI5.VdConstObjectType_tag.OBJ_CIRCLE)
        circ.CenterPoint = Array(poly.Grips(i, 0), poly.Grips(i, 1), poly.Grips(i, 2))
        circ.Radius = Render.PixelSize * VDraw.GripSize / 2#
        circ.PenColor = VDraw.GripColor
        If i > UBound(poly.VertexList) Then
            circ.PenColor = "(255,0,0)"
        End If
        Render.DrawEntity circ
    Next i
    
    Cancel = 1
End If

End Sub