Create region in AutoCAD using pyautocad (Python)

Create region in AutoCAD using pyautocad (Python)

tanmayms3009
Participant Participant
2,160 Views
4 Replies
Message 1 of 5

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
Accepted solutions (2)
2,161 Views
4 Replies
Replies (4)
Message 2 of 5

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
Message 3 of 5

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
Message 4 of 5

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
Message 5 of 5

tanmayms3009
Participant
Participant

Yes correct. Thanks for your help once again.

0 Likes