ID:
PW:

     0 ºÐ
     23 ºÐ

¿£Áö´Ï¾î µ¹Á¾
  dolljong
ÇÁ·Î±×·¡¹Ö Tips
ÇÁ·Î±×·¡¹Ö¿¡ °üÇÑ TipÀ» °øÀ¯ÇÏ´Â °÷ÀÔ´Ï´Ù.


(¿£Áö´Ï¾î¸¦ À§ÇÑ)ÆÄÀ̽㠽ÃÀÛÇϱâ[15] ÆÄÀ̽ã-ijµå ¿¬µ¿(pyautocad)
À̼®Á¾  2022-12-20 16:18:01, Á¶È¸ : 1,177, Ãßõ : 125
- Download #1 : engpython15.png (47.9 KB), Download : 18


(¿£Áö´Ï¾î¸¦ À§ÇÑ) ÆÄÀ̽㠽ÃÀÛÇϱâ[15]

 

³»¿ë : ÆÄÀ̽ã-CAD ¿¬µ¿-1/2(pyautocad,pyzwcad)

ÂüÁ¶ : https://pypi.org/project/pyautocad/  (pyautoacad - AutoCAD Automation for Python

)

https://pyautocad.readthedocs.io/en/latest/ (Welcome to pyautocad¡¯s documentation!)

https://pypi.org/project/pyzwcad/ (pyzwcad - ZwCAD Automation for Python)

 

 

0.½ÃÀÛÇϸç

¿£Áö´Ï¾îµéÀÌ ¸¹ÀÌ »ç¿ëÇÏ´Â ¼ÒÇÁÆ®¿þ¾î Áß ¿¢¼¿°ú ÇÔ²² °¡Àå ¸¹ÀÌ »ç¿ëÇÏ´Â ¼ÒÇÁ¿þ¾î°¡ CADÀÏ °ÍÀÌ´Ù. ¼³°è¶ó´Â °ÍÀÌ ±âȹ-°èȹ-°è»ê(ºÐ¼®)-µµ¸éÀÛ¼ºÀÇ ¼øÀ¸·Î ÀÌ·ç¾îÁö°í ÃÖÁ¾ ¼º°úÇ°Àº µµ¸éÀÌ´Ù. Çѱ¹¿¡¼­´Â AutoCAD½ÃÀå Á¡À¯À²ÀÌ ¸Å¿ì ³ô´Ù. pythonÀ» Áö¿øÇÏ´Â CAD´Â AutoCAD, ZWCAD°¡ ÀÖ´Ù. (pypi.org »çÀÌÆ®±âÁØ) ´ëºÎºÐÀÇ Àú°¡Çü ijµå´Â AutoCAD¸¦ ¸ð»çÇßÀ¸¹Ç·Î »ç¿ë¹ýÀÌ °ÅÀÇ ºñ½ÁÇÏ´Ù°í º¸¸é µÇ°Ú´Ù. ´ëºÎºÐÀÇ CAD´Â LISP, C#, C++, Visual BasicÀ» Áö¿øÇÑ´Ù. ÇÏÁö¸¸ ÆÄÀ̽ãÀ» ÀÌ¿ëÇÏ´Â ÀÌÀ¯´Â ÆÄÀ̽ãÀÌ ¶óÀ̺귯¸®°¡ ´Ù¾çÇÏ°í ´Ù¸¥ ¸ñÀûÀ¸·Î °³¹ßÇÏ´Â ÇÁ·Î±×·¥(¿¹¸¦ µé¾î ±¸Á¶°è»êÇÁ·Î±×·¥)°ú ¿¬µ¿Çϱâ À§Çؼ­´Ù. Áï ÆÄÀ̽ã ÄÚµå Çϳª·Î ´Ù¸¥ ±â´ÉµéÀ» ¸ðµÎ ±¸ÇöÇϱâ À§ÇÔÀÌ´Ù.  

 

1. ActiveX , COM, comtypes

ÆÄÀ̽ãÀ¸·Î CAD¸¦ ÅëÁ¦Çϱâ À§Çؼ­´Â pyautocad°¡ ¼³Ä¡µÇ¾î ÀÖ¾î¾ß ÇÑ´Ù. ÀÌ ÇÁ·Î±×·¥ÀÇ ¼³¸í¿¡´Â This library aimed to simplify writing ActiveX Automation scripts for AutoCAD with Python¡¯¶ó°í ½áÀÖ´Ù. ActiveXÀÛ¼ºÀ» ½±°Ô Çϱâ À§ÇÑ ¶óÀ̺귯¸®¶ó´Â °ÍÀÌ´Ù. ±×·¸´Ù¸é ActiveX´Â ¶Ç ¹«¾ùÀΰ¡? ±íÀÌ ¾Ë ÇÊ¿ä´Â ¾øÁö¸¸ ´ëÃæ ÀÌ·± °ÍÀÌ´Ù Á¤µµ ¾Ë°í ³Ñ¾î°¡ÀÚ. ActiveX´Â ¸¶ÀÌÅ©·Î¼ÒÇÁÆ®°¡ ¸¸µç ±â¼ú·Î ÇÁ·Î±×·¥°£¿¡ ¼ÒÅëÇÒ ¼ö ÀÖµµ·Ï ÇØÁÖ´Â ±â¼úÀÌ´Ù. ÀÌÁ¤µµ¸¸ ¾Ë°í ÀÖÀÚ. COM(Component Object Model) °ú OLE(Object Linking and Embedding)¸¦ ÇÕÃļ­ ActiveX¶ó°í ºÒ·¶´Ù°í ÇÑ´Ù. OLE´Â ¾Æ¸¶µµ ¸¶ÀÌÅ©·Î¼ÒÇÁÆ® ¿¢¼¿À» ¾µ ¶§ µé¾îº» ÀûÀÌ ÀÖÀ» °ÍÀÌ´Ù. pythonÀ» ÀÌ¿ëÇؼ­ CADÇÁ·Î±×·¥À» ÅëÁ¦ÇÏ´Â °ÍÀº COM±â¼úÀ» ÀÌ¿ëÇÏ´Â °ÍÀ̶ó´Â °Í Á¤µµ¸¸ ¾Ë¾ÆµÎÀÚ.

À̹ø °Ô½Ã¹°¿¡¼­´Â pyautocad¶ó´Â ¶óÀ̺귯¸®¸¦ ÀÌ¿ëÇÏ°ÚÁö¸¸ ´ÙÀ½ °Ô½Ã¹°¿¡´Â comtypes¶óÀ̺귯¸®¸¦ ÀÌ¿ëÇÒ °ÍÀÌ´Ù. µÑ ´Ù COM±â¼úÀ» ÀÌ¿ëÇÏ´Â °ÍÀÌÁö¸¸ pyautocad´Â autocad¸¦ À§Çؼ­ ´Ü¼øÇÏ°Ô ¸¸µç °ÍÀÌ°í comtypes´Â autocad»Ó ¾Æ´Ï¶ó ¿¢¼¿ µî¿¡µµ Àû¿ëÇÒ ¼ö ÀÖ´Â ¹ü¿ë ±â¼úÀ̶ó°í »ý°¢ÇÏ¸é µÇ°Ú´Ù.

 

