.NET

Reply
Contributor
jiangfangji
Posts: 17
Registered: ‎05-31-2005
Message 1 of 5 (92 Views)

Please see my codes,why can not working?

92 Views, 4 Replies
05-31-2005 08:22 PM
''''''''''''''''''''''''''''''''''''''''''''''''

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)
btr.AppendEntity(dd1)
tm.AddNewlyCreatedDBObject(dd1, True)


MsgBox(Format(cir.Area, "0.00"))
MsgBox(Format(dd1.Area, "0.00"))


Dim cc As New Solid3d
'cc.ExtrudeAlongPath(dd1, sPline, 0)
'cc.Extrude(dd1, 10, 0)

'btr.AppendEntity(cc)
'tm.AddNewlyCreatedDBObject(cc, True)
'dd1.Dispose()
''''''''''''''''''''''''''''''''''''''''''''''''''
*Jon Rizzo
Message 2 of 5 (92 Views)

Re: Please see my codes,why can not working?

06-01-2005 01:53 PM in reply to: jiangfangji
Is it throwing an exception, or is the result not what you expected? I
don't see it in your code, but are you committing the transaction?


wrote in message news:4861403@discussion.autodesk.com...
''''''''''''''''''''''''''''''''''''''''''''''''

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)
btr.AppendEntity(dd1)
tm.AddNewlyCreatedDBObject(dd1, True)


MsgBox(Format(cir.Area, "0.00"))
MsgBox(Format(dd1.Area, "0.00"))


Dim cc As New Solid3d
'cc.ExtrudeAlongPath(dd1, sPline, 0)
'cc.Extrude(dd1, 10, 0)

'btr.AppendEntity(cc)
'tm.AddNewlyCreatedDBObject(cc, True)
'dd1.Dispose()
''''''''''''''''''''''''''''''''''''''''''''''''''
Contributor
jiangfangji
Posts: 17
Registered: ‎05-31-2005
Message 3 of 5 (92 Views)

Re: Please see my codes,why can not working?

06-01-2005 05:14 PM in reply to: jiangfangji
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
*Albert Szilvasy
Message 4 of 5 (92 Views)

Re: Please see my codes,why can not working?

06-01-2005 06:58 PM in reply to: jiangfangji
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
Contributor
jiangfangji
Posts: 17
Registered: ‎05-31-2005
Message 5 of 5 (92 Views)

Re: Please see my codes,why can not working?

06-01-2005 09:53 PM in reply to: jiangfangji
Hi, Albert :
Thanks for your Help!!

Regards.
John Jiang

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community