This part of the documentation covers all the interfaces of pyautocad
Main AutoCAD Automation object
Parameters: |
|
---|
Returns active AutoCAD.Application
if Autocad was created with create_if_not_exists=True, it will create AutoCAD.Application if there is no active one
Returns ActiveDocument of current Application
Iterate layouts from doc
Parameters: |
|
---|
Iterate objects from block
Parameters: |
|
---|
Shortcut for iter_objects(dont_cast=True)
Shouldn’t be used in normal situations
Returns first occurance of object which match predicate
Parameters: |
|
---|---|
Returns: | Object if found, else None |
Asks user to select objects
Parameters: | text – prompt for selection |
---|
shortcut for pyautocad.types.aDouble()
shortcut for pyautocad.types.aInt()
shortcut for pyautocad.types.aShort()
Constants from AutoCAD type library, for example:
text.Alignment = ACAD.acAlignmentRight
Usage:
>>> p1 = APoint(10, 10)
>>> p2 = APoint(20, 20)
>>> p1 + p2
APoint(30.00, 30.00, 0.00)
Also it supports iterable as parameter:
>>> APoint([10, 20, 30])
APoint(10.00, 20.00, 30.00)
>>> APoint(range(3))
APoint(0.00, 1.00, 2.00)
Supported math operations: +, -, *, /, +=, -=, *=, /=:
>>> p = APoint(10, 10)
>>> p + p
APoint(20.00, 20.00, 0.00)
>>> p + 10
APoint(20.00, 20.00, 10.00)
>>> p * 2
APoint(20.00, 20.00, 0.00)
>>> p -= 1
>>> p
APoint(9.00, 9.00, -1.00)
It can be converted to tuple or list:
>>> tuple(APoint(1, 1, 1))
(1.0, 1.0, 1.0)
Returns string with removed format information
Parameters: |
|
---|
>>> text = ur'{\fGOST type A|b0|i0|c204|p34;TEST\fGOST type A|b0|i0|c0|p34;123}'
>>> unformat_mtext(text)
u'TEST123'
Returns string with removed format innformation as unformat_mtext() and P (paragraphs) replaced with newlines
>>> text = ur'{\fGOST type A|b0|i0|c204|p34;TEST\fGOST type A|b0|i0|c0|p34;123}\Ptest321'
>>> mtext_to_string(text)
u'TEST123\ntest321'
Returns string in Autocad multitext format
Replaces newllines \n with \P, etc.
Represents table with ability to import and export data to following formats:
When you need to store some data, it can be done as follows:
table = Table()
for i in range(5):
table.writerow([i, i, i])
table.save('data.xls', 'xls')
To import data from file, use data_from_file():
data = Table.data_from_file('data.xls')
Synonym for writerow()
Save data to file
Parameters: |
|
---|
Return data, converted to format
Parameters: | fmt – desirable format of data |
---|
Note: to convert to csv format, use to_csv()
See also available_write_formats()
Writes data in csv format to stream
Parameters: |
|
---|
Returns data in desired format from file
Parameters: |
|
---|
Format should be in available_read_formats()