Drawing with linetypes

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
zebiya
Posts: 27
Joined: 14 Feb 2007, 22:45
Location: Spain

Drawing with linetypes

Post by zebiya » 20 Jul 2007, 00:03

Hello

Please could you explain a bit about drawing polylines with different linetypes? I'm using CadImport.NET and VB

Thanks!!

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 23 Jul 2007, 15:28

Hello Zebiya,

The following code adds new line type "ISO dash", if it doesn't exists and sets it to all CADLines in the loaded file:

Code: Select all

<font color="blue">Private Sub</font id="blue"> btnAddLType_Click(<font color="blue">ByVal</font id="blue"> sender <font color="blue">As</font id="blue"> System.Object, <font color="blue">ByVal</font id="blue"> e <font color="blue">As</font id="blue"> System.EventArgs) <font color="blue">Handles</font id="blue"> btnAddLType.Click
    <font color="blue">If</font id="blue"> (Me.FCADImage <font color="blue">Is Nothing</font id="blue">) <font color="blue">Then Return
    Me</font id="blue">.FCADImage.UseBufMetafile = <font color="blue">False</font id="blue">
    <font color="blue">Me</font id="blue">.cadPictBox.Invalidate()

    <font color="blue">Dim</font id="blue"> lType <font color="blue">As</font id="blue"> CADLineType

    lType = <font color="blue">Me</font id="blue">.FCADImage.Converter.LTypeByName("ISO dash")
    <font color="blue">If</font id="blue"> (lType <font color="blue">Is Nothing</font id="blue">) <font color="blue">Then</font id="blue">
        lType = <font color="blue">New</font id="blue"> CADLineType
        lType.Name = "ISO dash"
        lType.Lines.Ticks.Add(1.2)
        lType.Lines.Ticks.Add(-0.3)
        <font color="blue">Me</font id="blue">.FCADImage.Converter.LinesByName("ISO dash")
        <font color="blue">Me</font id="blue">.FCADImage.Converter.GetSection(CADImport.ConvSection.LTypes).AddEntity(lType)
    <font color="blue">End If

    Dim</font id="blue"> I <font color="blue">As</font id="blue"> Integer
    <font color="blue">Dim</font id="blue"> entLine <font color="blue">As</font id="blue"> CADLine

    <font color="blue">For</font id="blue"> I = 0 <font color="blue">To</font id="blue"> <font color="blue">Me</font id="blue">.FCADImage.Converter.Entities.Count - 1
    If (TypeOf <font color="blue">Me</font id="blue">.FCADImage.Converter.Entities(I) <font color="blue">Is</font id="blue"> CADLine) <font color="blue">Then</font id="blue">
        entLine = <font color="blue">Me</font id="blue">.FCADImage.Converter.Entities(I)
        entLine.SetLType(lType)
        entLine.LineWeight = 1.4
        <font color="blue">Me</font id="blue">.FCADImage.Converter.Loads(entLine)
    <font color="blue">End If
    Next </font id="blue">I
    <font color="blue">Me</font id="blue">.cadPictBox.Invalidate()
<font color="blue">End Sub</font id="blue">
Sergey.

Please post questions to the forum or write to support@cadsofttools.com

zebiya
Posts: 27
Joined: 14 Feb 2007, 22:45
Location: Spain

Post by zebiya » 23 Jul 2007, 20:39

Thank you, Sergey, I realise it is a good and simple example but I was looking for an "explanation".

For instance,
Ñ—what can I do with <i>LType.Pen.DashStyle</i>?
Ñ—Can I make more "complex" linetypes?
Ñ—How?
Ñ—Which are the limits?
Ñ—What does exactely mean LineTypeScale?
Ñ—What are Ticks?

I am sure you will make those things clear for me. I do not need very deep teaching, but just some quick clues to manage linetypes

Thank you very much

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Post by support » 25 Jul 2007, 17:55

Hello Zebiya!

<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">Ñ—what can I do with LType.Pen.DashStyle?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
This line does not allows to do anything. <b>CAD Import .NET</b> does not use standard system dash styles.
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">Ñ—Can I make more "complex" linetypes?
Ñ—How?
Ñ—Which are the limits?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
Please use the following example:

Code: Select all

<font color="blue">Dim</font id="blue"> lType <font color="blue">As</font id="blue"> CADLineType
lType = <font color="blue">Me</font id="blue">.FCADImage.Converter.LTypeByName("New LineType")
<font color="blue">If</font id="blue"> (lType <font color="blue">Is Nothing</font id="blue">) <font color="blue">Then</font id="blue">
    lType = <font color="blue">New</font id="blue"> CADLineType
    lType.Name = "New LineType"
    lType.Lines.Ticks.Add(5.0)
    lType.Lines.Ticks.Add(-0.5)
    lType.Lines.Ticks.Add(0.1)
    lType.Lines.Ticks.Add(-0.5)
    lType.Lines.Ticks.Add(0.1)
    lType.Lines.Ticks.Add(-0.5)
    lType.Lines.Ticks.Add(0.1)
    lType.Lines.Ticks.Add(-0.5)

    <font color="blue">Me</font id="blue">.FCADImage.Converter.GetSection(CADImport.ConvSection.LTypes).AddEntity(lType)
<font color="blue">End If</font id="blue">
Number of ticks is unlimited.
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">Ñ—What are Ticks?<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
<b>Ticks</b> define length of dashes and dots and empty spaces between them.
Positive value defines a dash(or dot - dependently on its length).
Negative value defines empty space between dashes (dots).
<blockquote id="quote"><font size="2" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">Ñ—What does exactely mean LineTypeScale? <hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">
<b>LineTypeScale</b> defines a value which is used for multiplying length of dashes and dots and empty spaces between them.
Currently changing CADLineType.LineTypeScale gives no result. It will be corrected in future versions of the library. Until that we recommend to set this value for entities directly:

Code: Select all

<font color="blue">Dim</font id="blue"> I <font color="blue">As Integer
Dim</font id="blue"> entLine <font color="blue">As</font id="blue"> CADLine

<font color="blue">For</font id="blue"> I = 0 <font color="blue">To Me</font id="blue">.FCADImage.Converter.Entities.Count - 1
    <font color="blue">If</font id="blue"> (<font color="blue">TypeOf Me</font id="blue">.FCADImage.Converter.Entities(I) <font color="blue">Is</font id="blue"> CADLine) <font color="blue">Then</font id="blue">
        entLine = <font color="blue">Me</font id="blue">.FCADImage.Converter.Entities(I)
        entLine.SetLType(lType)
        entLine.LineWeight = 0.6
        entLine.LineTypeScale = 20
        <font color="blue">Me</font id="blue">.FCADImage.Converter.Loads(entLine)
    <font color="blue">End If
Next I</font id="blue">
Sergey

Please post questions to the forum or write to support@cadsofttools.com

zebiya
Posts: 27
Joined: 14 Feb 2007, 22:45
Location: Spain

Post by zebiya » 25 Jul 2007, 22:22

Thanks a lot for your help. It is just what I needed

Greetings

Post Reply