# Acad object survey ```Sub demo_solid()
Call connect_acad
Dim objent As Acad3DSolid
Dim R As Double
R = 5

Call convert_pt0(R, 0, 0)
Set objent = acadDoc.ModelSpace.AddBox(pt0, 2, 1.5, 1)

Call convert_pt0(R, 45, 1)
Set objent = acadDoc.ModelSpace.AddCone(pt0, 1, 2)

Call convert_pt0(R, 90, 2)
Set objent = acadDoc.ModelSpace.AddCylinder(pt0, 1, 1)

Call convert_pt0(R, 135, 3)
Set objent = acadDoc.ModelSpace.AddSphere(pt0, 1)

Call convert_pt0(R, 180, 2)
Set objent = acadDoc.ModelSpace.AddTorus(pt0, 1.5, 0.375)

Call convert_pt0(R, 225, 1)
Set objent = acadDoc.ModelSpace.AddWedge(pt0, 2, 1, 1)

Call convert_pt0(R, 270, 0)
Set objent = acadDoc.ModelSpace.AddEllipticalCone(pt0, 2, 1, 2)

Call convert_pt0(R, 315, 1)
Set objent = acadDoc.ModelSpace.AddEllipticalCylinder(pt0, 1.5, 1, 1)

Update
acadDoc.SendCommand "_shade" & vbCr
End Sub

Sub convert_pt0(R As Double, A As Double, Z As Double)
Dim A_rad As Double
Dim X As Double, Y As Double
A_rad = deg2rad(A)
X = R * Cos(A_rad)
Y = R * Sin(A_rad)
pt0(0) = X: pt0(1) = Y: pt0(2) = Z
End Sub
```

These are autocad primitive solids. There are interface commands to join them and cut.

There are also 3 vba methods to create solids from Region objects. A Region is a 2d figure, a bounded loop. It can be constructed from lines, polylines, circles, arcs, splines.
ADDEXTRUDEDSOLID
ADDEXTRUDEDSOLIDALONGPATH
ADDREVOLVEDSOLID

dont forget to choose developer or search is stupid

http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-B9DEA4C5-EDAA-4CC6-93B0-394D5991A0E6

http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-2EDFD984-A178-4F1D-8F97-351E141D3DA4

http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-C23158D9-F68B-44C6-B323-8196D8D5224D

To use these in a program we will need to develop Region techniques.

```Sub revolve_code()
'this is pseudo code, declarations are skipped, taken from autocad help file
'to create a region, create an array of acad objects that form a coplanar loop
Dim curves(0 To 1) As AcadEntity
'addregion returns an array of regions, acadregion is not used as object type
Dim regionObj As Variant
Dim solidObj As Acad3DSolid

'draw the loop objects and add them to the array
Set curves(0) = acadDoc.ModelSpace.AddArc(centerPoint, radius, startAngle, endAngle)
Set curves(1) = acadDoc.ModelSpace.AddLine(curves(0).StartPoint, curves(0).EndPoint)

'addregion takes an array of acad objects
'it will make multiple regions if fed appropriate data
'return type is an array of region objects
regionObj = acadDoc.ModelSpace.AddRegion(curves)

Set solidObj = acadDoc.ModelSpace.AddRevolvedSolid(regionObj(0), axisPt, axisDir, angle)
End Sub
```
Advertisements

This site uses Akismet to reduce spam. Learn how your comment data is processed.