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

How to draw a cylinder using vb.net

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

How to draw a cylinder using vb.net

Hi:
I want to draw a 3d cylinder through the origion point raduis
path(axis),height or the start point and end point of the center axis of the
cylinder
I found the cylinder object as a member of the geometry elements but i don't
know how could i add this cylinder thpe to the drawing database as i could
see it in the drawing.

Thanks in advance.

--
Nermeen Bakr
Project Manager
MCS (Modern Computing Services)
Website: http://www.mcsoil.com
Phone: +2 02 4036520 /+202 4051129
Fax: +2 02 4040503
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

I'm struggling with this too:

Imports Autodesk.AutoCAD
'Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.ApplicationServices

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myTransMan As DatabaseServices.TransactionManager
Dim myTrans As DatabaseServices.Transaction
Dim myDWG As Document
Dim myBT As BlockTable
Dim myBTR As BlockTableRecord
Dim myCylinder As Cylinder
Dim StartPoint As Geometry.Point3d
Dim EndPoint As Geometry.Point3d

myDWG = Application.DocumentManager.MdiActiveDocument
myTransMan = myDWG.TransactionManager
myTrans = myTransMan.StartTransaction

'open database for read
myBT = myDWG.Database.BlockTableId.GetObject(OpenMode.ForRead)

'open ModelSpace for write
myBTR = myBT(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)

StartPoint = myDWG.Editor.GetPoint("Select Start Point: ").Value
EndPoint = myDWG.Editor.GetPoint("Select End Point: ").Value

'create the cylinder
myCylinder = New Cylinder(7.723, StartPoint, EndPoint)
'Add cylinder to Modelspaces block table record
myBTR.AppendEntity(myCylinder)
'Add cylinder to the transaction
myTrans.AddNewlyCreatedDBObject(myCylinder, True)
'commit transaction
myTrans.Commit()
'dispose transaction
myTrans.Dispose()
myTransMan.Dispose()

End Sub
Message 3 of 5
Anonymous
in reply to: Anonymous

I'm not going to comment on this, other than to say that you need to learn how to structure your app, as it relates to acquiring user input, and accessing the database.

Generally, you acquire all user input before you access the database or its contents, where that's possible. Once you've obtained the needed input successfully, only then do you start a transaction
and open objects.

Read the ObjectARX docs, and note where they discuss the patterns relating to opening and closing objects, and how you should keep objects open only as long as absolutely necessary and close them as soon as possible.

What you definitely should not do is open an object for write, and then acquire input. The chances that AutoCAD or another application may try to open an object while getting user input (e.g., for things like object snap, etc.), are very good, and in that case, if an object or one of its owners is currently open for write, kaboom.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5792878@discussion.autodesk.com...
I'm struggling with this too:

Imports Autodesk.AutoCAD
'Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.ApplicationServices

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myTransMan As DatabaseServices.TransactionManager
Dim myTrans As DatabaseServices.Transaction
Dim myDWG As Document
Dim myBT As BlockTable
Dim myBTR As BlockTableRecord
Dim myCylinder As Cylinder
Dim StartPoint As Geometry.Point3d
Dim EndPoint As Geometry.Point3d

myDWG = Application.DocumentManager.MdiActiveDocument
myTransMan = myDWG.TransactionManager
myTrans = myTransMan.StartTransaction

'open database for read
myBT = myDWG.Database.BlockTableId.GetObject(OpenMode.ForRead)

'open ModelSpace for write
myBTR = myBT(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)

StartPoint = myDWG.Editor.GetPoint("Select Start Point: ").Value
EndPoint = myDWG.Editor.GetPoint("Select End Point: ").Value

'create the cylinder
myCylinder = New Cylinder(7.723, StartPoint, EndPoint)
'Add cylinder to Modelspaces block table record
myBTR.AppendEntity(myCylinder)
'Add cylinder to the transaction
myTrans.AddNewlyCreatedDBObject(myCylinder, True)
'commit transaction
myTrans.Commit()
'dispose transaction
myTrans.Dispose()
myTransMan.Dispose()

End Sub
Message 4 of 5
Anonymous
in reply to: Anonymous

Thank you for your comments Tony. I have only been looking at .Net for a few weeks in my lunch half hour (wish I had an hour - grrr!). I am using the code from pages 59 & 69 of Jerry Winter's VB.Net book. I find it useful to work through his exercises then to try and adapt them for something that I can use in my job.

In his example he accesses the database thingy first then gets user input and creates the entity.

Guess I'm just trying to pass the buck!
Message 5 of 5
Anonymous
in reply to: Anonymous

Let me apologize in advance to anyone that may be offended by this, but I have tell you that if you got that code from a book, I would have no choice but to give that book a big thumbs down, regardless of who wrote/published/edited it.

Sorry again. Books are things that people write when they have expertise to share, and those who pay them money for their work have a right to hold the author(s), publisher, and technical editor(s) accountable for inacurracies and/or technically flawed or inferior content, within the domain of expertise.

If you're serious about this, consider Autodesk API training, as their instructors are qualified and know what they're doing.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5792924@discussion.autodesk.com...
Thank you for your comments Tony. I have only been looking at .Net for a few weeks in my lunch half hour (wish I had an hour - grrr!). I am using the code from pages 59 & 69 of Jerry Winter's VB.Net book. I find it useful to work through his exercises then to try and adapt them for something that I can use in my job.

In his example he accesses the database thingy first then gets user input and creates the entity.

Guess I'm just trying to pass the buck!

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