2. pyautocad ¼³Ä¡Çϱâ.

ÆÄÀ̽ãÀ¸·Î CAD¸¦ ÅëÁ¦Çϱâ À§Çؼ­ pyautocad¸¦ ¼³Ä¡ÇÏÀÚ. pip¸í·ÉÀ» ÀÌ¿ëÇÏ¸é µÈ´Ù.

pip install pyautocad

 

(base) D:\dev\python\pyautocad>pip show pyautocad
Name: pyautocad
Version:
0.2.0
Summary: AutoCAD Automation
for Python
Home-page: https://github.com/reclosedev/pyautocad
Author: Roman Haritonov
Author-email: reclosedev@gmail.com
License: BSD License
Location: c:\programdata\anaconda3\
lib\site-packages
Requires: comtypes
Required-
by:

 

pyautocad¸¦ ¼³Ä¡ÇÑ ÈÄ pip show pyautocad ¸í·ÉÀ¸·Î Á¤º¸¸¦ »ìÆ캸ÀÚ. Requires¿¡ comtypes°¡ ÀÖ´Â °ÍÀ» ¾Ë ¼ö ÀÖ´Ù. ¾Õ¿¡¼­ ¼³¸íÇÑ °Íó·³ pyautocadµµ comtypes ¶óÀ̺귯¸®¸¦ ÀÌ¿ëÇÑ´Ù.

 

pyzwcad·Î ¸¶Âù°¡Áö ¹æ¹ýÀ¸·Î ¼³Ä¡ÇÏ¸é µÈ´Ù.

pyautocad´Â 2015³â, pyzwcad´Â 2020³âÀÌ ¸¶Áö¸· ¾÷µ¥ÀÌÆ®´Ù. pyautocad°¡ »ó´ç±â°£ ¾÷µ¥ÀÌÆ®°¡ ÀÌ·ç¾îÁöÁö ¾ÊÀº °ÍÀ» ¾Ë ¼ö ÀÖ´Ù. comtypesÀ̶ó´Â ±â¼ú·Î Ä¿¹ö°¡ °¡´ÉÇϱ⠶§¹®ÀÏ ¼öµµ ÀÖ´Ù.

 

3. ½ÃÀÛÇϱâ-ÆÄÀ̽ã°ú CAD¿¬°á

pyautocad¸¦ ÀÌ¿ëÇؼ­ CAD¿Í ¼ÒÅëÇÏ´Â °ÍºÎÅÍ Çغ¸ÀÚ. ¾Æ·¡ÀÇ Äڵ带 hello.py¶ó´Â À̸§À¸·Î ÀúÀåÇغ¸ÀÚ.

from pyautocad import Autocad
acad = Autocad()
acad.prompt(
"Hello, Autocad from Python\n")
print(acad.doc.Name)

 

acad=Autocad() : À̺κÐÀÌ ½ÇÇàµÇ¾î ÀÖ´Â AutoCAD¸¦ ÃëÇؼ­ acad¶ó´Â À̸§À¸·Î ÇÒ´çÇÑ°ÍÀÌ´Ù. ÀÌÁ¦ºÎÅÍ ½ÇÇàµÈ AutoCAD´Â acad¸¦ ÅëÇؼ­ Á¢±Ù °¡´ÉÇÏ´Ù.

acad.prompt(¡°~ ¡°) ÀÌ ¸í·ÉÀº autocad¸í·Éâ¿¡ ¹®ÀÚ¸¦ Ãâ·ÂÇÏ´Â ³»¿ëÀÌ´Ù.

acad.doc.NameÀº acadÀÇ ÆÄÀϸíÀ̶ó´Â ¶æÀÌ´Ù. ½ÇÇàÇÏ¸é ¾Æ·¡¿Í °°Àº °á°ú¸¦ º¼ ¼ö ÀÖ´Ù.

(base) D:\dev\python\pyautocad>python hello.py
Hello, Autocad
from Python

Drawing1.dwg

 

ijµå¸í·Éâ¿¡µµ acad.prompt() ¸í·ÉÀÇ °á°ú·Î Hello~ °¡ Ãâ·ÂµÈ °ÍÀ» º¼ ¼ö ÀÖ´Ù.

 

COM±â¼úÀ» ÀÌ¿ëÇÏ·Á¸é modelÀ» ¾Ë°í ÀÖ¾î¾ß ÇÑ´Ù. ¸ðµ¨À» °èÃþÀûÀ¸·Î ±¸Á¶È­ µÇ¾î Àֱ⠶§¹®¿¡ ¸ðµ¨À» ÀÌÇØÇÏ°í ÀÖÀ¸¸é ÀÚ½ÅÀÌ ¿øÇÏ´Â °´Ã¼¸¦ ¸¸µé°Å³ª ¿øÇÏ´Â ±â´ÉÀ» ã¾Æº¼ ¼ö ÀÖ´Ù. ÀÌ°ÍÀº VBA·Î CAD¿ë ÇÁ·Î±×·¥À» ¸¸µé ¶§µµ ¸¶Âù°¡Áö´Ù. ¾Æ·¡ µð·ºÅ丮¿¡ ÀÖ´Â chm µµ¿ò¸» ÆÄÀÏÀ» ¿­¾îº¸ÀÚ.

C:\Program Files\Common Files\Autodesk Shared\acadauto.chm

Çѱ۹öÀüÀÎ °æ¿ì¿¡´Â ¾Æ·¡ÀÇ µð·ºÅ丮¿¡ ÀÖ´Ù. C:\Program Files\Common Files\Autodesk Shared\ko-KR\acadauto.chm

AutoCAD Object ModelÀÌ´Ù. ApplicationÀ̶ó´Â °ÍÀÌ °¡Àå »óÀ§¿¡ ÀÖ°í ±× ¾Æ·¡ ü°èÀûÀ¸·Î ±¸¼ºµÇ¾îÀÖ´Ù. ApplicationÀº °ð AutoCAD¸¦ ¶æÇÑ´Ù. ¸»´ÜÀ» º¸¸é circle, line, textµîÀÌ ÀÖ´Â °ÍÀ» º¼ ¼ö ÀÖ´Ù. ÀÌ Á¤µµ¸¸ È®ÀÎÇÏ°í ³Ñ¾î°¡ÀÚ. pyautocad´Â ÀÌ Object¸ðµ¨À» ½±°Ô ´Ù·çµµ·Ï µµ¿ÍÁÖ´Â ¶óÀ̺귯¸®´Ù.

 

-       ijµå½ÇÇàÇϱâ

