Hi Albert:
Following is the complete codes that you can compile.Please help me to find the reason why the function "SetUCS" don't work!
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)
'''''''''Draw Screw Solid '''''''''''''''''''''''''''''''''
Dim dboCol As New DBObjectCollection
Dim cir As New Circle
Dim solid3dScrew As New Solid3d
Dim regionCir As Region
Dim regions As DBObjectCollection
''''''''''''''''''''''''''''''UCS should be changed to FrontView from TopView,But the SetUCS can not goog work!!!!!!!!!!
Dim orthoView As New OrthographicView
Dim viewp As New Viewport
orthoView = OrthographicView.FrontView
viewp.SetUcs(orthoView)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
cir.Center = p0
cir.Radius = 10
dboCol.Clear()
dboCol.Add(cir)
btr.AppendEntity(cir)
tm.AddNewlyCreatedDBObject(cir, True)
regions = regionCir.CreateFromCurves(dboCol)
regionCir = regions(0)
'solid3dScrew.ExtrudeAlongPath(regionCir, sPline, 0)
btr.AppendEntity(solid3dScrew)
tm.AddNewlyCreatedDBObject(solid3dScrew, True)
regions.Dispose()
'''''''''Draw Screw Solid '''''''''''''''''''''''''''''''''
ta.Commit()
Catch
MsgBox( Err.Description, MsgBoxStyle.Critical, "Error")
Finally
ta.Dispose()
End Try
End Sub