Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
327 views
in Technique[技术] by (71.8m points)

python - How to rotate,move or copy few lines in pyautocad?

I want to create objects with lines and then to "merge" them to rotate, copy and move. Here are my codings.

 from pyautocad import Autocad, APoint, aDouble

acad = Autocad(create_if_not_exists=True)
acad.prompt("Hello, Autocad from Python
")
print('You are using ' + acad.doc.Name)
# Apoint(x,y)
width = int(input('Width: '))
height = int(input('Height: '))
p1 = APoint(0, 0)
p2 = APoint(width, 0)
p3 = APoint(width, height)
p4 = APoint(0, height)

line1 = [acad.model.AddLine(p1, p2), acad.model.AddLine(p2, p3), acad.model.AddLine(p3, p4), acad.model.AddLine(p4, p1)]
line1.Rotate(p1,0.7853981)


acad.model.AddDimAligned(p2, p1, p4)
acad.model.AddDimAligned(p3, p2, p1)

As you can see I will create rectangle for example in line1 and would like to rotate it in command line1.Rotate(p1,0.7853981) Unfotunately after running code it returns error:

AttributeError: 'list' object has no attribute 'Rotate'

Is this even possible to merge those lines and other objects?

question from:https://stackoverflow.com/questions/65873098/how-to-rotate-move-or-copy-few-lines-in-pyautocad

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...