¾ÕÀÇ ¿¹¿¡¼­´Â ijµå°¡ ½ÇÇàµÇ¾îÀÖ´Â »óŸ¦ °¡Á¤ÇÏ°í ¿¬°á¸¸ Çß´Ù. acad=Autocad(). ijµå°¡ ½ÇÇàµÇ¾î ÀÖÁö ¾ÊÀº °æ¿ì¿¡´Â ¿¡·¯°¡ ¹ß»ýÇÑ´Ù. ±×·¡¼­ ¸¸¾à ijµå°¡ ½ÇÇàµÇ¾îÀÖÁö ¾ÊÀ» ¶§´Â ijµå¸¦ ½ÇÇàÇ϶ó´Â ¿É¼ÇÀ» Ãß°¡ÇÒ ¼ö ÀÖ´Ù. Autocad()¿¡ create_if_not_exists=True ¿É¼ÇÀ» Ãß°¡ÇØÁÖ¸é µÈ´Ù.

from pyautocad import Autocad
acad = Autocad(create_if_not_exists=
True)
acad.prompt(
"Hello, Autocad from Python\n")
print(acad.doc.Name)

 

ÀÌ Äڵ带 ½ÇÇàÇϸé ijµå°¡ ½ÇÇàµÇ°í ³­ ÈÄ acad.doc.NameÀÇ °á°úÀÎ Drawing1.dwgÀÌ ÄܼÖÅë¿¡ Ãâ·ÂµÇ´Â °ÍÀ» º¼ ¼ö ÀÖ´Ù.

 

4. °´Ã¼ Ãß°¡

ÆÄÀ̽ã°ú ijµå°¡ Àß ¿¬°áµÈ °ÍÀ» È®ÀÎÇß´Ù. À̹ø¿¡´Â ¼±À̳ª ¿ø, ÅؽºÆ® °°Àº °´Ã¼µéÀ» Ãß°¡ÇØ º¸ÀÚ. °´Ã¼¸¦ Ãß°¡Çϱâ À§Çؼ­´Â ÁÂÇ¥°¡ ÀÖ¾î¾ß Çϴµ¥ pyautocad¿¡¼­ APoint¶ó´Â ÁÂÇ¥ ŸÀÔÀ» Áö¿øÇÑ´Ù. »ç¿ë¹ýÀº APoint(x,y,z)¶ó°í ½áÁÖ¸é µÈ´Ù. z´Â »ý·«ÇÒ ¼ö ÀÖ´Ù. importÇÒ ´ë APointµµ importÇß´Ù.

from pyautocad import Autocad, APoint
acad = Autocad(create_if_not_exists=
True)
p1 = APoint(
0, 0)
p2 = APoint(
50, 25)
for i in range(5):
    text = acad.model.AddText(
u'Hi %s!' % i, p1, 2.5)
    acad.model.AddLine(p1, p2)
    acad.model.AddCircle(p1,
10)
    p1.y +=
10

°´Ã¼¸¦ Ãß°¡ÇÏ´Â method (ÇÔ¼ö)´Â AddText, AddLine, AddCircleÀÌ »ç¿ëµÇ¾ú´Ù. °´Ã¼´Â model¿¡´Ù Ãß°¡ÇÒ ¼ö ÀÖ´Ù. acad´Â AutoCADÇÁ·Î±×·¥, modelÀº Modelspace¶ó°í »ý°¢ÇÏ¸é µÈ´Ù. AutoCAD¿¡ ÀÖ´Â Modelspace¿¡ °´Ã¼¸¦ Ãß°¡ÇÏ´Â °ÍÀÌ´Ù.

-        Text Ãß°¡Çϱâ(AddText)

»ç¿ë¹ý : acad.model.AddText(¹®ÀÚ¿­, »ðÀÔÁ¡, ÅؽºÆ®Å©±â)

return : Text °´Ã¼

ÀÌ ¸Þ¼Òµå´Â ÅؽºÆ®¸¦ ±×¸®°í ÅؽºÆ® °´Ã¼¸¦ µ¹·ÁÁØ´Ù.

»ç¿ë¿¹ : acad.model.AddText(u¡¯'Hi %s!' % i, p1, 2.5)

  ¡°¾Õ¿¡ ºÙÀº u´Â À¯´ÏÄÚµå¶ó´Â ¶æÀÌ´Ù. i´Â 0ºÎÅÍ 4±îÁö º¯ÇÏ´Â for¹®ÀÌ Àû¿ëµÇ¾ú´Ù. p1Àº APoint()·Î Á¤ÀǵǾú´Âµ¥ óÀ½¿£ 0,0À¸·Î ½ÃÀÛÇß´Ù. for¹®ÀÇ ¸¶Áö¸·¿¡ p1.y+=10ÀÌ Àִµ¥ p1ÀÇ yÁÂÇ¥¸¦ Çѹø ¹Ýº¹ÇÒ ¶§¸¶´Ù 10¾¿ Áõ°¡½ÃŲ´Ù´Â ¶æÀÌ´Ù. ¸¸µé¾îÁø ÅؽºÆ®¸¦ text¶ó´Â º¯¼ö¿¡ ÇÒ´çÇß´Ù.

 

-        Line Ãß°¡Çϱâ(AddLine)

»ç¿ë¹ý : acad.model.AddLine(½ÃÀÛÁ¡, ³¡Á¡)

return : Line °´Ã¼

Àû¿ë¿¹ : acad.model.AddLine(p1, p2)

p1¿¡¼­ p2·Î lineÀ» ±×¸°´Ù.

 

-        Circle Ãß°¡Çϱâ(AddCircle)

»ç¿ë¹ý : acad.model.AddCircle(Áß½ÉÁ¡, ¹ÝÁö¸§)

return : Line °´Ã¼

Àû¿ë¿¹ : acad.model.AddCircle(p1, 10)

p1À» Áß½ÉÁ¡À¸·Î ÇÏ´Â ¹ÝÁö¸§ 10ÀÎ ¿øÀ» ±×¸°´Ù.

 

À§ÀÇ Äڵ带 ½ÇÇàÇÏ¸é ¾Æ·¡¿Í °°Àº °á°ú¸¦ º¼ ¼ö ÀÖ´Ù. 5°³ÀÇ ¿øÀ» yÁÂÇ¥¸¦ 10¾¿ Áõ°¡½ÃÅ°¸é¼­ ±×¸®°í ±× Á߽ɿ¡ Hi¿Í ¹øÈ£¸¦ ÅؽºÆ®·Î ½è´Ù. Áß½ÉÁ¡¿¡¼­ 50,25·Î ¼±À» ±×·È´Ù. 

 

 

5. °´Ã¼ º¯°æ

-        »ö»ó º¯°æ

