Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Create region in AutoCAD using pyautocad (Python)

tanmayms3009
Participant

Create region in AutoCAD using pyautocad (Python)

tanmayms3009
Participant
Participant

Hi, 

 

According to the documentation for the "AddRegion" method provided on AutoCAD2022 Developer and ObjectARX Help: "https://help.autodesk.com/view/OARX/2022/ENU/?guid=GUID-74C8765E-EB4A-4773-ADD4-6C0F318FE6BE"

we need to pass the safearray of objects to Block or Modelspace to create a region.

 

Since I have been working on documenting the use of pyautocad as a means to automate AutoCAD tasks, I want to perform the same operation using python. But none of the python-based data structures (e.g. List, Tuples, Sets etc.) worked for adding a region. Also, I tried creating a customized array using "win32com" module, still no satisfactory output. Can anyone please guide me through this?

 

Thanks in advance.

0 Likes
Reply
Accepted solutions (2)
1,439 Views
4 Replies
Replies (4)

Alexander.Rivilis
Mentor
Mentor
Accepted solution

Try this code: https://adn-cis.org/forum/index.php?topic=7864.msg45040#msg45040

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes

tanmayms3009
Participant
Participant

Many thanks for the response, Sir.

 

Can you please also tell me how to get a Region object in return? Because the AddRegion does not return a Region object but an Array of Variants. 

 

Thanks in advance!

0 Likes

Alexander.Rivilis
Mentor
Mentor
Accepted solution

изображение.png

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes

tanmayms3009
Participant
Participant

Yes correct. Thanks for your help once again.

0 Likes