'How to create dimension line in Pyautocad?
I created rectangle with commands acad.model.AddLine
and I'd like Autocad to show dimensions of those lines.
Here is my code:
from pyautocad import Autocad, APoint
acad = Autocad(create_if_not_exists=True)
acad.prompt("Hello, Autocad from Python\n")
print('Using file ' + acad.doc.Name)
width = int(input('Enter width: '))
height = int(input('Enter height: '))
p1 = APoint(0, 0)
p2 = APoint(width, 0)
p3 = APoint(width, height)
p4 = APoint(0, height)
line1 = acad.model.AddLine(p1, p2)
line2 = acad.model.AddLine(p2, p3)
line3 = acad.model.AddLine(p3, p4)
line4 = acad.model.AddLine(p4, p1)
I tried to use acad.model.AddDimAligned(line4, 10)
but it is not working.
Solution 1:[1]
Rawel,
try this for add dimensions in your drawing.
dim1 = acad.model.AddDimAligned(p1, p2, APoint(width/2, -0.5))
And continuing like this for the others dimensions. Check this video on my YT if you have more doubts about it: My YT.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Axel T. |