°´Ã¼¸¦ Ãß°¡ÇÏ´Â °ÍÀ» ÇغôÙ. À̹ø¿¡´Â °´Ã¼¸¦ º¯°æÇغ¸ÀÚ.  °´Ã¼ÀÇ ¼Ó¼ºÀ» º¯°æÇϱâ À§Çؼ­´Â °´Ã¼ ´ÙÀ½¿¡ .À» Âï°í ¼Ó¼ºÀ» ½áÁÖ°í °ªÀ» ÇÒ´çÇØÁÖ¸é µÈ´Ù. for¹® ¾È¿¡¼­ ¸¸µé¾îÁø textÀÇ »öÀ» ¹Ù²ãº¸ÀÚ text.Color=iÀÌ·¸°Ô ¹Ù²ÙÀÚ. i´Â for¹® ¾È¿¡¼­ 0~4À¸·Î º¯ÇÑ´Ù. Áï ù¹ø° textÀÇ »öÀº 0, µÎ¹ø°´Â1¡¦ÀÌ·¸°Ô µÉ °ÍÀÌ´Ù.

 

from pyautocad import Autocad, APoint, ACAD
acad = Autocad()
acad.prompt(
"Hello, Autocad from Python\n")
print(acad.doc.Name)
p1 = APoint(
0, 0)
p2 = APoint(
50, 25)
for i in range(5):
    text = acad.model.AddText(
u'Hi %s!' % i, p1, 2.5)
    text.Color=i
    acad.model.AddLine(p1, p2)
    acad.model.AddCircle(p1,
10)
    p1.y +=
10

 

 

 

-        ÅؽºÆ® Á¤·Ä ¼³Á¤

ÅؽºÆ®¿¡ Á¤·ÄÀº ¸Å¿ì Áß¿äÇÏ´Ù. Á¤·ÄÀ» middle·Î ¼³Á¤Çغ¸°Ú´Ù. Alignment ¼Ó¼ºÀ» ¼³Á¤ÇØÁÖ¸é µÈ´Ù. Alignment¸¦ º¯°æÇϸé TextAlignmentPointµµ °°ÀÌ º¯°æÇØÁà¾ß ÇÑ´Ù.

from pyautocad import Autocad, APoint, ACAD

acad = Autocad()
acad.prompt(
"Hello, Autocad from Python\n")
print(acad.doc.Name)

p1 = APoint(
0, 0)
p2 = APoint(
50, 25)
for i in range(5):
    text = acad.model.AddText(
u'Hi %s!' % i, p1, 2.5)
    text.Color=i
    text.Alignment = ACAD.acAlignmentMiddle
    text.TextAlignmentPoint = p1
    acad.model.AddLine(p1, p2)
    acad.model.AddCircle(p1,
10)
    p1.y +=
10

 

textÀÇ Á¤·Ä¹æ¹ýÀ» ¼³Á¤Çϱâ À§Çؼ­ text.Alignment¼Ó¼ºÀ» ¼³Á¤ÇØÁØ´Ù. Á¤·Ä ¹æ¹ýÀº acAlignment~ ·Î ½ÃÀÛÇÏ´Â »ó¼ö·Î ¹Ì¸® ¼³Á¤µÇ¾îÀÖ´Ù. ÀÌ »ó¼ö¸¦ »ç¿ëÇÏ·Á¸é ACAD¸¦ importÇØ¾ß ÇÑ´Ù. Á¤·Ä¹æ¹ýµéÀº ¾Æ·¡¿Í °°´Ù. ÀÌ ¸ñ·ÏÀº ¾Õ¿¡¼­ À̾߱âÇÑ C:\Program Files\Common Files\Autodesk Shared\ko-KR\acadauto.chm µµ¿ò¸»ÀÎ ActiveX Reference Guide¿¡¼­ °¡Á®¿Â °ÍÀÌ´Ù. ¸ðµ¨ Áß text object¸¦ ¼±ÅÃÇÏ°í ±× Áß Aligment property¸¦ ¼±ÅÃÇÏ¸é ¸ñ·ÏÀ» º¼ ¼ö ÀÖ´Ù. pyautocadÀÇ ¹®¼­¿¡ ¸ðµç ¼³Á¤ÀÌ ¼³¸íµÇ¾îÀÖÁö ¾Ê´Ù. ActiveX Reference Guide¸¦ ÂüÁ¶ÇÏ¸é µÈ´Ù.

¡Ü      acAlignmentLeft

¡Ü      acAlignmentCenter

¡Ü      acAlignmentRight

¡Ü      acAlignmentAligned

¡Ü      acAlignmentMiddle

¡Ü      acAlignmentFit

¡Ü      acAlignmentTopLeft

¡Ü      acAlignmentTopCenter

¡Ü      acAlignmentTopRight

¡Ü      acAlignmentMiddleLeft

¡Ü      acAlignmentMiddleCenter

¡Ü      acAlignmentMiddleRight

¡Ü      acAlignmentBottomLeft

¡Ü      acAlignmentBottomCenter

¡Ü      acAlignmentBottomRight

Á¤·ÄÁ¡À» ¼³Á¤ÇÑ ÅؽºÆ®¸¦ ¼±ÅÃÇغ¸¸é »ðÀÔÁ¡(¿ÞÂÊ ¾Æ·¡) ¿Ü¿¡ Á¤·ÄÁ¡(Middle)µµ ¼³Á¤µÇ´Â °ÍÀ» È®ÀÎÇÒ ¼ö ÀÖ´Ù.

 

-        ÅؽºÆ® ȸÀü ¼³Á¤

ÅؽºÆ®ÀÇ °¢µµ¸¦ ¼³Á¤Çϱâ À§Çؼ­´Â Rotation ¼Ó¼ºÀ» ¼³Á¤ÇØÁÖ¸é µÈ´Ù. °¢µµ´Â RadianÀÌ´Ù. pi°ªÀ» »ç¿ëÇϱâ À§Çؼ­ import math¸¦ Ãß°¡ÇØÁà¾ß ÇÑ´Ù. °¢µµÀÇ ¹æÇâÀº ¹Ý½Ã°è ¹æÇâÀÌ +´Ù. 45µµ·Î ¼³Á¤Çϱâ À§Çؼ­ math.pi * 0.25¸¦ Àû¿ëÇß´Ù.

 

import math
text.Rotation = math.pi *
0.25

 

 

-        ´Ù¸¥ °´Ã¼ º¯°æ

