The Torus

Use the AddTorus method to create a torus and add it at a given point in a drawing, such that the ring lays flat in the XY plane.

Set 3DSolidObject = Object.AddTorus(TorusCenter, TorusRadius, TubeRadius)

Table 9-5 presents the AddTorus method's parameters, and Figure 9-5 shows an example of a torus in AutoCAD.

Table 9-5. The AddTorus Method's Parameters

Name

Data Type

Description

TorusCenter

Variant

A three-element array of doubles specifying the point about which the torus is centered in WCS coordinates

TorusRadius

Double

A positive value representing the distance from the torus's center to the tube's center

TubeRadius

Double

A positive value representing the tube's radius

Autocad Script End

Figure 9-5. A torus

The following example creates a torus based on user input:

Public Sub TestAddTorus()

Dim pntPick As Variant Dim pntRadius As Variant Dim dblRadius As Double Dim dblTube As Double Dim objEnt As Acad3DSolid Dim intI As Integer

'' set the default viewpoint SetViewpoint

'' get input from user With ThisDrawing.Utility .InitializeUserlnput 1

pntPick = .GetPoint(, vbCr & "Pick the center point: ") .InitializeUserlnput 1

pntRadius = .GetPoint(pntPick, vbCr & "Pick a radius point: ") .InitializeUserInput 1 + 2 + 4, ""

dblTube = .GetDistance(pntRadius, vbCr & "Enter the tube radius: ") End With

'' calculate radius from points For intI = 0 To 2

dblRadius = dblRadius + (pntPick(intI) - pntRadius(intI)) A 2

Next dblRadius = Sqr(dblRadius) '' draw the entity

Set objEnt = ThisDrawing.ModelSpace.AddTorus(pntPick, dblRadius, dblTube) objEnt.Update

ThisDrawing.SendCommand "_shade" & vbCr End Sub

Was this article helpful?

0 0

Post a comment