.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DoubleCollection in Creating a Spline

5 REPLIES 5
Reply
Message 1 of 6
gilseorin
381 Views, 5 Replies

DoubleCollection in Creating a Spline

Hi,all.

I can create a spline in one method.
Now, I try in another method.
Suppose I commit an error in using the DoubleCollection option.
How could I get the correct result?
Could anyone help me?
Thanks in advance.

Public Sub CreateSpline()
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim t As Transaction = db.TransactionManager.StartTransaction
Try
Dim bt As BlockTable = CType(t.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
Dim btr As BlockTableRecord = CType(t.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
Dim v3d As Vector3d = New Vector3d(0, 0, 1)

Dim controlpts As Point3dCollection = New Point3dCollection
controlpts.Add(New Point3d(100, 100, 0))
controlpts.Add(New Point3d(133.3333, 133.3333, 0))
controlpts.Add(New Point3d(166.6666, 166.6666, 0))
controlpts.Add(New Point3d(200, 200, 0))

Dim dc As DoubleCollection = New DoubleCollection
dc.Add(100)
dc.Add(200)

Dim dc1 As DoubleCollection = New DoubleCollection
dc1.Add(300)
dc1.Add(400)

Dim c As Spline = New Spline(3, True, False, True, controlpts, dc, dc1, 0.0, 0.0)
btr.AppendEntity(c)
t.AddNewlyCreatedDBObject(c, True)
t.Commit()
t.Dispose()
Finally
End Try
End Sub
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: gilseorin

I used another constructor without
DoubleCollection
See how it will work for you
A2007/ Win XP HE/ VS20005

~'J'~

Public Sub CreateSpline()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = doc.Editor
Dim docLock As DocumentLock = doc.LockDocument
Dim db As Database = doc.Database
Dim t As Transaction = db.TransactionManager.StartTransaction
Try
Dim bt As BlockTable = CType(t.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
Dim btr As BlockTableRecord = CType(t.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)

Dim controlpts As Point3dCollection = New Point3dCollection
controlpts.Add(New Point3d(1000, 1000, 0))
controlpts.Add(New Point3d(1200, 1100, 0))
controlpts.Add(New Point3d(1800, 1900, 0))
controlpts.Add(New Point3d(2000, 2000, 0))

Dim c As Spline = New Spline(controlpts, New Vector3d(0.7071, 0.7071, 0), New Vector3d(0.7071, 0.7071, 0), 1, 0.0)

btr.AppendEntity(c)
t.AddNewlyCreatedDBObject(c, True)
ed.Regen()
t.Commit()

Finally
docLock.Dispose()
t.Dispose()
End Try
End Sub
Message 3 of 6
gilseorin
in reply to: gilseorin

Thank you so much,Fatty.
Thought I couldn't know the method of DoubleCollection,
It is really helpful to me.
Message 4 of 6
Anonymous
in reply to: gilseorin

Just install "Reflector" on your machine

from this page:

http://www.aisto.com/roeder/dotnet

very nice one, hope it will be useful for you

Regards,

~'J'~
Message 5 of 6
gilseorin
in reply to: gilseorin

Thank you so much again deeply for your kind help.
Message 6 of 6
Anonymous
in reply to: gilseorin

You are welcome
Cheers 🙂

~'J'~

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost