Hi,
When using VB.NET to draw a cone, the auto cues ask for:
cosineangle as double - what is this?
sinangle as double - what is this?
baseorigin as Point3D - obvious
base radius as double - obvious
axis of symetry as vector3D - what is this?
reference axis as vector3D - what is this?
height as Autodesk.AutoCAD.Geometry.Interval
- obvious
startangle as double
end angle as double. - presumably this and the start angle allow segments of a cone to be drawn, so I would try 0 and two pi
Searching this NG and Google does not return any clues as to the actual realities of the pararmeters I've questioned.
Assumming I have all the transaction code in place is the following code like to function to draw a unit height cone at 0,0,0?
Dim dHeight As Autodesk.AutoCAD.Geometry.Interval = 1 Dim dCosineAngle As Double = 1 ' Guess this as Cos(0) Dim dSineAngle As Double = 0 ' Guess this as Sin(0)
Dim CenterPoint As New Geometry.Point3d(0, 0, 0)
Dim dBaseRadius As Double = 0.5
Dim AxisOfSyymetry As New Vector3d(0, 0, 1) ' Guess this as the Z axis Dim ReferenceAxis As New Vector3d(1, 0, 0) ' Guess this as the X axi Dim myCone As New Cone(dCosineAngle, dSineAngle, CenterPoint, dBaseRadius, AxisOfSyymetry, ReferenceAxis, dHeight, 0, 2 * Math.PI) myTrans.AddNewlyCreatedDBObject(myCone, True)
Solved! Go to Solution.
Solved by laurie.comerford. Go to Solution.
Hi Laurie,
not that I'm knowing each of these parameters, I have more a global question that may put you away from what you are doing currently.
The question is: are you trying to create a Geometry.Cone to get it placed into the database? IMHO that will not work, you should start with "new DatabaseServices.Solid" and create the cone with revolve or extrude (as shown >>>here<<< by Kean Walmsley).
At least this statement:
myTrans.AddNewlyCreatedDBObject(myCone, True)
will not work as long as the cone is a type defined in the Geometry-namespace.
- alfred -
Hi Alfred,
Thank you and Ken. While I can learn from my mistakes, it's so much easier when someone points out where the mistake lies.
I put Ken's C# code through:
http://www.developerfusion.com/tools/convert/csharp-to-vb/
and checked it successfully.
My need for a cone is very simple and I've modified Ken's code as shown below to show how I'll normally use it:
'' This is the typical way I will use the DrawCone Sub, but there are more options allowed for
<CommandMethod("TDC")> _
Sub TestDrawCone()
Dim Pt2D As New Point2d(0, 0)
DrawCone(Pt2D)
End Sub
Public Sub DrawCone(ByVal InsertionPoint As Point2d, _
Optional ByVal dpHeight As Double = 1, _
Optional ByVal dpRadius As Double = 0.05, _
Optional ByVal dpTopRadius As Double = 0, _
Optional ByVal spLayerName As String = "0")
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim bCreateHistory As Boolean = True
Dim Pt3D As New Point3d(0, 0, dpHeight / 2)
Dim dTopRadius As Double = 0
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Using tr
' Create the solid and set the history flag
Dim oSolid As New Solid3d()
oSolid.RecordHistory = bCreateHistory
oSolid.CreateFrustum(dpHeight, dpRadius, dpRadius, dpTopRadius)
oSolid.Layer = spLayerName
' Add the Solid3d to the modelspace
Dim bt As BlockTable = DirectCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
Dim ms As BlockTableRecord = DirectCast(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
ms.AppendEntity(oSolid)
tr.AddNewlyCreatedDBObject(oSolid, True)
' And transform it to the selected point
oSolid.TransformBy(Matrix3d.Displacement(Pt3D - Point3d.Origin))
tr.Commit()
End Using
End Sub ' DrawCone