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))
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)
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:
- Link: Python for AutoCAD pyautocad module
- Link: add() method in pyautocad
- Link: Solved call was rejected by callee in pythoncom
- Link: Tree data structure for AutoCAD objects using Python
- Link: Extending the objects in AutoCAD using pyautocad in Python
- Link: Using Python lists and dictionaries to work with AutoCAD objects with pyautocad
- Link: Hatching objects on AutoCAD template using pywin32 in Python
- Link: Raster image object in AutoCAD with pyautocad in Python
- Link: Working with 3D mesh object in AutoCAD using pyautocad in Python
- Link: Creating adouble constructor using pywin32 in Python
- Link: Creating apoint method using pywin32 in Python
- Link: Python integration with AutoCAD using pywin32 and win32com
- Link: Deleting objects in a AutoCAD template with pyautocad and pywin32 in Python
- Link: Mirror object on a 2D plane with pyautocad in Python
- Link: Working with texts in Autocad using pyautocad in Python
- Link: Polar arrays in AutoCAD using pyautocad in Python
- Link: Rectangular arrays in AutoCAD using pyautocad in Python
- Link: Operations with AutoCAD objects using pyautocad in Python
- Link: Solid objects in AutoCAD using pyautocad in Python
- Link: Working with helices in AutoCAD using pyautocad in Python
- Link: Drawing splines in AutoCAD with pyautocad in Python
- Link: Polylines in pyautocad for drawing AutoCAD polygons in Python
- Link: Drawing ellipse arcs in AutoCAD using pyautocad in Python
- Link: Drawing arcs in AutoCAD using pyautocad in Python
- Link: Near simultaneous factory design and process optimization with Promodel AutoCAD edition
- Link: Python for AutoCAD pyautocad module
- Link: Region object in AutoCAD with Python
Civil engineer interested in automation in core subjects such as civil, mechanical and electrical, using IT skills comprising cloud computing, devops, programming languages and databases along with the technical skills gained while working as a civil engineer since past 3 years.
Leave a Reply