¾Õ¿¡¼­ ÅؽºÆ®ÀÇ Á¤·Ä¹æ¹ýÀ» º¯°æÇÒ ¶§ ActiveX Reference Guide¸¦ ÂüÁ¶Çß´Ù. °¢ objectÀÇ ¼Ó¼ºµéÀ» ÆľÇÇÏ°í °Å±â¿¡ ¸Â°Ô ¼³Á¤ÇØÁÖ¸é µÈ´Ù. pyautocad°¡ ¸ðµç ¼Ó¼ºÀ» Áö¿øÇÏÁö´Â ¾Ê´Â´Ù. ¼Ó¼ºÀÇ À̸§ÀÌ ´Ù¸¥ °æ¿ìµµ ÀÖ´Ù. ¿¹¸¦ µé¾î textÀÇ color¼Ó¼ºÀº ActiveX¿¡´Â TrueColor·Î µÇ¾îÀÖ´Ù. µµ¸é¿¡¼­ »ç¿ëÇÏ´Â °´Ã¼ÀÇ Á¾·ù°¡ »ý°¢º¸´Ù ¸¹Áö ¾Ê´Ù. °¢ °´Ã¼º° ¿øÇÏ´Â ¼Ó¼ºÀ̳ª ¸Þ¼Òµå´Â ±¸±Û¸µÀ» Çϰųª ActiveX Reference¸¦ ÂüÁ¶ÇÏÀÚ.

 

 

6. °´Ã¼ ¼±ÅÃ

¿¹¸¦ µé¾î ÇöÀç µµ¸é¿¡ ±×·ÁÁø ¸ðµç ¿øÀÇ Áß½ÉÁ¡À» ÇöÀç Á¡¿¡¼­ ¿À¸¥ÂÊÀ¸·Î 10 ¸¸Å­ À̵¿ÇÏ·Á¸é ¾î¶»°Ô ÇØ¾ß ÇÒ±î? ¿ì¼± ÀÌ¹Ì ±×·ÁÁø ¿øÀ» ¼±ÅÃÇØ¾ß ÇÏ°í ±× ´ÙÀ½¿£ °¢ ¿ø¿¡ ´ëÇؼ­ º¯°æÀ» ÇÏ¸é µÉ °ÍÀÌ´Ù. ¿ì¼± ÇöÀç µµ¸é ³»ÀÇ ¸ðµç ¿øÀ» ¼±ÅÃÇÏ´Â ¹æ¹ýÀ» ¾Ë¾Æº¸ÀÚ.

¨ç µµ¸éÀüü¿¡¼­ ¼±ÅÃÇϱâ. acad.iter_objects(Á¶°Ç)

¨è »ç¿ëÀÚ°¡ ¼±ÅÃÇϱâ acad.get_selection(¡®¸Þ½ÃÁö¡¯)

 

¨ç acad.iter_objects(Á¶°Ç) : Àüü µµ¸é¿¡¼­ ¼±ÅÃÇϱâ

acad¿¡´Â pyautocad°¡ Áö¿øÇÏ´Â iter_objects()ÇÔ¼ö(¸Þ¼Òµå)°¡ ÀÖ´Ù. ÀÌ ¸Þ¼Òµå´Â ()¾È¿¡ ÁÖ¾îÁø Á¶°Ç¿¡ ¸Â´Â object¸®½ºÆ®¸¦ µ¹·ÁÁØ´Ù. ¾Æ·¡ ÄÚµå´Â À§ÀÇ ÄÚµåÀÇ ¸¶Áö¸·¿¡ Ãß°¡ÇÑ ÄÚµå´Ù. ¿©±â¿¡¼­ for¹®¿¡ »ç¿ëµÈ acad.iter_objects([¡®Circle¡¯,¡¯Line¡¯])Àº ¿ø°ú ¼±À» ¸ðµÎ ¼±ÅÃÇ϶ó´Â ¶æÀÌ´Ù.

for obj in acad.iter_objects(['Circle', 'Line']):
   
#print(obj.ObjectName)
   
if obj.ObjectName=='AcDbLine':
        print(obj.Length, obj.StartPoint, obj.EndPoint)
   
if obj.ObjectName=='AcDbCircle':
        print(obj.Area)

 

for¹® ¾ÈÀÇ ³»¿ëÀº ¼±ÅÃµÈ ObjectNameÀÌ ¡®AcDbLine¡¯(¡®Line¡¯ÀÌ ¾Æ´Ô¿¡ ÁÖÀÇÇÏÀÚ)ÀÌ¸é ¼±ÀÇ ±æÀÌ¿Í(obj.Length) ½ÃÀÛÁ¡(StartPoint), ³¡Á¡(EndPoint)¸¦ Ãâ·ÂÇϵµ·Ï ÇÏ°í ÀÖ´Ù. ±×¸®°í ObjectNameÀÌ ¡®AcDbCircle¡¯(¿ª½Ã ¡®Circle¡¯ÀÌ ¾Æ´Ô¿¡ ÁÖÀÇÇÏÀÚ)ÀÌ¸é ¿øÀÇ ¸éÀû(Area)¸¦ Ãâ·ÂÇϵµ·Ï ÇÏ°í ÀÖ´Ù.  ¾Æ·¡¿Í °°ÀÌ ¾Õ¿¡¼­ ±×·ÁÁø 5°³ÀÇ ¼±°ú ¿ø¿¡ ´ëÇؼ­ ¼±ÀDZæÀÌ, ½ÃÀÛÁ¡, ³¡Á¡ÁÂÇ¥¿Í ¿øÀÇ ¸éÀûÀÌ Ãâ·ÂµÈ °ÍÀ» È®ÀÎÇÒ ¼ö ÀÖ´Ù.  ÀÌ Äڵ忡¼­ »ç¿ëÇÑ StartPoint, EndPoint, Area µî °¢ °´Ã¼¸¶´ÙÀÇ ¼Ó¼ºÀº ActiveX reference¸¦ Âü°íÇÏ¿© È®ÀÎÇÏ°í »ç¿ëÇÏ´Â °ÍÀ» ÃßõÇÑ´Ù.

(base) D:\dev\python\pyautocad>python pya.py
Hello, Autocad
from Python

Drawing1.dwg
55.90169943749474 (0.0, 0.0, 0.0) (50.0, 25.0, 0.0)
314.1592653589793
52.20153254455275 (0.0, 10.0, 0.0) (50.0, 25.0, 0.0)
314.1592653589793
50.24937810560445 (0.0, 20.0, 0.0) (50.0, 25.0, 0.0)
314.1592653589793
50.24937810560445 (0.0, 30.0, 0.0) (50.0, 25.0, 0.0)
314.1592653589793
52.20153254455275 (0.0, 40.0, 0.0) (50.0, 25.0, 0.0)
314.1592653589793

 

 

            ¨è acad.get_selection(¡°¸Þ½ÃÁö¡±) : »ç¿ëÀÚ°¡ ¼±ÅÃÇϱâ

acad¿¡´Â »ç¿ëÀÚ°¡ °´Ã¼µéÀ» ¼±ÅÃÇϵµ·Ï ÇÏ´Â get_selection()¸Þ¼Òµå°¡ ÀÖ´Ù. ¾Æ·¡ÀÇ Äڵ带 À§ÀÇ ÄÚµåÀÇ ¸¶Áö¸·¿¡ »ðÀÔÇغ¸ÀÚ. get_selection('select object: ')¸¦ ¸¸³ª¸é »ç¿ëÀÚ°¡ ¹°Ã¼¸¦ ¼±ÅÃÇϱ⸦ ±â´Ù¸°´Ù. ¹°Ã¼ ¼±ÅÃÀÌ ¿Ï·áµÇ¸é for¹®À» µ¹¸é¼­ ObjectNameÀ» Ãâ·ÂÇØÁÖ´Â ±â´ÉÀÌ´Ù.

