autocad win32com PDF导出 - 自定义规模问题

问题描述 投票:0回答:1
import win32com.client import time import os def dwg_to_pdf_win32(dwg_file_path, pdf_file_path): try: # Initialize AutoCAD autocad = win32com.client.Dispatch("AutoCAD.Application") autocad.Visible = False # Open the DWG file doc = autocad.Documents.Open(dwg_file_path) layout = doc.Layouts.Item("Model") layout.PlotType = 2 # Extents layout.CenterPlot = True layout.PlotRotation = 1 layout.ConfigName = "Microsoft Print to PDF" layout.CanonicalMediaName = "A3" layout.UseStandardScale = False layout.PaperUnits = 1 layout.SetCustomScale(1, 0.2) # Scale: 1/200 layout.PlotWithLineweights = False layout.PlotWithPlotStyles = True layout.StyleSheet = "style.ctb" # Create the PDF plot = doc.Plot plot.PlotToFile(pdf_file_path) # Wait for the PDF to be created timeout = 120 for _ in range(timeout): if os.path.exists(pdf_file_path): print(f"PDF generated: {pdf_file_path}") break time.sleep(1) else: print("PDF file was not created.") return None # Close document doc.Close(False) print("Conversion successful!") except Exception as e: print(f"Error during conversion: {e}") # Example usage dwg_to_pdf_win32( "C:\\Users\\hp\\P8818-PLAN.dwg", "C:\\Users\\hp\\P8818-PLAN.pdf" )

任何洞察力或更正将不胜感激。谢谢!

我不知道我是否缺少任何东西,但是

SetCustomScale(1, 0.2)

看起来不像1:200.
python pywin32 autocad
1个回答
0
投票
SetCustomScale(1, 200)

SetCustomScale(1, 0.005)


最新问题
© www.soinside.com 2019 - 2025. All rights reserved.