Author Topic: Complex Linetype with Shapes  (Read 2901 times)

0 Members and 1 Guest are viewing this topic.

ReneRam

  • Guest
Complex Linetype with Shapes
« on: May 06, 2008, 06:15:26 PM »
I was wondering if anybody could help with this.

I'm creating linetypes programmatically when the user needs them and adding them at runtime, and I have no problem until my linetype has dashes, points or text parts.

Code: [Select]
        Dim myLinetype As DatabaseServices.LinetypeTableRecord
        myLinetype = New DatabaseServices.LinetypeTableRecord
        myLinetype.Name = "TestLineType"
        myLinetype.Comments = "TestLineType"
        myLinetype.NumDashes = 3
        myLinetype.SetDashLengthAt(0, 0.125)
        myLinetype.SetDashLengthAt(1, -0.5)
        myLinetype.SetDashLengthAt(2, 0.125)
        Dim myTST As DatabaseServices.TextStyleTable = _
            myDB.TextStyleTableId.GetObject(DatabaseServices.OpenMode.ForRead)
        Dim myTS As DatabaseServices.TextStyleTableRecord = _
            myTST("STANDARD").GetObject(DatabaseServices.OpenMode.ForRead)
        myLinetype.SetTextAt(0, "Text1")
        myLinetype.SetShapeScaleAt(0, 0.0625)
        myLinetype.SetShapeStyleAt(0, myTS.ObjectId)
        myLinetype.SetShapeOffsetAt(0, New Geometry.Vector2d(0.125, 0.01))

        myLinetype.SetTextAt(1, "Text2")
        myLinetype.SetShapeScaleAt(1, 0.0625)
        myLinetype.SetShapeStyleAt(1, myTS.ObjectId)
        myLinetype.SetShapeOffsetAt(1, New Geometry.Vector2d(-0.34, -0.07))

(credit to Jerry Winters book, but you can find similar stuff in "Through The Interface")

My question is, how can I add a shape instead of a text, ie FENCELINE1 or FENCELINE2 in the default AutoCAD linetypes. How can I load/define a shape like "circ1" or "box" in the linetype.shx file.
Thanks in advance
René

ReneRam

  • Guest
Re: Complex Linetype with Shapes
« Reply #1 on: May 07, 2008, 08:56:33 AM »
... :-)
got it myself!
I just had to add a TextStyle referring to "ltypeshp.shx" and use it as normal text.

Code: [Select]
'Set Text Value
Dim myTST As TextStyleTable = _
myDB.TextStyleTableId.GetObject(OpenMode.ForWrite)
Dim myTS As TextStyleTableRecord = New TextStyleTableRecord
myTS.Name = "ShpText"
myTS.FileName = "ltypeshp.shx"
myTS.IsShapeFile = True
myTST.Add(myTS)
myTrans.AddNewlyCreatedDBObject(myTS, True)

' normaly create linetype...

myLinetype.PatternLength = 1.0
myLinetype.SetDashLengthAt(0, 2.5)
myLinetype.SetDashLengthAt(1, -2.5)
myLinetype.SetDashLengthAt(2, -5)
myLinetype.SetDashLengthAt(3, 5)
myLinetype.SetShapeStyleAt(2, myTS.ObjectId)
myLinetype.SetShapeNumberAt(2, 133)
myLinetype.SetShapeOffsetAt(2, New Vector2d(-1, 0))

' finish adding...

just sharing it 8-)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Complex Linetype with Shapes
« Reply #2 on: May 07, 2008, 11:00:59 AM »
<snip>
just sharing it 8-)
And thanks for that.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.