for obj in acad.get_selection('select object: '):
    print(obj.ObjectName)

 

8. ´Ù¸¥ °´Ã¼µé

pyautocad°ø½Ä¹®¼­°¡ Ãæ½ÇÇÏÁö ¾Ê´Ù. ActiveX reference¸¦ ¸¹ÀÌ ÂüÁ¶ÇØ¾ß ÇÑ´Ù. ±¸±Û¸µÀ» Çغ¸´Ï Àß Á¤¸®ÇسõÀº »çÀÌÆ®°¡ ÀÖ´Ù. ¸¹Àº ¿¹Á¦µéÀÌ Æ÷ÇԵǾî ÀÖ´Ù. https://www.supplychaindataanalytics.com/category/python-for-autocad/ Python for AutoCAD

 

-        Æú¸®¶óÀÎ

AutoCAD¿¡¼­ Æú¸®¶óÀÎÀº µÎ Á¾·ù°¡ ÀÖ´Ù. LightWeightPolyline°ú ±×³É PolylineÀÌ´Ù. LWpolylineÀº 2D, polylineÀº 3D´Ù. »ç¿ë¹ýÀº Á¡ÀÇ array¸¦ ÁÖ¸é µÈ´Ù. ¿©±â¼­ array´Â x,yÁÂÇ¥ ¶Ç´Â x,y,zÁÂÇ¥°¡ ¿¬¼ÓµÇ¾î ³ª¿­µÈ °ÍÀÌ´Ù. ÀÌ array¸¦ »ç¿ëÇϱâ À§ÇØ array¸ðµâÀ» importÇØÁØ´Ù. array¸ðµâÀº ³»Àå ¸ðµâÀÌ´Ù. array¸¦ »ý¼ºÇÒ ¶§ array.array(¡°d¡±, point¸®½ºÆ®)¿Í °°ÀÌ ÀÔ·ÂÇØÁØ´Ù. ¡°d¡±´Â doubleÀÇ Àǹ̴٠¡°i¡±´Â integerÀÇ Àǹ̴Ù. Áï array¸¦ ÀÌ·ç´Â µ¥ÀÌÅÍ ÇüÀÌ´Ù. ÀÚ¼¼ÇÑ °ÍÀº ÆÄÀ̽㠰ø½Ä¹®¼­¸¦ Âü°íÇÏÀÚ. https://docs.python.org/ko/3/library/array.html

 

AddLightWeightPolyline(2DÁ¡ array)

AddPolyline(3DÁ¡ array)

 

from pyautocad import Autocad
import array
acad = Autocad(create_if_not_exists=
True)
points_2d = [
0, 1, 1, 2, 2, 2]
points_double = array.array(
"d", points_2d)
acad.model.AddLightWeightPolyline(points_double)

points_3d = [
0, 0, 0, 1, 1, 0, 2, 1, 0]
points_double = array.array(
"d", points_3d)
acad.model.AddPolyline(points_double)

 

 

ÀÌ·± ½ÄÀ¸·Î ÁÂÇ¥¸¦ 1Â÷¿øÀ¸·Î ³ª¿­Çؼ­ »ç¿ëÇÏ·Á¸é ´ç¿¬È÷ ºÒÆíÇÏ´Ù. ±×·¡¼­ ¿©·¯°³ÀÇ ÁÂÇ¥¸¦ ¿¬°áÇؼ­ array·Î ¸¸µé¾î¼­ ¾²´Â °ÍÀÌ ÆíÇÒ °ÍÀÌ´Ù. reduce¶ó´Â ÇÔ¼ö¸¦ ÀÌ¿ëÇÒ ¼ö ÀÖ´Ù. ÀÌÀü¿¡ ´Ù·ð´ø mapÇÔ¼ö°¡ ¸®½ºÆ®ÀÇ ¿ä¼Òµé¿¡ ´ëÇؼ­ °¢°¢ ¾î¶² ¿¬»êÀ» ÇÑ °á°ú¸¦ µ¹·ÁÁشٸé reduce´Â ´©ÀûÇؼ­ ¿¬»êÀ» ¼öÇàÇÑ´Ù. reduceÇÔ¼ö¸¦ ¾²±â À§Çؼ­´Â from functools import reduce¸í·ÉÀ¸·Î ¸ÕÀú reduce¸¦ importÇØ¾ß ÇÑ´Ù.

¾Æ·¡¿Í °°ÀÌ a,b,c¶ó´Â ¼¼°³ÀÇ ÁÂÇ¥¸¦ °¡Áö°í ÀÖ´Ù°í ÇÏÀÚ ÀÌ ÁÂÇ¥µéÀ» arrayÇüÅ·Π¹Ù²Ù±â À§Çؼ­ reduceÇÔ¼ö¸¦ Àû¿ëÇÏ¸é µÈ´Ù. lambdaÇÔ¼ö´Â À͸íÇÔ¼ö·Î x,y¸®½ºÆ®¸¦ ¹Þ¾Æ¼­ Çϳª·Î ÇÕÄ¡´Â ¿¬»ê(+)À» ÇÏ°í °á°ú¸¦ °¡Áö°í ÀÖ´Â »óÅ¿¡¼­ ´ÙÀ½ listÀÇ ¿ä¼Ò¿¡ ´ëÇØ +¿¬»êÀ» ¼öÇàÇÑ´Ù. ¼¼°³ÀÇ list°¡ Çϳª·Î ÇÕÃÄÁ³´Ù. ÀÌ ÄÚµå´Â 1Â÷¿øÀ¸·Î ¸¸µå´Â °ÍÀ» ¿¹·Î µç °ÍÀÌ°í pyautocad¿¡¼­ »ç¿ëÇÏ·Á¸é arrayÇÔ¼ö¸¦ ½á¼­ Çü½ÄÀ» º¯È¯ÇØÁà¾ß ÇÑ´Ù.

from functools import reduce
a=[
1,2]
b=[
3,4]
c=[
5,6]
k=reduce(
lambda x,y: x+y, [a,b,c])

print(k)

 

[1, 2, 3, 4, 5, 6]

 

À̹ø¿¡´Â Á¶±Ý ´Ù¸¥ ¹æ¹ýÀ» »ç¿ëÇغ¸°Ú´Ù. 1Â÷¿øÀÇ ÁÂÇ¥¸¦ ¸¸µå´Â ¹æ¹ýÀº extendÇÔ¼ö¸¦ »ç¿ëÇÏ°í, Çü½Ä º¯È¯Àº pyautocad°¡ Á¦°øÇÏ´Â aDoubleÀ̶ó´Â ÇÔ¼ö¸¦ Àû¿ëÇÏ°Ú´Ù.

