Here's the corrected code. The primary problem was that you failed to
realize that CreateFromCurves is a static (shared in vb lingo) method that
returns an array of regions. I have no idea what kind of object you are
trying to create here. It looks pretty interesting.
_
Public Sub Doit()
Dim db As Database =
Application.DocumentManager.MdiActiveDocument.Database
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager =
db.TransactionManager
Dim ta As Transaction = tm.StartTransaction
Try
Dim r, w, v, h As Double
Dim x0, y0, z0, x1, y1, z1 As Double
Dim tt, n As Integer
Dim cenX0, cenY0, cenZ0 As Double
Dim p0, p1 As Point3d
Dim p1Collection As New Point3dCollection
Dim sPline As Polyline3d
Const pi = 3.1415926
n = 1
cenX0 = 0
cenY0 = 0
cenZ0 = 0
tt = 0
r = 1
h = 1
Dim bt As BlockTable = tm.GetObject(db.BlockTableId,
OpenMode.ForRead, False)
Dim btr As BlockTableRecord =
tm.GetObject(bt.Item(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False)
w = 2 * pi / 180
v = h / 180
x0 = cenX0 + r * Math.Cos(w * tt)
y0 = cenY0 + r * Math.Sin(w * tt)
z0 = cenZ0 + v * tt
p0 = New Point3d(x0, y0, z0)
p1 = New Point3d(x0, y0, z0)
p1Collection.Add(p1)
tt = tt + 1
Do While (tt <= (n * 180))
x0 = cenX0 + r * Math.Cos(w * tt)
y0 = cenY0 + r * Math.Sin(w * tt)
z0 = cenZ0 + v * tt
p1 = New Point3d(x0, y0, z0)
p1 = New Point3d(x0, y0, z0)
p1Collection.Add(p1)
tt = tt + 1
Loop
sPline = New Polyline3d(Poly3dType.SimplePoly, p1Collection,
False)
btr.AppendEntity(sPline)
tm.AddNewlyCreatedDBObject(sPline, True)
''''''''''''''''''''''''''''''''''''''''''''''''
Dim bb As New DBObjectCollection
Dim cir As New Circle
cir.Center = p0
cir.Radius = 10
bb.Clear()
bb.Add(cir)
Dim regions As DBObjectCollection
regions = Region.CreateFromCurves(bb)
Dim dd1 As Region
dd1 = regions(0)
Dim cc As New Solid3d
cc.ExtrudeAlongPath(dd1, sPline, 0) '''????????why not working
btr.AppendEntity(cc)
tm.AddNewlyCreatedDBObject(cc, True)
dd1.Dispose()
''''''''''''''''''''''''''''''''''''''''''''''''''
ta.Commit()
Finally
ta.Dispose()
End Try
End Sub
wrote in message news:4862765@discussion.autodesk.com...
Sorry! Following is the complete codes:
Private Sub btnDraw_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDraw.Click
Dim db As Database =
Application.DocumentManager.MdiActiveDocument.Database
Dim tm As DBTransMan = db.TransactionManager
Dim ta As Transaction = tm.StartTransaction
Try
Dim r, w, v, h As Double
Dim x0, y0, z0, x1, y1, z1 As Double
Dim tt, n As Integer
Dim cenX0, cenY0, cenZ0 As Double
Dim p0, p1 As Point3d
Dim p1Collection As New Point3dCollection
Dim sPline As Polyline3d
Const pi = 3.1415926
n = CInt(txtN.Text)
cenX0 = CDbl(txtX.Text)
cenY0 = CDbl(txtY.Text)
cenZ0 = CDbl(txtZ.Text)
tt = 0
r = CDbl(txtRadius.Text)
h = CDbl(txtDaoCheng.Text)
Dim bt As BlockTable = tm.GetObject(db.BlockTableId,
OpenMode.ForRead, False)
Dim btr As BlockTableRecord =
tm.GetObject(bt.Item(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False)
w = 2 * pi / 180
v = h / 180
x0 = cenX0 + r * Cos(w * tt)
y0 = cenY0 + r * Sin(w * tt)
z0 = cenZ0 + v * tt
p0 = New Point3d(x0, y0, z0)
p1 = New Point3d(x0, y0, z0)
p1Collection.Add(p1)
tt = tt + 1
Do While (tt <= (n * 180))
x0 = cenX0 + r * Cos(w * tt)
y0 = cenY0 + r * Sin(w * tt)
z0 = cenZ0 + v * tt
p1 = New Point3d(x0, y0, z0)
p1 = New Point3d(x0, y0, z0)
p1Collection.Add(p1)
tt = tt + 1
Loop
sPline = New Polyline3d(Poly3dType.SimplePoly, p1Collection,
False)
btr.AppendEntity(sPline)
tm.AddNewlyCreatedDBObject(sPline, True)
''''''''''''''''''''''''''''''''''''''''''''''''
Dim bb As New DBObjectCollection
Dim cir As New Circle
cir.Center = p0
cir.Radius = 10
bb.Clear()
bb.Add(cir)
Dim dd1 As New Region
dd1.CreateFromCurves(bb) '''???????????????why not
working!!!!!!!!!
Dim cc As New Solid3d
cc.ExtrudeAlongPath(dd1, sPline, 0) '''????????why not working
btr.AppendEntity(cc)
tm.AddNewlyCreatedDBObject(cc, True)
dd1.Dispose()
''''''''''''''''''''''''''''''''''''''''''''''''''
ta.Commit()
Catch
MsgBox( Err.Description, MsgBoxStyle.Critical, "Error")
frmMain.ActiveForm.Close()
Finally
ta.Dispose()
frmMain.ActiveForm.Close()
End Try
End Sub