Add extruded solid along path in AutoCAD

In this article, I will discuss the AddExtrudedSolidAlongPath-method. This is part of my AutoCAD automatization series in Python.

The AddExtrudedSolidAlongPath method is basically used to create solid objects out of a 2D object by guiding the same into a particular direction/path.

Prerequisites for creating a solid object in AutoCAD

Firstly, to create a solid object out of the 2D plane I need a region in one plane and a path along which I want the region object to extrude.

It must be remembered that the region and the path shall be in different planes than each other being a 3D object.

Also, make sure to check out my article on creating the region in AutoCAD using Python.

#Circle
c1 = acad.AddCircle(ap(100, 100, 0), 50)
c2 = acad.AddCircle(ap(100, 100, 0), 45)
########################################
#Region
r1 = acad.AddRegion(win32com.client.VARIANT(VT_ARRAY | VT_DISPATCH, (c1, c2)))

#Path
a1 = acad.AddLine(ap(1000, 1000, 0), ap(1000, 1000, 1500))
2D Region of circles and line to guide as path extending in Z-axis

Creating solid objects using AutoCAD region and path

As I know the AddRegion method does not return the region object but an array of objects in that region (Variant).

Due to this, I need to iterate over the drawing to fetch the region object and use the same to create a solid object.

for obj in acad:
    if obj.ObjectName=="AcDbRegion":
        acad.AddExtrudedSolidAlongPath(obj, a1)
Using AddExtrudedSolidAlongPath in Python for AutoCAD extrusion

Finally, this is how I can create solid objects along the path extending any 2D region.

Concluding remarks and related content

For further blog posts covering AutoCAD automatization please check my other blog posts related to pyautocad and pywin32. Please leave any questions that you might have as a comment below. Feel free to contact me for any technical assistance. You can do so by using our contact form.

Here are some related articles covering AutoCAD automatization and AutoCAD scripting in Python:

Leave a Reply

Leave a Reply

Your email address will not be published.

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

Close

Meta