AutoCAD 3D pyramid: Object, properties, API

In this post I provide an introduction to and documentation of the AutoCAD 3D pyramid object. This post is part of our AutoCAD automatization documentation that demonstrates successful implementation of APIs in VBA and also Python for AutoCAD automatization. You can find related links to this documentation at the bottom of this post.

Drawing AutoCAD 3D pyramid object

To draw a 3D pyramid in AutoCAD, you can use the following steps:

  1. Open AutoCAD application.
  2. Create a new drawing and save it.
  3. Select the “3D Modeling” workspace in AutoCAD software.
  4. Set the current elevation level to 0, ensuring that the AutoCAD 3D pyramid is drawn on the XY plane.
  5. Go to the “Home” tab.
  6. Access “3D Modeling” panel.
  7. Click “Pyramid” button.
  8. In the “Pyramid” dialog box displayed, specify the base width and height of the pyramid object.
  9. Click on the “Create” button.
  10. Use the mouse to specify pyramid base center point.
  11. Drag the cursor to specify pyramid height.
  12. Release the mouse button to create the pyramid.
  13. To adjust the appearance of the pyramid, you can use the “Properties” palette, allowing you to :
    • Change line thickness.
    • Change line color.
    • Change other visual properties.
  14. You can also use the “View” tab to change the perspective and shading of the 3D model.

Properties of the AutoCAD 3D pyramid object

To access and modify properties of any AutoCAD object, you can use the “Properties” palette. You can also right-click on the pyramid and select “Properties” from the context menu.

Here are som common properties that you can modify for the AutoCAD pyramid object:

  • Base width and height: These properties determine the size of the base of the pyramid.
  • Height: This property determines the height of the pyramid from the base to the apex.
  • Apex: This property determines the location of the apex, or top point, of the pyramid.
  • Surface properties: You can modify the appearance of the surface of the pyramid, such as the color, line thickness, and shading.
  • Line properties: You can modify the appearance of the lines that define the edges of the pyramid, such as the color and line thickness.
  • Material: You can assign a material to the pyramid, which determines its appearance when rendered.

The exact properties of a pyramid object in AutoCAD depend on the version of AutoCAD you are using and the settings you are using.

Modifying AutoCAD 3D pyramid with VBA

You can modify pyramid properties in AutoCAD with VBA. Open the AutoCAD drawing containing the pyramid object. Press ALT+F11 to open the VBA editor. Then, in the VBA editor, select the “Insert” menu and then choose “Module”. A new module in the project explorer for implementing VBA code results from this.

In the new module the following subroutine should be specified to modify pyramid properties.

Sub ModifyPyramid()
End Sub

Inside the subroutine, use the following code to retrieve the pyramid object from the drawing:

Dim pyramid As Acad3DPolyline
Set pyramid = ThisDrawing.ModelSpace.Item(1)

Use the following code to modify the properties of the pyramid object:

pyramid.BaseWidth = 5 ' set the base width to 5
pyramid.BaseHeight = 10 ' set the base height to 10
pyramid.Height = 15 ' set the height to 15
pyramid.Update

Run the subroutine by pressing the “F5” key or by selecting “Run” from the “Debug” menu.

Modifying AutoCAD 3D pyramid object in Python

Besides VBA you can e.g. also use Python for modifying AutoCAD 3D pyramid properties. You can e.g. use win32com.

Here is a brief demonstration. It assumes a drawing that already contains a AutoCAD 3D pyramid object.

pip install pypiwin32

import win32com.client
import pythoncom

acad = win32com.client.GetActiveObject("AutoCAD.Application")

pyramid = acad.ActiveDocument.ModelSpace.Item(1)

pyramid.BaseWidth = 5 # set the base width to 5
pyramid.BaseHeight = 10 # set the base height to 10
pyramid.Height = 15 # set the height to 15
pyramid.Update()

In the example above the base width, base heigt, and height properties where adjusted.

Related AutoCAD documentation

If you are interested in learning more about AutoCAD and AutoCAD automatization you can e.g. see the following exemplaric extract of our AutoCAD documentation:

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Close

Meta