from pyautocad import Autocad, aDouble

acad = Autocad(create_if_not_exists=
True)
k=[]
a=[
0,0]
b=[
10,0]
c=[
10,10]
d=[
0,10]

k.extend(a)
k.extend(b)
k.extend(c)
k.extend(d)
k.extend(a)

#karr=array.array("d",k)
karr=aDouble(k)
pl = acad.model.AddLightWeightPolyline(karr)

print(pl.Coordinates)
print(pl.Closed)
pl.Closed=
True
print(pl.Closed)
print(pl.Area)
print(pl.Coordinate(
1))

 

(base) D:\dev\python\pyautocad>python polyline1.py
(
0.0, 0.0, 10.0, 0.0, 10.0, 10.0, 0.0, 10.0, 0.0, 0.0)
False
True
100.0

(10.0, 0.0)

 

 

array¸¦ importÇÏÁö ¾Ê¾Ò°í ºó ¸®½ºÆ®¸¦ ¸¸µç ´ÙÀ½¿¡ extend¸Þ¼Òµå¸¦ ÀÌ¿ëÇؼ­ a,b,c,d,a¸¦ Ãß°¡Çß´Ù. ¸¶Áö¸·¿¡ ½ÃÀÛÁ¡ a¸¦ Ãß°¡Çß´Ù. ¾ÕÀÇ ¿¹¿¡¼­´Â array¸¦ »ç¿ëÇߴµ¥ À̹ø¿¡´Â aDoubleÇÔ¼ö¸¦ »ç¿ëÇؼ­ Çü½Äº¯È¯Çß´Ù. ¸¸µé¾îÁø LWpolylineÀ» pl¿¡´Ù ÇÒ´çÇÏ°í ¼Ó¼ºµéÀ» Ãâ·ÂÇغôÙ. Æú¸®¶óÀο¡´Â ¼Ó¼º Coordinates, Closed, Area µîÀÌ ÀÖ´Ù. Coordinates´Â Æú¸®¶óÀÎÀÇ ÁÂÇ¥µéÀ» Ãâ·ÂÇØÁØ´Ù. ù¹ø ° pl.Closed¸¦ Ãâ·ÂÇßÀ» ¶§´Â False°¡ Ãâ·ÂµÇ¾ú°í, pl.Closed=True·Î º¯°æÇÑ ´ÙÀ½ pl.Closed¸¦ Ãâ·ÂÇßÀ» ¶§´Â True°¡ Ãâ·ÂµÈ °ÍÀ» È®ÀÎÇÒ ¼ö ÀÖ´Ù. Area¼Ó¼ºÀ» ÀÌ¿ëÇؼ­ ¸éÀûÀ» ¾Ë ¼ö ÀÖ´Ù. °¢ Á¡ÀÇ ÁÂÇ¥¸¦ ¾Ë°í ½ÍÀ» ¶§ pl.Coordinate(1)¿Í °°ÀÌ Coordinate() ¸Þ¼Òµå¸¦ ÀÌ¿ëÇÒ ¼ö ÀÖ´Ù.

 

-        È£(Arc)

pyautocad·Î È£¸¦ ±×¸®´Â ¹æ¹ýÀº Áß½ÉÁÂÇ¥¿Í ¹ÝÁö¸§, ½ÃÀÛ°¢µµ, ³¡°¢µµ¸¦ ÁÖ¸é µÈ´Ù. À̶§ °¢µµ´Â radianÀÌ´Ù.

acad.model.AddArc(center, radius, start angle , end angle)

¾Æ·¡ÀÇ ÄÚµå´Â µÎ°³ÀÇ È£¸¦ ±×¸°´Ù. ù¹ø° È£´Â 15µµ¿¡¼­ ½ÃÀÛÇؼ­ 105µµ±îÁö ±×¸®°í µÎ¹ø° È£´Â 105µµ¿¡¼­ 15µµ±îÁö ±×¸°´Ù. ù¹ø° È£ÀÇ »öÀº ³ë¶õ»ö(2), µÎ¹ø° È£ÀÇ »öÀº »¡°£»ö(1)ÀÌ´Ù. È£¸¦ ±×¸± ¶§ ÁÖÀÇÇÒ Á¡Àº ½Ã°è¹Ý´ë¹æÇâÀ¸·Î ±×¸°´Ù´Â °ÍÀÌ´Ù. µû¶ó¼­ ½ÃÀÛ°¢°ú ³¡°¢À» ÀûÀýÇÏ°Ô ¼±ÅÃÇØ¾ß ÇÑ´Ù.

È£ °´Ã¼¿¡¼­ Áö¿øÇÏ´Â ÁÖ¿ä ¼Ó¼ºÀº ´ÙÀ½°ú °°´Ù.

arcobject.color : »ö

arcobject.Center : Áß½ÉÁ¡ÁÂÇ¥(CenterPoint°¡ ¾Æ´Ï´Ù)

arcobject.StartPoint : ½ÃÀÛÁ¡(½ÃÀÛ°¢¿¡ ÀÇÇؼ­ Á¤ÇØÁü)

arcobject.EndPoint : ³¡Á¡(³¡°¢¿¡ ÀÇÇؼ­ Á¤ÇØÁü)

arcobject.ArcLength : È£ÀÇ ±æÀÌ

arcobject.Radius : È£ÀÇ ¹ÝÁö¸§

 

from pyautocad import Autocad, aDouble, APoint
import math

acad = Autocad(create_if_not_exists=
True)
cp=APoint(
0,0,0)

arc1 = acad.model.AddArc(cp,
10, 15*math.pi/180 , 105*math.pi/180)
arc1.color=
2

arc2 = acad.model.AddArc(cp,
10, 105*math.pi/180, 15*math.pi/180)
arc2.color=
1

cp=APoint(arc1.Center)
sp=APoint(arc1.StartPoint)
ep=APoint(arc1.EndPoint)

ls=acad.model.AddLine(cp, sp)
le=acad.model.AddLine(cp, ep)
ls.color=
3
le.color=
3

print(arc1.ArcLength)

print(arc1.Radius)

 

 

-        Ä¡¼ö¼±

Ä¡¼ö¼±Àº ¿É¼ÇÀÌ »ó´çÈ÷ ¸¹Àº ÆíÀÌ´Ù. pyautocad·Î dimensionÀ» ±×¸®±â À§Çؼ­´Â Ä¡¼ö¼±¿¡ ´ëÇÑ ¿É¼ÇµéÀ» Àß ¾Ë°í ÀÖ¾î¾ß ÇÑ´Ù. Ä¡¼ö¼±À» ±×¸®´Â ¸í·ÉÀº ¾Æ·¡¿Í °°´Ù. ÀÚ¼¼ÇÑ »çÇ×µéÀº ActiveX Reference Guide(ARG)¸¦ ÂüÁ¶ÇÏÀÚ.

