Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot automation #42

Open
Eligio-Cazo opened this issue Oct 14, 2022 · 2 comments
Open

Plot automation #42

Eligio-Cazo opened this issue Oct 14, 2022 · 2 comments

Comments

@Eligio-Cazo
Copy link

I'm working on a project of plan plotting automation with python, I was able to do it with pywin32 but I couldn't do it with pyautocad. The problem itself is that I need a point of only 2 coordinates for the plotting window, APoint uses three dimensions, is there any alternative to solve this problem?

acad.ActiveDocument.ActiveLayout.SetWindowToPlot(Point1, Point2)
Point1 and Point 2 must be only x , y coordinates.

@zangdol
Copy link

zangdol commented Sep 16, 2023

Umm. Im using SendCommand

Direction = "Portrait"
command_template = ("-Plot\n"
"Yes\n"
"Model\n"
"\n"
"\n"
"\n"
f"{Direction}\n"
"No\n"
"Window\n"
"<P1.X>,<P1.Y>\n"
"<P2.X>,<P2.Y>\n"
"Fit\n"
"Center\n"
"Yes\n"
"\n"
"Yes\n"
"\n"
"No\n"
"Y\n"
"Y\n")
................................
sset = acad.get_selection() # select plot blocks
for block in acad.iter_objects('blockreference', sset):
if block.name == title:
block_box = block.GetBoundingBox()
Lcorner = block_box[0]
Hcorner = block_box[1]
MinPoint = Lcorner[:2]
MaxPoint = Hcorner[:2]

                    #
                    command = command_template.replace("<P1.X>", str(MinPoint[0]))
                    command = command.replace("<P1.Y>", str(MinPoint[1]))
                    command = command.replace("<P2.X>", str(MaxPoint[0]))
                    command = command.replace("<P2.Y>", str(MaxPoint[1]))
                    
                    # 프린터 설정 확인
                    if printer != "없음":     
                        myDoc.SendCommand(command)

@Eligio-Cazo
Copy link
Author

Eligio-Cazo commented Sep 19, 2023

That code is probably fine for your needs. I actually needed this to work for an automation of plotting drawings, when selecting the frame that plots what is inside the frame, in this case the frame is a polyline, sometimes I have more than 50 drawings to print. But CAD files are generated by other software that does not use paper mode or layouts, and it is frustrating when printing them. But I already made it work with pwin32.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants