Product : Engine, Version : 5.1.1.1037, ArticleID : 41024007

HowTo : Create and Edit a LineType

Article41024007
TypeHowTo
ProductEngine
Version5.1.1.1037
Date Added6/7/2005
Submitted byChristian HolBrook
Keywords

Subject

Create and Edit a LineType

Summary

Can I create a Linetype with an editable text segment in it. For example:

-------1001------1001-------1001-------  and use the same linetype to do:

-------1002------1002-------1002-------

Or would I have to define a linetype for each?

Solution

 

You can edit the current linetype but every figure which uses the old text will be changed according the new. If you want to have the "1001" linetype for a figure and "1002" for another figure at the same time, then you have to construct two diferent linetypes.See the following sample
 
Create a vb6 project with the component and add three buttons with the following code.

Private Sub Command1_Click()
    'line types which create shapes must have their own TextStyle which must not be used in objects other than linetype elements.
    ' Do not use STANDARD for shape style linetypes!!
    Dim myltype As vdLineType
    Dim myline As vdLine
    Dim style1 As vdTextstyle
   
    vdraw.ActiveDocument.New

    Set style1 = vdraw.ActiveDocument.TextStyles.Add("LineType_A")
    style1.FontFile = "Arial"
    Set myltype = vdraw.ActiveDocument.LineTypes.Add("test_A")
    myltype.Comments = "vdtestA ____ 1001 ____ 1001 ____"
    myltype.NumDashes = 3
    myltype.SetDashAt 0, 1
    myltype.SetDashAt 1, -0.7
    myltype.SetDashAt 2, -0.7
    myltype.SetShapeOffsetAt 1, -0.7, 0#
    myltype.SetShapeStyleAt 1, "LineType_A"
    myltype.SetFlagAt 1, 2 'Use 2 for True type fonts and then SetTextAt to define the text
    myltype.SetTextAt 1, "1001"
    myltype.SetShapeScaleAt 1, 0.4
   
    'Active textstyle must be always other than textstyle which is using for linetypes
    'Do not use STANDARD for shape style linetypes!!

    vdraw.ActiveDocument.ActiveTextStyle = "STANDARD"
   
    Dim line1 As vdLine
    Dim line2 As vdLine
   
    Set line1 = vdraw.ActiveDocument.ActiveLayOut.Entities.AddLine(Array(0, 0, 0), Array(10, 0, 0))
    line1.PenStyle = 100 + myltype.Index
   
    Set line2 = vdraw.ActiveDocument.ActiveLayOut.Entities.AddLine(Array(0, 5, 0), Array(10, 5, 0))
    line2.PenStyle = 100 + myltype.Index
   
    vdraw.CommandAction.Zoom "E", 0, 0
   
    Command2.Enabled = True
    Command3.Enabled = True
End Sub


Private Sub Command2_Click()
'edits linetype "test_A"
Dim myltype As vdLineType
   
    Set myltype = vdraw.ActiveDocument.LineTypes.FindName("test_A")
    If Not myltype Is Nothing Then
        myltype.SetTextAt 1, "1002"
        myltype.Comments = "vdtestA ____ 1002 ____ 1002 ____"
    End If
    vdraw.Redraw
    Command2.Enabled = False
    Command3.Enabled = False
End Sub


Private Sub Command3_Click()
Dim line As vdLine
Dim myltype As vdLineType
Dim style1 As vdTextstyle

'Creates a new linetype "test_B"
    Set style1 = vdraw.ActiveDocument.TextStyles.Add("LineType_B")
    style1.FontFile = "Arial"
    Set myltype = vdraw.ActiveDocument.LineTypes.Add("test_B")
    myltype.Comments = "vdtestB ____ 1002 ____ 1002 ____"
    myltype.NumDashes = 3
    myltype.SetDashAt 0, 1
    myltype.SetDashAt 1, -0.7
    myltype.SetDashAt 2, -0.7
    myltype.SetShapeOffsetAt 1, -0.7, 0#
    myltype.SetShapeStyleAt 1, "LineType_B"
    myltype.SetFlagAt 1, 2 'Use 2 for True type fonts and then SetTextAt to define the text
    myltype.SetTextAt 1, "1002"
    myltype.SetShapeScaleAt 1, 0.4
   
    'Active textstyle must be always other than textstyle which is using for linetypes
    'Do not use STANDARD for shape style linetypes!!

    vdraw.ActiveDocument.ActiveTextStyle = "STANDARD"

    Set line = vdraw.ActiveDocument.Entities.Last
    line.PenStyle = 100 + myltype.Index
    vdraw.Redraw
    Command2.Enabled = False
    Command3.Enabled = False
End Sub