A
A
al2019-12-28 16:19:54
Python
al, 2019-12-28 16:19:54

Is it possible to change line weight in autocad via pyautocad?

In the code below, I create a square and in some sides I need to make more weight. In Google, I found the Lineweight method, which does not fit under AddLine because it interacts with other objects. Actually questions:
1. How to increase line weight?
2. Is there another python library to work with autocad?
3. Another PL for working with autocad, if any

from pyautocad import Autocad, APoint

acad = Autocad(create_if_not_exists=True)
# Фасад
x1 = int(input('Введите x1:\t'))
y1 = int(input('Введите y1:\t'))
x2 = int(input('Введите x2:\t'))
y3 = int(input('Введите y3:\t'))
# Задаем параметры точек основания здания
p1 = APoint(x1, y1)
p2 = APoint(x2, y1)  # Параметр y2, x3, x4, y4 не задается, из условия что фундамент
p3 = APoint(x1, y3)  # квадратной/прямоугольной. формы. Используется x1 -> x3; x2 -> x4; y3 -> y4
p4 = APoint(x2, y3)  # y1 -> y2
A = acad.model.AddLine(p1, p2)
acad.model.AddLine(p1, p3)
acad.model.AddLine(p2, p4)
acad.model.AddLine(p3, p4)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dlobyntsev, 2020-02-13
@dlobyntsev

1. You can increase the line weight:

#создаём линию
A = acad.model.AddLine(p1, p2)
#устанавливаем её вес, например, 1мм
A.Lineweight = 100
"""
Веса линий кодируются как:
-3 - по умолчанию
-2 - по блоку
-1 - по слою
0 - 0мм
5 - 0,05мм
...
40 -0,4мм
...
100 - 1мм
и т.д.
"""

2. As for other libraries - they are not needed at all, you only need pywin32 and a description of the AutoCAD object model (installed with AutoCAD). There are no libraries for working with AutoCAD from Python that completely cover all aspects of work.
3. If you need to work closely with AutoCAD, then it is better to pay attention to C #. Python can only work with AutoCAD via COM, which is not very fast and not always convenient, although it is quite enough for most tasks.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question