Active Contributor
Posts: 48
Registered: ‎09-08-2006
Message 1 of 3 (293 Views)
Accepted Solution

Drawing a cone - parameter meanings

293 Views, 2 Replies
12-04-2011 04:20 AM



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)




Laurie Comerford
*Expert Elite*
Posts: 8,963
Registered: ‎06-29-2007
Message 2 of 3 (289 Views)

Re: Drawing a cone - parameter meanings

12-04-2011 06:44 AM in reply to: laurie.comerford

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 -

Ingenieur Studio HOLLAUS ... www.hollaus.at
Active Contributor
Posts: 48
Registered: ‎09-08-2006
Message 3 of 3 (279 Views)

Re: Drawing a cone - parameter meanings

12-04-2011 01:56 PM in reply to: laurie.comerford

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:


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)
    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)
            tr.AddNewlyCreatedDBObject(oSolid, True)
            ' And transform it to the selected point
            oSolid.TransformBy(Matrix3d.Displacement(Pt3D - Point3d.Origin))
        End Using
    End Sub ' DrawCone


Laurie Comerford
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 or visit the Installation and Licensing Forum to get help installing your software.