object.AddDimAligned(ExtLine1Point, ExtLine2Point, TextPosition)

object.AddDimAligned(Ä¡¼öº¸Á¶¼± ùÁ¡, Ä¡¼öº¸Á¶¼± µÑ°Á¡, ÅؽºÆ® À§Ä¡)

ARG¿¡´Â ¾Æ·¡¿Í °°Àº ±×¸²ÀÌ Æ÷ÇԵǾî ÀÖ´Ù.

 

 

¾Æ·¡ ÄÚµå´Â 1»çºÐ¸éºÎÅÍ 4»çºÐ¸é ±îÁö 4°³ÀÇ ¼±¿¡ ´ëÇؼ­ Ä¡¼ö¼±À» ±×¸®´Â ÄÚµå´Ù. ¼±À» 4°³ ±×¸®°í °¢ ¼±ÀÇ StatPoint¿Í EndPoint¸¦ ÀÌ¿ëÇؼ­ Ä¡¼ö¼±À» ±×·È´Ù. ÅؽºÆ®ÀÇ À§Ä¡´Â Áß°£Á¡¿¡¼­ x=20 ¶Ç´Â -20, y=20 ¶Ç´Â -20 ¸¸Å­ ¶³¾îÁø Á¡À¸·Î ÁöÁ¤Çؼ­ dimensionÀ» ±×·È´Ù. ±×¸®°í °¢Á¾ ¼Ó¼ºÀ» º¯°æÇØÁá´Ù. ÁÖ¿ä ¼Ó¼ºÀº ´ÙÀ½°ú °°´Ù. »ó¼¼ÇÑ ¼Ó¼ºÀº ARG¸¦ ÂüÁ¶ÇÏÀÚ.

dimobject.ExtensionLineColor  : Ä¡¼öº¸Á¶¼± »ö

dimobject.DimensionLineColor : Ä¡¼ö¼± »ö

dimobject.Arrowhead1Type = ACAD.acArrowDot : È­»ìÃË Çü½Ä

dimobject.ArrowheadSize = 5 : È­»ìÃË Å©±â

dimobject.TextHeight = 10 : ÅؽºÆ® ³ôÀÌ

 

from pyautocad import Autocad, aDouble, APoint, ACAD

acad = Autocad(create_if_not_exists=
True)

l1=acad.model.AddLine(APoint(
0,0),APoint(100,100))
l2=acad.model.AddLine(APoint(
0,0),APoint(-100,100))
l3=acad.model.AddLine(APoint(
0,0),APoint(-100,-100))
l4=acad.model.AddLine(APoint(
0,0),APoint(100,-100))

dimp1m = APoint((l1.StartPoint[
0]+l1.EndPoint[0])/2-20,(l1.StartPoint[1]+l1.EndPoint[1])/2+20)
dimp2m = APoint((l2.StartPoint[
0]+l2.EndPoint[0])/2+20,(l2.StartPoint[1]+l2.EndPoint[1])/2+20)
dimp3m = APoint((l3.StartPoint[
0]+l3.EndPoint[0])/2-20,(l3.StartPoint[1]+l3.EndPoint[1])/2+20)
dimp4m = APoint((l4.StartPoint[
0]+l4.EndPoint[0])/2+20,(l4.StartPoint[1]+l4.EndPoint[1])/2+20)

dimo1=acad.model.AddDimAligned(APoint(l1.StartPoint), APoint(l1.EndPoint), dimp1m)
dimo2=acad.model.AddDimAligned(APoint(l2.StartPoint), APoint(l2.EndPoint), dimp2m)
dimo3=acad.model.AddDimAligned(APoint(l3.StartPoint), APoint(l3.EndPoint), dimp3m)
dimo4=acad.model.AddDimAligned(APoint(l4.StartPoint), APoint(l4.EndPoint), dimp4m)

dimo1.ExtensionLineColor=
1
dimo1.DimensionLineColor=
1

dimo2.ExtensionLineColor=
1
dimo2.DimensionLineColor=
1
dimo2.Arrowhead1Type = ACAD.acArrowDot
dimo2.Arrowhead2Type = ACAD.acArrowDot

dimo3.ExtensionLineColor=
1
dimo3.DimensionLineColor=
1
dimo3.Arrowhead1Type = ACAD.acArrowDot
dimo3.Arrowhead2Type = ACAD.acArrowDot
dimo3.ArrowheadSize =
5

dimo4.ExtensionLineColor=
1
dimo4.DimensionLineColor=
1
dimo4.Arrowhead1Type = ACAD.acArrowDot
dimo4.Arrowhead2Type = ACAD.acArrowDot
dimo4.TextHeight =
10

 

 

8. ¸ÎÀ½¸»

À̹ø ½Ã°£¿¡´Â pyautocad ¶óÀ̺귯¸®¸¦ ÀÌ¿ëÇؼ­ autocad¿¡ °´Ã¼¸¦ »ý¼ºÇÏ°í ¼öÁ¤ÇÏ´Â °ÍÀ» ÇغôÙ. ¿À´Ã ´Ù·é °´Ã¼´Â Line, Circle, Text, Polyline, Arc, Dimension µîÀÌ´Ù. ÀÌÁ¤µµÀÇ °´Ã¼¸¸ À־ À¢¸¸ÇÑ µµ¸éÀº ¸ðµÎ ±×¸± ¼ö ÀÖÀ» °ÍÀÌ´Ù. °´Ã¼¼±Åõµ ¾Ë¾ÆºÃ´Ù. µµ¸éÀüü¿¡¼­ Á¶°Ç¿¡ ¸Â´Â °´Ã¼¸¦ ¼±ÅÃÇÏ´Â ¹æ¹ý°ú »ç¿ëÀÚ°¡ ¸¶¿ì½º·Î ¼±ÅÃÇÏ´Â ¹æ¹ý ¸ðµÎ °¡´ÉÇÏ´Ù. ´Ù¸¥ °´Ã¼¸¦ »ý¼ºÇϰųª ¼öÁ¤Çϱâ À§Çؼ­´Â ±¸±Û¸µÀ» Çϰųª ActiveX Reference Guide¸¦ Âü°íÇÏ¸é µÈ´Ù. ´ÙÀ½ ½Ã°£¿¡´Â Á¡À» ÀÔ·Â¹Þ°í °´Ã¼¸¦ ¼öÁ¤ÇÏ´Â ´Ù¸¥ ±â´ÉµéÀ» ´õ ¾Ë¾Æº¸µµ·Ï ÇÏ°Ú´Ù.

 

-³¡-



  ÃßõÇÏ±â   ¸ñ·Ïº¸±â

Copyright 1999-2024 Zeroboard / skin by zero
±¸Á¶¼³°èÀÇ ¹Ì·¡¸¦ ÁغñÇÏ´Â ¸ðÀÓ [±¸Á¶¼³°è¹Ì·¡Æ÷·³]