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

Please see my codes,why can not working?

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
527 Views, 4 Replies

Please see my codes,why can not working?

''''''''''''''''''''''''''''''''''''''''''''''''

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()
''''''''''''''''''''''''''''''''''''''''''''''''''
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

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()
''''''''''''''''''''''''''''''''''''''''''''''''''
Message 3 of 5
Anonymous
in reply to: Anonymous

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
Message 4 of 5
Anonymous
in reply to: Anonymous

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
Message 5 of 5
Anonymous
in reply to: Anonymous

Hi, Albert :
Thanks for your Help!!

Regards.
John Jiang

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