refactor(dxf): optimize table drawing and add diagnostic scripts

This commit includes several updates to the Python_OpenSource_DXF project:

- The core script draw_table_from_template.py has been refactored for better logic and clarity.

- New utility scripts such as diagnose_blocks.py, export_dxf.py, and plot_by_block_name.py have been added to enhance diagnostic and plotting capabilities.

- The convert_dxf_to_pdf.py script was removed as its functionality is now covered by other modules.

- README.md and .specstory documentation have been updated to reflect these changes.
This commit is contained in:
puzzlesion 2025-09-12 17:21:08 +08:00
parent ec09c612b8
commit 5e87bd7c33
238 changed files with 5413 additions and 74 deletions

View File

@ -0,0 +1,464 @@
<!-- Generated by SpecStory -->
# 使用模板写入DXF文件数据 (2025-09-11 07:06Z)
_**User (2025-09-11 06:45Z)**_
使用drawing功能写入到 "C:\Users\83500\久翌\CAD编辑同步excel\测试文件区\04_Test_Files\塔器.dxf"的 布局1 的 500 600
数据和模板:
C:\Users\83500\久翌\CAD编辑同步excel\测试文件区\03_Python_OpenSource_DXF\模板\一级料表模板
---
_**Assistant**_
<think><details><summary>Thought Process</summary>**Defining the DXF Table**
I'm currently focusing on drawing a table within a DXF file. I've identified the target file and layout. Now, I need to figure out how to represent the table data its structure, cell contents, and positioning within the DXF format. Coordinates are being considered.
**Locating Relevant Files**
I'm now digging into the "一级料表模板" directory to determine which files serve as the header and column templates, along with the data JSON. I'm also assessing if "布局1" is compatible with the `draw_table_from_template.py` script, given its focus on the model. The relative path is now understood, which simplifies file referencing.
**Examining File Contents**
I'm now delving into the template directory files to identify the header template, column template, and data JSON files. I've also noted the script's reliance on model space, so I must determine how to handle the specified layout "布局1". I plan to list the files to proceed.
</details></think>
---
好的,我将使用 `draw_table_from_template.py` 脚本将表格数据写入到您指定的 DXF 文件中。
首先,我需要确认模板文件夹中的具体文件名,以便正确调用脚本。我将列出 `03_Python_OpenSource_DXF\模板\一级料表模板` 目录下的文件。
---
<details>
<summary>Listed directory undefined • **0** results</summary>
No results found
</details>
---
<think><details><summary>Thought Process</summary>**Defining Template Structure**
I'm currently examining the structure of the template directory. I've identified several JSON files within `03_Python_OpenSource_ DXF\模板\一级料表模板`, specifically those for columns, drawing data, and headers. These files seem to define the format of the data required by a function, which is promising.
**Confirming File Correspondence**
I've confirmed that the JSON files perfectly align with the inputs of `draw_table_from_template.py`. Specifically, `header_template.json`, `columns_template.json`, and `drawing1_data.json` directly correspond to the header, column, and data arguments respectively. Now, I am investigating `draw_table_from_template.py` and layout support.
</details></think>
---
Okay, I see the `draw_table_from_template.py` script requires `header_template.json`, `columns_template.json`, and `drawing1_data.json`, all of which are present. The user wants to draw in "布局1", so I'll check if the script supports layouts since the documentation example only mentions modelspace.
---
Read file: undefined
---
<think><details><summary>Thought Process</summary>**Assessing the Script's Limitations**
I've just analyzed `draw_table_from_template.py` and confirmed its restriction to the modelspace. The script currently lacks functionality for layout selection. My focus has now shifted to understanding the implications of this limitation and strategizing a method for layout integration.
**Formulating the Strategy**
I've identified the need to add a `--layout` argument to the script to enable layout selection. My strategy includes adding a command-line argument to the existing script. If a layout name is supplied, the script will fetch the layout; otherwise, it defaults to modelspace. This approach maintains backward compatibility. I'm now preparing to implement these changes.
**Devising a Solution**
I've pinpointed the key limitation of `draw_table_from_template.py`: its exclusive focus on modelspace. My next step is to integrate layout selection. To achieve this, I'll implement a `--layout` argument. The script will then select the appropriate space, maintaining modelspace as the default. Now, I'm drafting the implementation strategy, starting with adding the plan.
</details></think>
---
好的,我将按您的要求执行操作。
首先,我分析了您提供的需求和现有文件。`draw_table_from_template.py` 脚本目前只能在模型的“模型空间”中绘图,但您的要求是绘制到 "布局1" 中。因此,我需要先对该脚本进行修改,增加指定布局的功能。
这是我的行动计划:
1. **修改 `draw_table_from_template.py` 脚本**
* 添加一个新的命令行参数 `--layout`,用于接收布局名称。
* 更新代码逻辑:如果用户提供了 `--layout` 参数,程序将尝试获取并使用指定的布局;如果未提供,则默认使用模型空间,以保证旧功能不受影响。
2. **执行修改后的脚本**
* 使用您提供的路径、坐标和模板文件,执行脚本,将表格绘制到 `塔器.dxf` 文件的 `布局1` 中。
我现在开始执行第一步,修改脚本。
---
## Todo List
- [-] Modify `draw_table_from_template.py` to support specifying a layout.
- [ ] Run the modified script with user-provided parameters.
---
<think><details><summary>Thought Process</summary>**Refining Initial Implementation**
I've begun implementing the `--layout` argument within `draw_table_from_template.py`. Currently, I'm focused on parsing the argument and handling potential errors. The plan is to attempt loading the specified layout and exit gracefully if the layout is missing.
**Integrating Argument Parsing**
I've successfully added the `--layout` argument using `argparse`. Now, I'm focused on implementing the error handling. Specifically, I'm incorporating a `try-except` block to catch `KeyError` if the specified layout is not found in the DXF document and printing helpful error messages, along with available layouts.
**Initiating Code Modification**
I'm now actively working on modifying `draw_table_from_template.py`. I've outlined the `argparse` addition for the `--layout` argument and how to handle it in the `main` function. I'm implementing the code now, specifically integrating the argument parsing and layout selection, including the necessary error handling for missing layouts. I'll be replacing `msp = doc.modelspace()` with the new layout logic, and I've considered the case of a new DXF.
</details></think>
---
Okay, I am starting the first task, which is to modify `draw_table_from_template.py`.
I will add a `--layout` argument. If a layout is specified, I will attempt to retrieve it. If the layout does not exist, I will print an error message and exit. If no layout is specified, I will use the modelspace.
---
<details><summary>Edit file: 03_Python_OpenSource_DXF/draw_table_from_template.py</summary>
undefined
**Chunk 1**
Lines added: 1, lines removed: undefined
```diff
@@ -202,4 +202,5 @@
help="Sets the anchor point of the table for the insertion coordinates (--x, --y)."
)
+ parser.add_argument("--layout", type=str, default=None, help="The name of the layout to draw on. Defaults to modelspace.")
args = parser.parse_args()
```
**Chunk 2**
Lines added: 12, lines removed: 1
```diff
@@ -218,10 +219,21 @@
if os.path.exists(args.source_dxf):
doc = ezdxf.readfile(args.source_dxf)
- msp = doc.modelspace()
print(f"Loaded source DXF file: {args.source_dxf}")
else:
print(f"Source file not found, creating a new DXF document.")
doc = ezdxf.new()
+
+ if args.layout:
+ try:
+ msp = doc.layouts.get(args.layout)
+ print(f"Using layout: {args.layout}")
+ except KeyError:
+ print(f"Error: Layout '{args.layout}' not found in the document.")
+ print("Available layouts:", ", ".join(l.name for l in doc.layouts))
+ return
+ else:
msp = doc.modelspace()
+ print("Using modelspace.")
+
except IOError:
print(f"Could not read source DXF file: {args.source_dxf}. Creating a new document.")
```
</details>
---
<think><details><summary>Thought Process</summary>**Refining The Code**
I've been tidying up the code, focusing on improving readability and organization. The edits I made initially were a bit rough around the edges, so I'm working on refining those changes and streamlining the structure of the code block. I want it to be easier to understand and maintain.
**Code Clarity Improvement**
I'm currently focused on refining the "Load DXF" section of the code, aiming for a cleaner and more organized structure. The initial edits, while functional, could be improved for readability, specifically in the error handling and file loading logic. I'm now integrating these changes and re-evaluating how to best handle potential issues.
**Improving the Layout Logic**
I've just completed a review of the layout handling code. The new implementation is more robust, using `doc.layouts.has_layout()` and `doc.layouts.names()` to validate the layout selection, which is a significant improvement over the original approach. This helps in identifying and communicating errors.
**Evaluating the Changes**
I've revisited the "Load DXF" section. I was aiming for more clarity, and it seems I was overthinking things initially. The `doc.layouts.has_layout()` approach is a good check. Using `try...except` with `doc.layouts.get()` is the more "pythonic" route for handling the layout selection and I have incorporated this approach.
**Revisiting and Correcting Edits**
I've just corrected a bug in the previous edits; I had inadvertently moved the `args = parser.parse_args()` line. Also, I'm reviewing my approach, and I believe using `try...except` with `doc.layouts.get()` is the most appropriate way for handling layout selection. I'm going to integrate these improvements.
</details></think>
---
Okay, I see the previous edit introduced a bug by misplacing `args = parser.parse_args()`. I will correct this now by applying a cleaned-up version of the logic.
---
<details><summary>Edit file: 03_Python_OpenSource_DXF/draw_table_from_template.py</summary>
undefined
**Chunk 1**
Lines added: 2, lines removed: undefined
```diff
@@ -216,4 +216,6 @@
# --- Load DXF ---
+ msp = None
+ doc = None
try:
if os.path.exists(args.source_dxf):
```
**Chunk 2**
Lines added: 1, lines removed: 1
```diff
@@ -223,5 +225,5 @@
print(f"Source file not found, creating a new DXF document.")
doc = ezdxf.new()
-
+
if args.layout:
try:
```
**Chunk 3**
Lines added: 1, lines removed: 1
```diff
@@ -230,5 +232,5 @@
except KeyError:
print(f"Error: Layout '{args.layout}' not found in the document.")
- print("Available layouts:", ", ".join(l.name for l in doc.layouts))
+ print("Available layouts:", ", ".join(doc.layouts.names()))
return
else:
```
</details>
---
<think><details><summary>Thought Process</summary>**Troubleshooting Edit Failures**
I'm still struggling with the edit. It appears the tool I'm using is having issues applying changes properly. I will try again using a more comprehensive code block to give the tool additional context.
**Iterating Edit Attempts**
The prior attempt failed. The edit tool struggles with the task at hand. The goal is to replace the `main` function's logic. I've now provided the desired `main()` function in a complete code block, hoping this comprehensive approach yields better results. I'm aiming for a clean implementation.
**Refining the Implementation**
The previous attempt failed again, and the issue persists. The editing tool's struggle continues, failing to accurately apply the changes. This time, I'm including the complete `main()` function in my code block to give the tool more context. I'm focused on a clean start for the `main` function.
**Persisting with Refinements**
The edit tool continues to be problematic. It's not properly integrating the changes. I'm going to try again with a more extensive code block that provides the complete `main()` function. My focus remains on a clean implementation of the argument parsing and DXF loading.
</details></think>
---
<details><summary>Edit file: 03_Python_OpenSource_DXF/draw_table_from_template.py</summary>
undefined
**Chunk 1**
Lines added: 1, lines removed: 1
```diff
@@ -216,6 +216,6 @@
# --- Load DXF ---
+ doc = None
msp = None
- doc = None
try:
if os.path.exists(args.source_dxf):
```
</details>
---
<think><details><summary>Thought Process</summary>**Analyzing for Edits**
I've decided to overhaul the existing edits. The current version isn't satisfactory, so I'm shifting to a more hands-on approach. I plan to read through the file carefully, identifying the areas needing correction, and then craft the edits myself.
</details></think>
---
Read file: undefined
---
<think><details><summary>Thought Process</summary>**Running the Script Now**
I've confirmed that `draw_table_from_template.py` appears to be functionally sound. The `--layout` argument has been incorporated, along with the necessary logic. My immediate next step is to execute the script using the user-supplied parameters.
**Testing the Execution**
I'm now ready to run the script with the user's provided parameters. I've assembled the command line arguments, including the source DXF, template files, data, output location, coordinates, and the layout specification. I'll monitor the output closely for any errors or unexpected behavior during the run. I'm particularly interested in how the `--layout 布局 1` argument is handled.
**Initiating the Run**
I'm now preparing the command line invocation of the script with the detailed parameters. I've carefully constructed the call, including paths for DXF, templates, data, output, coordinates and crucially, the layout specification. I'll execute it with the full path to the python executable within the virtual environment, as instructed. I'll be watching closely for the `--layout`'s proper integration.
**Preparing for Execution**
I've meticulously constructed the command-line call, focusing on accurate pathing, especially for the python executable and the script itself. I'm also ensuring the proper handling of the `--layout` argument. The next step is to execute the command within the terminal environment. I'll meticulously examine the output, looking for any errors.
**Final Execution Preparation**
I've carefully constructed the command, incorporating relative paths for brevity. The key aspects include the script's location, the Python interpreter's location within the virtual environment, and the full specification of input/output files and parameters. I'm preparing for the execution using PowerShell, ensuring proper quoting. I am optimistic about a successful outcome.
</details></think>
---
好的,我已经修改了 `draw_table_from_template.py` 脚本,现在它支持通过 `--layout` 参数指定图纸的布局。
接下来,我将执行此脚本,将您指定的表格数据和模板绘制到 `塔器.dxf` 文件的“布局1”中坐标为 (500, 600)。输出文件将保存为 `塔器_with_table.dxf`
---
## Todo List
- [x] Modify `draw_table_from_template.py` to support specifying a layout.
- [-] Run the modified script with user-provided parameters.
---
```bash
& ".\\03_Python_OpenSource_DXF\\venv\\Scripts\\python.exe" ".\\03_Python_OpenSource_DXF\\draw_table_from_template.py" ".\\04_Test_Files\\塔器.dxf" ".\\03_Python_OpenSource_DXF\\模板\\一级料表模板\\header_template.json" ".\\03_Python_OpenSource_DXF\\模板\\一级料表模板\\columns_template.json" ".\\03_Python_OpenSource_DXF\\模板\\一级料表模板\\drawing1_data.json" ".\\04_Test_Files\\塔器_with_table.dxf" --x 500 --y 600 --layout "布局1"
```
```
"布局1"
Loaded source DXF file: .\\04_Test_Files\\塔器.dxf
Using layout: 布局1
Drawing table with anchor 'bottom-left' at (500.0, 600.0)...
Calculated bottom-left start position: (500.00, 600.00)
Successfully saved new table to: .\\04_Test_Files\\塔器_with_table.dxf
```
---
<think><details><summary>Thought Process</summary>**Assessing Script Execution**
The script performed as expected, successfully loading the DXF file "塔器.dxf" and utilizing the "布局1" layout. The table was drawn correctly at the designated location, and the output was saved as planned.
**Verifying Script Completion**
I've confirmed successful script execution. The DXF file loaded, layout "布局1" was used, the table was drawn as intended, and the output, including the table, was correctly saved. The output file is located at `.\04_Test_Files\塔器 _with_table.dxf`.
</details></think>
---
## Todo List
- [x] Modify `draw_table_from_template.py` to support specifying a layout.
- [x] Run the modified script with user-provided parameters.
---
<think><details><summary>Thought Process</summary>**Evaluating the Execution**
I've confirmed the script ran without a hitch. The DXF file was read, the specified layout was used. Furthermore, the start position was correctly calculated, leading to successful table drawing. The output has been saved, as expected.
**Concluding the Process**
The system performed as expected, precisely following the defined steps. I confirmed the loading of the specified DXF, the use of the correct layout, and the accurate drawing with saved output. Success! The table has been drawn, and the results are saved.
</details></think>
---
好的,我已经成功执行了您的请求。
具体操作如下:
1. **修改了绘图脚本**:我对 `03_Python_OpenSource_DXF/draw_table_from_template.py` 脚本进行了修改添加了对CAD“布局(Layout)”的支持。现在可以通过 `--layout` 参数指定图纸的布局名称。
2. **执行绘图命令**:使用修改后的脚本,我将您指定的“一级料表模板”和数据,在 `04_Test_Files\塔器.dxf` 文件的 `布局1` 中,于坐标 `(500, 600)` 处插入了表格。
3. **生成了新文件**:结果已保存到一个新文件中,路径为:`04_Test_Files\塔器_with_table.dxf`。
您可以检查生成的文件,看看是否符合您的预期。
---
_**User (2025-09-11 06:45Z)**_
直接把命令发我,我再执行一次
---
_**Assistant**_
<think><details><summary>Thought Process</summary>**Repeating the Command**
\n\n
I've zeroed in on providing the user with the command they need. I'll present the exact string I executed earlier, allowing them to replicate the action. My primary concern is ensuring they have the correct command for direct execution.
**Confirming the Action**
\n\n
My current thinking confirms the need to reiterate the previous action. Therefore, I'm directly outputting the exact command executed previously. I have formatted it within a code block as requested. This will enable the user to easily rerun the command for identical results.
</details></think>
---
好的,这是您需要执行的命令:
```shell
& ".\\03_Python_OpenSource_DXF\\venv\\Scripts\\python.exe" ".\\03_Python_OpenSource_DXF\\draw_table_from_template.py" ".\\04_Test_Files\\塔器.dxf" ".\\03_Python_OpenSource_DXF\\模板\\一级料表模板\\header_template.json" ".\\03_Python_OpenSource_DXF\\模板\\一级料表模板\\columns_template.json" ".\\03_Python_OpenSource_DXF\\模板\\一级料表模板\\drawing1_data.json" ".\\04_Test_Files\\塔器_with_table.dxf" --x 500 --y 600 --layout "布局1"
```
您可以在 `C:\Users\83500\久翌\CAD编辑同步excel\测试文件区` 这个目录下直接运行它。
---

View File

@ -0,0 +1,17 @@
{
"permissions": {
"allow": [
"Read(/C:\\Users\\83500\\久翌\\CAD编辑同步excel\\测试文件区\\04_Test_Files/**)",
"Bash(pip install:*)",
"Bash(python:*)",
"Bash(call venvScriptsactivate.bat)",
"Bash(./venv/Scripts/python.exe --version)",
"Bash(./venv/Scripts/pip.exe list)",
"Bash(./venv/Scripts/python.exe plot_by_block_name.py \"../04_Test_Files/塔器.dxf\" -o test_output)",
"Bash(./venv/Scripts/python.exe plot_by_block_name.py \"../04_Test_Files/塔器.dxf\" --layout \"布局1\" -o test_output)",
"Bash(./venv/Scripts/python.exe:*)"
],
"deny": [],
"ask": []
}
}

View File

@ -123,14 +123,20 @@
万事俱备!现在运行 `draw_table_from_template.py` 脚本,将**您的模板**、您的数据和您的目标文件作为参数传入。 万事俱备!现在运行 `draw_table_from_template.py` 脚本,将**您的模板**、您的数据和您的目标文件作为参数传入。
最重要的,您现在可以通过 `--x``--y` 参数来精确指定表格**左下角的插入坐标**。 最重要的,您现在可以通过 `--x``--y` 参数来指定插入坐标,并通过 `--anchor` 参数来定义这些坐标所对应的**锚点**。
**锚点选项**:
- `bottom-left` (默认): `(x, y)` 是表格的左下角。
- `bottom-right`: `(x, y)` 是表格的右下角。
- `top-left`: `(x, y)` 是表格的左上角。
- `top-right`: `(x, y)` 是表格的右上角。
```shell ```shell
# 用法: python draw_table_from_template.py <目标DXF> <您的表头模板> <您的列模板> <您的数据JSON> <输出DXF> --x <X坐标> --y <Y坐标> # 用法: python draw_table_from_template.py <目标DXF> <您的表头模板> <您的列模板> <您的数据JSON> <输出DXF> --x <X坐标> --y <Y坐标> --anchor <锚点>
./venv/Scripts/python 03_Python_OpenSource_DXF/draw_table_from_template.py "C:/path/to/target_drawing.dxf" "C:/path/to/my_header_template.json" "C:/path/to/my_columns_template.json" "C:/path/to/my_data.json" "C:/path/to/output_with_table.dxf" --x 300 --y 100 ./venv/Scripts/python 03_Python_OpenSource_DXF/draw_table_from_template.py "C:/path/to/target_drawing.dxf" "C:/path/to/my_header_template.json" "C:/path/to/my_columns_template.json" "C:/path/to/my_data.json" "C:/path/to/output_with_table.dxf" --x 420 --y 297 --anchor top-right
``` ```
执行完毕后,`output_with_table.dxf` 文件中就会在 (300, 100) 的位置出现一个根据您的样式和数据绘制好的、崭新的表格。 执行完毕后,`output_with_table.dxf` 文件的右上角将被精确定位在 `(420, 297)` 坐标点,并出现一个根据您的样式和数据绘制好的、崭新的表格。
--- ---

View File

@ -1,64 +0,0 @@
import ezdxf
from ezdxf.addons.drawing import RenderContext, Frontend
from ezdxf.addons.drawing.matplotlib import MatplotlibBackend
import matplotlib.pyplot as plt
import os
import sys
# --- 配置 ---
# 将脚本的父目录项目根目录添加到Python路径中
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
PROJECT_ROOT = os.path.dirname(SCRIPT_DIR)
sys.path.append(PROJECT_ROOT)
INPUT_DXF_NAME = "图签测试.dxf"
OUTPUT_PDF_NAME = "图签测试_from_dxf.pdf"
INPUT_DXF_PATH = os.path.join(SCRIPT_DIR, INPUT_DXF_NAME)
# 确保输出目录存在
output_dir = os.path.join(PROJECT_ROOT, "04_Test_Files", "结果")
os.makedirs(output_dir, exist_ok=True)
OUTPUT_PDF_PATH = os.path.join(output_dir, OUTPUT_PDF_NAME)
def dxf_to_pdf(input_path, output_path):
"""
将指定的 DXF 文件渲染并保存为 PDF
"""
if not os.path.exists(input_path):
print(f"错误: 输入的 DXF 文件未找到: '{input_path}'")
return
try:
print(f"--- 正在加载 DXF 文件: {os.path.basename(input_path)} ---")
doc = ezdxf.readfile(input_path)
msp = doc.modelspace()
# 创建 Matplotlib Figure 和 Axes
fig = plt.figure()
ax = fig.add_axes([0, 0, 1, 1])
# 设置渲染上下文和后端
ctx = RenderContext(doc)
out = MatplotlibBackend(ax)
print("--- 开始渲染 DXF 内容 ---")
# 使用 ezdxf 的绘图插件渲染模型空间
Frontend(ctx, out).draw_layout(msp, finalize=True)
print(f"--- 正在将渲染结果保存为 PDF: {os.path.basename(output_path)} ---")
# 保存为 PDFdpi可以调整清晰度bbox_inches='tight'会自动裁剪空白边缘
fig.savefig(output_path, dpi=300, bbox_inches='tight', pad_inches=0.1)
plt.close(fig)
print("\n操作成功!")
print(f"PDF 文件已保存到: '{output_path}'")
except IOError:
print(f"错误: 无法读取文件: '{input_path}'")
except Exception as e:
print(f"处理并转换 DXF 文件时发生未知错误: {e}")
if __name__ == "__main__":
dxf_to_pdf(INPUT_DXF_PATH, OUTPUT_PDF_PATH)

View File

@ -0,0 +1,49 @@
import ezdxf
import argparse
from pathlib import Path
def diagnose_blocks(dxf_file: Path):
"""
加载一个DXF文件并打印出其模型空间中所有顶层块参照的名称
"""
if not dxf_file.is_file():
print(f"错误: 文件不存在 -> {dxf_file}")
return
try:
doc = ezdxf.readfile(dxf_file)
except IOError:
print(f"错误: 无法读取文件 -> {dxf_file}")
return
except ezdxf.DXFStructureError as e:
print(f"DXF 文件结构错误: {e}")
return
msp = doc.modelspace()
top_level_blocks = msp.query('INSERT')
print(f"\n--- 在 '{dxf_file.name}' 的模型空间中找到的顶层块参照 ---")
if not top_level_blocks:
print("未找到任何顶层的块参照 (INSERT entities)。")
return
# 为了更好的可读性,我们统计一下每个块名出现的次数
from collections import Counter
block_names = [block.dxf.name for block in top_level_blocks]
block_counts = Counter(block_names)
print(f"共找到 {len(top_level_blocks)} 个块参照,涉及 {len(block_counts)} 个不同的块定义。")
print("-" * 50)
for name, count in block_counts.items():
print(f" 块名: '{name}' \t (在模型空间中出现了 {count} 次)")
print("-" * 50)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="诊断DXF文件列出其模型空间中所有顶层的块参照名称。"
)
parser.add_argument("input_dxf", type=Path, help="要诊断的源DXF文件的路径。")
args = parser.parse_args()
diagnose_blocks(args.input_dxf)

View File

@ -192,8 +192,16 @@ def main():
# Output file # Output file
parser.add_argument("output_dxf", help="Path to the output DXF file to write.") parser.add_argument("output_dxf", help="Path to the output DXF file to write.")
# Optional coordinates # Optional coordinates
parser.add_argument("--x", type=float, default=260.0, help="The X coordinate for the table's bottom-left insertion point.") parser.add_argument("--x", type=float, default=260.0, help="The X coordinate for the table's anchor point.")
parser.add_argument("--y", type=float, default=50.0, help="The Y coordinate for the table's bottom-left insertion point.") parser.add_argument("--y", type=float, default=50.0, help="The Y coordinate for the table's anchor point.")
parser.add_argument(
"--anchor",
type=str,
default="bottom-left",
choices=["bottom-left", "bottom-right", "top-left", "top-right"],
help="Sets the anchor point of the table for the insertion coordinates (--x, --y)."
)
parser.add_argument("--layout", type=str, default=None, help="The name of the layout to draw on. Defaults to modelspace.")
args = parser.parse_args() args = parser.parse_args()
# --- Load Templates --- # --- Load Templates ---
@ -207,15 +215,28 @@ def main():
return return
# --- Load DXF --- # --- Load DXF ---
doc = None
msp = None
try: try:
if os.path.exists(args.source_dxf): if os.path.exists(args.source_dxf):
doc = ezdxf.readfile(args.source_dxf) doc = ezdxf.readfile(args.source_dxf)
msp = doc.modelspace()
print(f"Loaded source DXF file: {args.source_dxf}") print(f"Loaded source DXF file: {args.source_dxf}")
else: else:
print(f"Source file not found, creating a new DXF document.") print(f"Source file not found, creating a new DXF document.")
doc = ezdxf.new() doc = ezdxf.new()
if args.layout:
try:
msp = doc.layouts.get(args.layout)
print(f"Using layout: {args.layout}")
except KeyError:
print(f"Error: Layout '{args.layout}' not found in the document.")
print("Available layouts:", ", ".join(doc.layouts.names()))
return
else:
msp = doc.modelspace() msp = doc.modelspace()
print("Using modelspace.")
except IOError: except IOError:
print(f"Could not read source DXF file: {args.source_dxf}. Creating a new document.") print(f"Could not read source DXF file: {args.source_dxf}. Creating a new document.")
doc = ezdxf.new() doc = ezdxf.new()
@ -229,10 +250,34 @@ def main():
if bom_data is None: if bom_data is None:
return return
# --- Calculate table dimensions to determine the final start position ---
col_boundaries = header_template.get("column_boundaries", [0])
table_width = col_boundaries[-1] - col_boundaries[0]
header_height = header_template.get("header_height", 0)
row_height = columns_template.get("row_height", 8.0)
num_data_rows = len(bom_data)
table_height = header_height + num_data_rows * row_height
# --- Adjust start position based on the anchor ---
start_x = args.x
start_y = args.y
if args.anchor == "bottom-right":
start_x -= table_width
elif args.anchor == "top-left":
start_y -= table_height
elif args.anchor == "top-right":
start_x -= table_width
start_y -= table_height
# The drawing function always uses the bottom-left corner as the start position
final_start_position = Vec3(start_x, start_y)
# --- Draw Table --- # --- Draw Table ---
print("Drawing table from templates...") print(f"Drawing table with anchor '{args.anchor}' at ({args.x}, {args.y})...")
start_position = Vec3(args.x, args.y) print(f"Calculated bottom-left start position: ({final_start_position.x:.2f}, {final_start_position.y:.2f})")
draw_table_from_template(msp, start_position, header_template, columns_template, bom_data) draw_table_from_template(msp, final_start_position, header_template, columns_template, bom_data)
# --- Save Output --- # --- Save Output ---
try: try:

View File

@ -0,0 +1,170 @@
import ezdxf
import sys
from ezdxf.addons.drawing import RenderContext, Frontend
from ezdxf.addons.drawing.matplotlib import MatplotlibBackend
from ezdxf.addons.drawing.properties import Configuration
from ezdxf import bbox # 导入边界框计算模块
import matplotlib.pyplot as plt
import os
import json # 导入JSON模块
import argparse # 导入命令行参数处理模块
# --- 配置 ---
# 将脚本的父目录项目根目录添加到Python路径中
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
PROJECT_ROOT = os.path.dirname(SCRIPT_DIR)
sys.path.append(PROJECT_ROOT)
# 指定字体目录
FONT_DIR = r"C:\Users\83500\久翌\CAD编辑同步excel\测试文件区\03_Python_OpenSource_DXF\fonts"
def main():
"""
主函数用于解析命令行参数并调用核心处理函数
"""
# --- 1. 设置命令行参数解析 ---
parser = argparse.ArgumentParser(
description="将 DXF 文件导出为 PDF, PNG, 并提取其坐标保存为 JSON。",
formatter_class=argparse.RawTextHelpFormatter # 保持帮助文本的格式
)
parser.add_argument(
"input_dxf_path",
type=str,
help="要处理的源 DXF 文件的完整路径。"
)
# 设置默认输出目录
default_output_dir = os.path.join(PROJECT_ROOT, "04_Test_Files", "结果")
parser.add_argument(
"--output_dir",
type=str,
default=default_output_dir,
help="指定输出文件PDF, PNG, JSON的保存目录。\n"
f"如果未提供,将默认使用:\n{default_output_dir}"
)
parser.add_argument(
'--crop',
nargs=4,
type=float,
metavar=('X1', 'Y1', 'X2', 'Y2'),
help="提供一个矩形区域的两个对角点坐标 (X1 Y1 X2 Y2) 来裁剪输出的图像。"
)
args = parser.parse_args()
# --- 2. 确保输出目录存在 ---
os.makedirs(args.output_dir, exist_ok=True)
# --- 3. 调用核心功能 ---
export_dxf_with_coords(args.input_dxf_path, args.output_dir, crop_coords=args.crop)
def export_dxf_with_coords(input_path, output_dir, crop_coords=None):
"""
将指定的 DXF 文件中的 "布局1" 渲染为 PDF PNG并将其边界坐标保存为 JSON 文件
如果提供了 crop_coords则会对输出的图像进行裁剪
"""
# --- 1. 检查输入文件是否存在 ---
if not os.path.exists(input_path):
print(f"错误: 输入的 DXF 文件未找到: '{input_path}'")
return
# --- 2. 设置输出文件名 ---
base_name = os.path.splitext(os.path.basename(input_path))[0]
json_path = os.path.join(output_dir, f"{base_name}_coords.json")
pdf_path = os.path.join(output_dir, f"{base_name}.pdf")
png_path = os.path.join(output_dir, f"{base_name}.png")
try:
# --- 3. 加载并解析 DXF 文件 ---
print(f"--- 正在加载 DXF 文件: {os.path.basename(input_path)} ---")
doc = ezdxf.readfile(input_path)
# --- 新增: 查找并使用 "布局1" ---
layout_name = '布局1'
try:
layout = doc.layouts.get(layout_name)
print(f"--- 已成功找到并切换到布局: '{layout_name}' ---")
except KeyError:
available_layouts = ", ".join(doc.layouts.names())
print(f"错误: 在 DXF 文件中找不到名为 '{layout_name}' 的布局。")
print(f"该文件中可用的布局有: [{available_layouts}]")
return
# --- 4. 计算图纸边界并保存为 JSON (基于布局) ---
print(f"--- 正在计算 '{layout_name}' 的边界坐标 ---")
extents = bbox.extents(layout, fast=True)
if not extents.has_data:
print(f"警告: 布局 '{layout_name}' 中不包含任何实体,无法计算坐标。")
# 即使没有坐标,也可能需要渲染一个空白页面,所以这里我们不直接返回
coords = {}
else:
coords = {
"bottom_left": {"x": round(extents.extmin.x, 2), "y": round(extents.extmin.y, 2)},
"bottom_right": {"x": round(extents.extmax.x, 2), "y": round(extents.extmin.y, 2)},
"top_left": {"x": round(extents.extmin.x, 2), "y": round(extents.extmax.y, 2)},
"top_right": {"x": round(extents.extmax.x, 2), "y": round(extents.extmax.y, 2)},
}
with open(json_path, 'w', encoding='utf-8') as f:
json.dump(coords, f, ensure_ascii=False, indent=4)
print(f"坐标已成功保存到: '{json_path}'")
# --- 5. 配置渲染器(包括字体) ---
# 鉴于当前环境存在无法解释的版本冲突问题,
# 我们回退到使用全局 support_dirs 的方法,这种方法兼容性更强,可以绕过问题。
if FONT_DIR not in ezdxf.options.support_dirs:
ezdxf.options.support_dirs.append(FONT_DIR)
# 使用默认配置, 并添加解决方法来处理3D点实体
config = Configuration.defaults().with_changes(
# 将点的大小设置为0这会让渲染器将点绘制为单个像素
# 从而绕过在处理3D点(POINT)的复杂几何图形时可能出现的Z坐标问题。
pdsize=0,
)
# --- 6. 渲染 DXF 内容 ---
fig = plt.figure()
ax = fig.add_axes([0, 0, 1, 1])
ctx = RenderContext(doc)
out = MatplotlibBackend(ax)
print("--- 开始渲染 DXF 内容 ---")
Frontend(ctx, out, config=config).draw_layout(layout, finalize=True)
# --- 新增: 应用裁剪区域 ---
if crop_coords:
x1, y1, x2, y2 = crop_coords
min_x, max_x = min(x1, x2), max(x1, x2)
min_y, max_y = min(y1, y2), max(y1, y2)
print(f"--- 正在应用裁剪区域: X({min_x:.2f} - {max_x:.2f}), Y({min_y:.2f} - {max_y:.2f}) ---")
ax.set_xlim(min_x, max_x)
ax.set_ylim(min_y, max_y)
# --- 7. 保存为 PDF ---
print(f"--- 正在保存为 PDF: {os.path.basename(pdf_path)} ---")
fig.savefig(pdf_path, dpi=300, bbox_inches='tight', pad_inches=0.1)
print(f"PDF 文件已保存到: '{pdf_path}'")
# --- 8. 保存为 PNG ---
print(f"--- 正在保存为 PNG: {os.path.basename(png_path)} ---")
fig.savefig(png_path, dpi=300, bbox_inches='tight', pad_inches=0.1)
print(f"PNG 文件已保存到: '{png_path}'")
plt.close(fig)
print("\n操作成功完成!")
except IOError:
print(f"错误: 无法读取文件: '{input_path}'")
except Exception as e:
print(f"处理并转换 DXF 文件时发生未知错误: {e}")
if __name__ == "__main__":
main()

Binary file not shown.

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,156 @@
% Copyright (C) 1989, 1990, 1991 Aladdin Enterprises. All rights reserved.
% Distributed by Free Software Foundation, Inc.
%
% This file is part of Ghostscript.
%
% Ghostscript is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
% to anyone for the consequences of using it or for whether it serves any
% particular purpose or works at all, unless he says so in writing. Refer
% to the Ghostscript General Public License for full details.
%
% Everyone is granted permission to copy, modify and redistribute
% Ghostscript, but only under the conditions described in the Ghostscript
% General Public License. A copy of this license is supposed to have been
% given to you along with Ghostscript so you can know your rights and
% responsibilities. It should be in a file named COPYING. Among other
% things, the copyright notice and this notice must be preserved on all
% copies.
% This file provides a dummy 'statusdict' and 'serverdict',
% and a few of the other LaserWriter operators, for the benefit of
% PostScript programs that think they are running on a LaserWriter.
%
% ***********************************************************************
% * *
% * M M OOO DDDD III FFFFF III EEEEE DDDD *
% * MM MM O O D D I F I E D D *
% * M M M O O D D I F I E D D *
% * M M O O D D I FFF I EEE D D *
% * M M O O D D I F I E D D *
% * M M O O D D I F I E D D *
% * M M OOO DDDD III F III EEEEE DDDD *
% * *
% * *
% * FFFFF III L EEEEE *
% * F I L E *
% * F I L E *
% * FFF I L EEE *
% * F I L E *
% * F I L E *
% * F III LLLLL EEEEE *
% * *
% ***********************************************************************
%
% .-------------.
% | /\ |
% | / \ |
% | / /\ \ |
% | / / \ \ |
% | / / /\ \ \ |
% | / / / \ \ \|
% `-------------' (R)
% Autodesk, Inc.
% Tools For the Golden Age of Engineering
%
% In keeping with subparagraph 2a of the Gnu General Public License
% (Version 1, February 1989):
%
% 2. You may modify your copy or copies of the Program or any
% portion of it, and copy and distribute such modifications under
% the terms of Paragraph 1 above, provided that you also do the
% following:
%
% a) cause the modified files to carry prominent notices stating
% that you changed the files and the date of any change; and...
%
% the following is a summary of the changes to this file made by
% Autodesk, Inc. in August 1991 in order to adapt Ghostscript to run
% as an ADS application and thereby to perform rendering of
% PostScript files within AutoCAD.
%
% STATUSD.PS Renamed to be ACADPSD.PS
%
% ************************************************************************
systemdict begin
/letter {statusdict begin 0 setpagetype end} def
/note {statusdict begin 1 setpagetype end} def
/legal {} def
/a4 {} def % not in original Red Book,
% but apparently standard now
/statusdict 50 dict def
/serverdict 4 dict def
end
statusdict begin
/checkpassword {statusdict begin .password eq end} def
/defaulttimeouts {statusdict begin .timeouts aload pop end} def
%/dostartpage
/eescratch {pop 0} def
/idlefonts {statusdict begin mark .idlefonts aload pop end} def
/jobname () def
%/jobtimeout
/manualfeed false def
/manualfeedtimeout 60 def
/margins {statusdict begin .topmargin .leftmargin end} def
/pagecount {4711} def
/pagestackorder {false} def
%/pagetype
/prefeed false def
/printererror {pop pop} def
/printername {statusdict begin .printername exch copy end} def
/product (Ghostscript) def
/revision 20100 def
/sccbatch {pop 9600 0} def
/sccinteractive {pop 9600 0} def
/setdefaulttimeouts {statusdict begin .timeouts astore pop end} def
/setdostartpage {statusdict exch /dostartpage exch put} def
/seteescratch {pop pop} def
/setidlefonts {] statusdict exch /.idlefonts exch put} def
/setjobtimeout {statusdict exch /jobtimeout exch put} def
/setmargins
{statusdict begin /.lmargin exch def /.topmargin exch def end} def
/setpagetype {statusdict exch /pagetype exch put} def
/setpassword
{exch checkpassword
{statusdict exch /.password exch put true}
{pop false}
ifelse} def
/setprintername
{dup length string copy statusdict exch /printername exch put} def
/setsccbatch {pop pop pop} def
/setsccinteractive {pop pop pop} def
/waittimeout 300 def
/.password 0 def
/.timeouts [0 60 30] def
true setdostartpage
mark setidlefonts
0 setjobtimeout
0 0 setmargins
0 setpagetype
product setprintername
end % statusdict
% The following contents of serverdict are a complete guess,
% based on some observed LaserWriter boilerplate.
serverdict begin
/execjob { } def
% The Red Book implies that something like the following is
% an appropriate definition of exitserver.
/exitserver { clear stop } def
% However, this interacts badly with Ghostscript's present error handler,
% so we override it with the following less appropriate definition.
/exitserver { clear cleardictstack } def
/setrealdevice { } def
end % serverdict

View File

@ -0,0 +1,275 @@
% Copyright (C) 1990, 1991 Aladdin Enterprises. All rights reserved.
% Distributed by Free Software Foundation, Inc.
%
% This file is part of Ghostscript.
%
% Ghostscript is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
% to anyone for the consequences of using it or for whether it serves any
% particular purpose or works at all, unless he says so in writing. Refer
% to the Ghostscript General Public License for full details.
%
% Everyone is granted permission to copy, modify and redistribute
% Ghostscript, but only under the conditions described in the Ghostscript
% General Public License. A copy of this license is supposed to have been
% given to you along with Ghostscript so you can know your rights and
% responsibilities. It should be in a file named COPYING. Among other
% things, the copyright notice and this notice must be preserved on all
% copies.
% Font initialization for Ghostscript. Despite anything claimed below,
% Ghostscript fonts are actually in the same format as Adobe Type 1 fonts,
% except that the external form customarily does not use eexec encryption.
% Someday there will be GNU documentation that describes this format.
% Until then, you'll have to either get a copy of Adobe's book, or read
% the Ghostscript code. The interpreter for Type 1 fonts, which reveals
% most of their structure, is in the file gstype1.c.
%
% ***********************************************************************
% * *
% * M M OOO DDDD III FFFFF III EEEEE DDDD *
% * MM MM O O D D I F I E D D *
% * M M M O O D D I F I E D D *
% * M M O O D D I FFF I EEE D D *
% * M M O O D D I F I E D D *
% * M M O O D D I F I E D D *
% * M M OOO DDDD III F III EEEEE DDDD *
% * *
% * *
% * FFFFF III L EEEEE *
% * F I L E *
% * F I L E *
% * FFF I L EEE *
% * F I L E *
% * F I L E *
% * F III LLLLL EEEEE *
% * *
% ***********************************************************************
%
% .-------------.
% | /\ |
% | / \ |
% | / /\ \ |
% | / / \ \ |
% | / / /\ \ \ |
% | / / / \ \ \|
% `-------------' (R)
% Autodesk, Inc.
% Tools For the Golden Age of Engineering
%
% In keeping with subparagraph 2a of the Gnu General Public License
% (Version 1, February 1989):
%
% 2. You may modify your copy or copies of the Program or any
% portion of it, and copy and distribute such modifications under
% the terms of Paragraph 1 above, provided that you also do the
% following:
%
% a) cause the modified files to carry prominent notices stating
% that you changed the files and the date of any change; and...
%
% the following is a summary of the changes to this file made by
% Autodesk, Inc. in August 1991 in order to adapt Ghostscript to run
% as an ADS application and thereby to perform rendering of
% PostScript files within AutoCAD.
%
% ACADPSF.PS Ghostscript font loading procedures. Called
% GS_FONTS.PS in standard Ghostscript.
%
% Added handling for various strange characteristics of
% fonts encountered in the real world.
%
% Added exception handling when fontmap.ps has an incorrect
% entry, to prevent infinite recursion.
% ************************************************************************
% Define the default font.
/defaultfontname /Ugly def
% Internal procedure to load the font name -> font file name map
% if it isn't loaded already, and push it on the stack.
/Fontmap
{ /FontFileMap where
{ /FontFileMap get }
{ (fontmap.ps) findlibfile not
{ (Can't find ) print print (!\n) print stop }
if
FontDirectory maxlength dict exch
2 dict begin
mark exch 2 index exch
/;
{ % The stack contains a mark, the dictionary, the font name,
% the file name, and additional information about the font.
counttomark 3 sub { pop } repeat put
1 index
} bind def
run
end
pop pop % pop the mark and the copy of the dictionary
userdict exch /FontFileMap exch put
FontFileMap
}
ifelse
} bind def
% Define definefont. This is a procedure built on an operator that
% does all the error checking and key insertion.
/definefont
{ 1 dict begin count /d exch def % save stack depth in case of error
{ .buildfont readonly } stopped
{ count d sub { pop } repeat end /invalidfont signalerror }
{ end dup FontDirectory 4 2 roll put }
ifelse
} odef
/GnernDict 1 dict def
% Define findfont so it tries to load a font if it's not found.
/findfont
{
% If the key is a string, convert it to a name for lookup.
dup type /stringtype eq { cvn } if
% If the font isn't in FontDirectory already, load it.
dup FontDirectory exch known
{ FontDirectory exch get
}
{ dup % save the font name on the stack
% Push the font name -> font file name map on the stack,
% loading it if necessary.
Fontmap
% Read the file name from the map.
% (The stack contains the font name and the font file map.)
1 index known not
{ QUIET not
{ (Substituting ) print defaultfontname cvx =only
( for unknown font ) print == flush
} { pop } ifelse
pop defaultfontname findfont
}
{ FontFileMap exch get
% If we can't find the file, substitute for the font.
dup findlibfile
% save the filename here; we'll need it if the load fails.
2 index /savedfilename exch def
{ QUIET not
{ (Loading font file ) print exch print (... ) print flush }
{ exch pop }
ifelse
%
% Discard trash before PostScript sentinel
%
% Fonts that come with Adobe Type Manager have some
% trash binary bytes before the "%!" sentinel. Walk
% through the file and make sure we start reading at
% the sentinel.
%
{ dup read
{ 37 eq { dup read { 33 eq
{ dup dup fileposition 2 sub setfileposition exit }
{ unread } } { exit} ifelse
ifelse } if }
{ exit } ifelse
} loop
%
% End discarding of trash before PostScript sentinel
%
% Now it's time for some more adhocracy, another
% indulgence in Kelvinist predestination. It turns out
% that the various fonts we've accreted over the years
% obey no coherent conventions for what they leave or don't
% leave on the stack and some, based on the Adobe Type 1
% encryption decoder, even leave marks on the stack. To
% guarantee that we emerge from the font code with the
% stack in a valid state, we save the stack depth in a
% variable then programmatically pop any trash off the
% stack when we're done. This is ugly, but it works
% with every font I've tried.
count GnernDict begin /GnernK exch def end
mark exch
systemdict begin run end % run can take a file
cleartomark
% Now for the actial dirty work to put the stack back
% the way it was before we loaded the font.
GnernDict begin
{ count GnernK lt { exit } if pop} loop
end
QUIET not
{ vmstatus 3 { =only ( ) print } repeat
(done.\n) print flush
} if
% OK, make sure the thing has really been loaded.
dup FontDirectory exch known not
{
% Oops.
(The font ) print =only
( is not really in the file ) print
savedfilename =only
(\n) print flush
defaultfontname
} if
findfont
}
{ pop 1 index defaultfontname eq
{ (Can't find default font!\n) print
pop pop NullFont
}
{ (Can't find font file ) print print
(, substituting ) print defaultfontname cvx =only
(.\n) print flush
pop defaultfontname findfont
}
ifelse
}
ifelse
}
ifelse
} ifelse
} bind def
% The CharStrings for a Ghostscript font are a dictionary in which
% the key is the character name, and the value is a compressed
% representation of a path, as produced by type1imagepath.
% For detailed information, see the book
% "Adobe Type 1 Font Format", published by Adobe Systems Inc.
% Here is the BuildChar implementation
% for Type 1 (Ghostscript standard) fonts.
% The name Type1BuildChar is known to the interpreter.
/Type1BuildChar
{ exch begin
Encoding exch get
dup CharStrings exch known not
{ QUIET not
{ (Substituting .notdef for ) print = flush
} { pop } ifelse
/.notdef
} if
CharStrings exch get
PaintType 0 ne
{ 1 setmiterlimit 1 setlinejoin 1 setlinecap
currentdict /StrokeWidth known { StrokeWidth } { 0 } ifelse
setlinewidth }
if
type1addpath % does a fill or stroke
end
} bind def

View File

@ -0,0 +1,820 @@
% Copyright (C) 1989, 1990, 1991 Aladdin Enterprises. All rights reserved.
% Distributed by Free Software Foundation, Inc.
%
% This file is part of Ghostscript.
%
% Ghostscript is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
% to anyone for the consequences of using it or for whether it serves any
% particular purpose or works at all, unless he says so in writing. Refer
% to the Ghostscript General Public License for full details.
%
% Everyone is granted permission to copy, modify and redistribute
% Ghostscript, but only under the conditions described in the Ghostscript
% General Public License. A copy of this license is supposed to have been
% given to you along with Ghostscript so you can know your rights and
% responsibilities. It should be in a file named COPYING. Among other
% things, the copyright notice and this notice must be preserved on all
% copies.
%
% ***********************************************************************
% * *
% * M M OOO DDDD III FFFFF III EEEEE DDDD *
% * MM MM O O D D I F I E D D *
% * M M M O O D D I F I E D D *
% * M M O O D D I FFF I EEE D D *
% * M M O O D D I F I E D D *
% * M M O O D D I F I E D D *
% * M M OOO DDDD III F III EEEEE DDDD *
% * *
% * *
% * FFFFF III L EEEEE *
% * F I L E *
% * F I L E *
% * FFF I L EEE *
% * F I L E *
% * F I L E *
% * F III LLLLL EEEEE *
% * *
% ***********************************************************************
%
% .-------------.
% | /\ |
% | / \ |
% | / /\ \ |
% | / / \ \ |
% | / / /\ \ \ |
% | / / / \ \ \|
% `-------------' (R)
% Autodesk, Inc.
% Tools For the Golden Age of Engineering
%
% In keeping with subparagraph 2a of the Gnu General Public License
% (Version 1, February 1989):
%
% 2. You may modify your copy or copies of the Program or any
% portion of it, and copy and distribute such modifications under
% the terms of Paragraph 1 above, provided that you also do the
% following:
%
% a) cause the modified files to carry prominent notices stating
% that you changed the files and the date of any change; and...
%
% the following is a summary of the changes to this file made by
% Autodesk, Inc. in August 1991 in order to adapt Ghostscript to run
% as an ADS application and thereby to perform rendering of
% PostScript files within AutoCAD.
%
%
% ACADPSI.PS I implemented a new procedure, "arun", which is used
% by the (PSGEN) function to run PostScript programs
% included with the PSIN command. "Arun" is a somewhat
% more intelligent version of "run" which accommodates
% variants of PostScript one encounters, especially on
% MS-DOS machines. If the binary "EPSF" header is
% present, used by desktop publishing programs which
% append a bitmap of the PostScript image to the file,
% arun recognises the sentinel, extracts the pointer to
% the bitmap from the header, and uses the new
% setsubfilelimit operator to logically truncate the
% file at that point. A setfileposition is then done to
% skip the header. To allow processing files with a few
% bytes of garbage before the "%!" sentinel, arun reads
% through the file searching for "%!", ignoring anything
% it finds before the sentinel.
%
% Ghostscript master initialisation file. Called
% GS_INIT.PS in standard Ghostscript. I added a new
% "acadpsversion" operator to return the local version
% of ACADPS ("2.2-ACADPS:Q001-JW1" in this release). I
% extended error handling to call "flagerrorhappened" so
% that the error code can be returned to the caller of
% (PSGEN). I changed the file name references to the
% ACADPSx.PS conventions and integrated the local code
% for ARUN, etc., from the version based on Ghostscript
% 2.1.1. I used the new NOPAUSE variable to suppress
% the pause in "copypage" and "showpage" rather than
% commenting out the user prompt as before. (New file.)
%
%
% ************************************************************************
% Initialization file for Ghostscript.
% When this is run, systemdict is still writable.
% Acquire the debugging flags.
currentdict /DEBUG known /DEBUG exch def
/VMDEBUG
DEBUG {{vmstatus pop ( ) cvs print pop ( ) print
systemdict length ( ) cvs print (\n) print flush}}
{{}} ifelse
def
currentdict /NODISPLAY known not /DISPLAYING exch def
currentdict /NOBIND known { /.bind /bind load def /bind { } def } if
currentdict /NOCACHE known /NOCACHE exch def
currentdict /NOPAUSE known /NOPAUSE exch def
currentdict /QUIET known /QUIET exch def
QUIET not { (Initializing... ) print flush } if
% Acquire systemdict and userdict.
% Note that the dictionary stack only has 1 element at this point!
/systemdict currentdict def
/userdict 200 dict def
userdict begin % 2 elements now
systemdict begin
VMDEBUG
% Define true and false.
/true 0 0 eq def
/false 0 1 eq def
% Turn on array packing for the rest of initialization.
true setpacking
% Acquire the standard files.
/.stdin (%stdin) (r) file def
/.stdout (%stdout) (w) file def
/.stderr (%stderr) (w) file def
% Define a special version of def for making operator procedures.
/odef
{1 index exch makeoperator def} bind def
% Define predefined procedures substituting for operators,
% in alphabetical order.
/[ /mark load def
/] {counttomark array astore exch pop} odef
/abs {dup 0 lt {neg} if} odef
/cleardictstack
{countdictstack 2 sub {end} repeat} odef
/.copypage /copypage load def
/copypage
{.copypage
(>>copypage, press <return> to continue<<\n) .confirm} odef
/defaultmatrix
{currentdevice exch deviceparams pop pop
counttomark 1 add 1 roll cleartomark} odef
/.echo /echo load def
userdict /.echo.mode true put
/echo {dup /.echo.mode exch store .echo} odef
/eexec {55665 exch type1decryptfile
cvx systemdict begin stopped end
$error /newerror get and {handleerror} if} odef
/executive
{ { prompt (%statementedit) (r) file
dup bytesavailable 0 lt
{ .stdin bytesavailable 0 lt {closefile exit} if }
if cvx execute
} loop
} odef
/framedevice
{.stderr (Warning: framedevice is an obsolete operator.\n) writestring
.stderr flushfile
pop pop pop setmatrix initclip} odef
/handleerror
{errordict /handleerror get exec} bind def
/identmatrix
{{1.0 0.0 0.0 1.0 0.0 0.0} cvlit exch copy} odef
/initgraphics
{initmatrix newpath initclip 1 setlinewidth 0 setlinecap 0 setlinejoin
[] 0 setdash 0 setgray 10 setmiterlimit} odef
/initmatrix
{.tempmatrix defaultmatrix setmatrix} odef
/matrix {6 array identmatrix} odef
/prompt {flush flushpage
(GS) print count 0 ne
{(<) print count =only}
if (>) print flush} bind def
/pstack {0 1 count 3 sub {index ==} for} odef
/run {dup type /filetype eq { true } { findlibfile } ifelse
{cvx execute}
{(r) file} % let the error happen
ifelse} odef
/selectfont
{ exch findfont exch
dup type /arraytype eq { makefont } { scalefont } ifelse
setfont
} odef
/showpage
{.copypage (>>showpage, press <return> to continue<<\n) .confirm
erasepage initgraphics} odef
/stack {0 1 count 3 sub {index =} for} odef
/start { QUIET not
{(Ghostscript ) print .version print
( Copyright (C) 1990, 1991 Aladdin Enterprises,\n) print
( Menlo Park, CA. All rights reserved.\n) print
(Distributed by Free Software Foundation, Inc.\n) print
(Ghostscript comes with NO WARRANTY: see the file COPYING for details.\n) print
flush
} if
executive
} def
% Define version so it prints a warning once, for programs that think that
% they are going to get an Adobe interpreter version.
/version
{ <00> % Flag to make sure we only do this once
dup 0 get 0 eq
{ .stderr (Warning -- Ghostscript version #s are not the same as Adobe version #s.\n) writestring
.stderr flushfile
0 1 put
}
{ pop }
ifelse .version
} odef
/.version
(2.2) def
% ACADPS version string, including base Ghostscript version
/acadpsversion
(2.2-ACADPS:Q001-JW1) def
% Provide semi-fake but usable definitions for
% the color PostScript extensions (except for colorimage,
% which is actually implemented as an operator).
/setcmykcolor {
1 exch sub dup dup % C, M, Y, S, S, S
6 -1 roll 1 exch sub mul % M, Y, S, S, red
exch 5 -1 roll 1 exch sub mul % Y, S, red, green
4 -2 roll exch 1 exch sub mul % red, green, blue
setrgbcolor
} odef
/currentcmykcolor {
currentrgbcolor
3 { 1 exch sub 3 1 roll } repeat
0
} odef
/setblackgeneration {
pop
} odef
/currentblackgeneration {
{}
} odef
/setundercolorremoval {
pop
} odef
/currentundercolorremoval {
{}
} odef
/setcolorscreen {
setscreen 9 {pop} repeat
} odef
/currentcolorscreen {
currentscreen 3 copy 6 copy
} odef
% Define some additional built-in procedures (beyond the ones defined by
% the PostScript Language Reference Manual).
/concatprocs
{ exch cvlit exch cvlit % proc1 proc2
dup length 2 index length add array % proc1 proc2 newproc
dup 0 4 index putinterval
dup 3 index length 3 index putinterval
exch pop exch pop cvx
} bind def
/concatstrings
{ 1 index length 1 index length add string
2 index 1 index copy pop
dup 3 index length 3 index length getinterval
2 index exch copy pop
exch pop exch pop
} bind def
/copyarray
{ dup length array copy } bind def
/copystring
{ dup length string copy } bind def
/defaultdevice
{ systemdict /DEVICE known
{ systemdict /DEVICE get finddevice }
{ 0 getdevice }
ifelse
} bind def
/finddevice
{ systemdict /devicedict get exch get } bind def
/rgbcolor
{ gsave setrgbcolor currentgscolor grestore } bind def
/selectdevice
{ finddevice setdevice } bind def
/signalerror % object errorname
{ errordict exch get exec } bind def
% Define auxiliary procedures needed for the above.
/shellarguments % -> shell_arguments true (or) false
{ /ARGUMENTS where
{ /ARGUMENTS get dup type /arraytype eq
{ aload pop /ARGUMENTS null store true }
{ pop false }
ifelse }
{ false } ifelse
} bind def
/.confirm
{DISPLAYING NOPAUSE not and
{% Print a message and wait for the user to type something.
% If the user just types a newline, flush it.
print flush
.echo.mode false echo
.stdin dup read
{dup (\n) 0 get eq {pop pop} {unread} ifelse} {pop} ifelse
echo}
{pop} ifelse} bind def
/.identmatrix % a read-only identity matrix
matrix readonly def
/.tempmatrix % a temporary matrix
matrix def
% Define the procedure used by the C executive for executing user input,
% and also by the run operator.
% This is called with a procedure or file on the operand stack.
/execute
{stopped $error /newerror get and {handleerror} if} odef
% Create the error handling machinery.
% The interpreter has created the ErrorNames array.
% Define $error.
/$error 11 dict def % newerror, errorname, command, errorinfo,
% ostack, estack, dstack, recordstacks,
% binary, .inerror, position
$error begin
/newerror false def
/recordstacks true def
/binary false def
/.inerror false def
end
% Define errordict. It has one entry per error name, plus handleerror.
/errordict ErrorNames length 1 add dict def
% Define the standard error handlers. When they are invoked,
% the top element of the o-stack is the error name;
% the next element is the offending command.
errordict begin
{ //$error /.inerror get .instopped not or
{ (Unrecoverable error: ) print =only flush
( in ) print = flush
count 0 gt
{ (Operand stack:\n ) print
0 1 count 3 sub { ( ) print index =only flush } for
(\n) print flush
} if
quit
} if % detect error recursion
$error /.inerror true put
$error /newerror true put
$error exch /errorname exch put
$error exch /command exch put
$error /dstack undef
$error /estack undef
$error /ostack undef
$error /recordstacks get $error /errorname get /VMerror ne and
{ $error /dstack countdictstack array dictstack put
$error /estack countexecstack array execstack put
count array astore dup $error exch /ostack exch put
aload pop
} if
$error /.inerror false put
stop
} bind
ErrorNames
{ [ 1 index 3 index /exec load ] cvx def
} forall
pop
end
% Define the standard handleerror.
errordict
begin
/handleerror
{
$error
begin
errorname (interrupt) eq
{
% Do not print out error messages and stack traces
% for interrupts; PSIN, if anyone, has that job.
}
{
(Error: ) print
errorname ==only flush
( in ) print
/command load ==only flush
currentdict /ostack known
{
(\nOperand stack:\n ) print ostack {
( ) print ==only
} forall
} if
currentdict /estack known
{
(\nExecution stack:\n ) print estack {
( ) print =only
} forall
} if
currentdict /dstack known
{
(\nDictionary stack:\n ) print dstack
{
dup ( ) print length =only (/) print maxlength =only
} forall
} if
(\n) print
} ifelse
flagerrorhappened
/newerror false def
end
currentdict /position known
{
(Current file position is ) print position =
}
if
flush
.instopped {
stop
} if
} bind def
end
% Define the =[only] procedures. Also define =print and =string,
% which are used by some P*stScr*pt programs even though
% they aren't documented anywhere.
/=print {=only} def
/=string 128 string def
/= {=only (\n) print} bind def
4 dict begin
/.buf =string def
/.print
{dup type currentdict exch known
{dup type exec} {.buf cvs print} ifelse
} bind def
/stringtype
{dup rcheck not {pop (--nostringval--)} if print} bind def
/nametype
{dup length .buf length gt
{dup length string}
{.buf}
ifelse cvs print} bind def
{0 begin .print end} copyarray dup 0 currentdict put
cvx bind
end
/=only exch def
% Define the [write]==[only] procedures.
/== {==only (\n) print} bind def
/==only {.stdout exch write==only} bind def
/write==
{2 copy write==only pop (\n) writestring} bind def
/.dict 17 dict dup
begin def
/.buf 128 string def
/.cvp {.buf cvs .p} bind def
% /.f {the_output_file} def
/.nop {(-) .p type .cvp (-) .p} bind def
/.p {.f exch writestring} bind def
/.p1 {.f exch write} bind def
/.print
{dup type .dict exch known
{dup type exec} {.nop} ifelse
} bind def
/integertype /.cvp load def
/realtype /.cvp load def
/booleantype /.cvp load def
/nametype
{dup xcheck not {(/) .p} if
dup length .buf length gt
{dup length string}
{.buf}
ifelse cvs .p} bind def
/arraytype
{dup rcheck
{dup xcheck {(})({)} {(])([)} ifelse .p
exch () exch
{exch .p .print ( )} forall pop .p}
{.nop}
ifelse} bind def
/operatortype
{(--) .p .cvp (--) .p} bind def
/packedarraytype /arraytype load def
/stringtype
{dup rcheck
{(\() .p
{/.ch exch def
.ch 32 lt .ch 127 ge or
{(\\) .p .ch 8#1000 add 8 .buf cvrs 1 3 getinterval .p}
{.ch 40 eq .ch 41 eq or .ch 92 eq or
{(\\) .p} if
.ch .p1}
ifelse}
forall (\)) .p}
{.nop}
ifelse} bind def
{0 begin exch cvlit /.f exch def .print end} copyarray dup 0 .dict put
bind cvx
end
/write==only exch def
VMDEBUG
% Define the font directory.
% Make it big to leave room for transformed fonts.
/FontDirectory 100 dict def
% Define the standard encoding vector.
/StandardEncoding
% \00x
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
% \04x
/space /exclam /quotedbl /numbersign
/dollar /percent /ampersand /quoteright
/parenleft /parenright /asterisk /plus
/comma /hyphen /period /slash
/zero /one /two /three
/four /five /six /seven
/eight /nine /colon /semicolon
/less /equal /greater /question
% \10x
/at /A /B /C /D /E /F /G
/H /I /J /K /L /M /N /O
/P /Q /R /S /T /U /V /W
/X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
% \14x
/quoteleft /a /b /c /d /e /f /g
/h /i /j /k /l /m /n /o
/p /q /r /s /t /u /v /w
/x /y /z /braceleft /bar /braceright /asciitilde /.notdef
% \20x
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
% \24x
/.notdef /exclamdown /cent /sterling
/fraction /yen /florin /section
/currency /quotesingle /quotedblleft /guillemotleft
/guilsinglleft /guilsinglright /fi /fl
/.notdef /endash /dagger /daggerdbl
/periodcentered /.notdef /paragraph /bullet
/quotesinglbase /quotedblbase /quotedblright /guillemotright
/ellipsis /perthousand /.notdef /questiondown
% \30x
/.notdef /grave /acute /circumflex /tilde /macron /breve /dotaccent
/dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
/emdash /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
% \34x
/.notdef /AE /.notdef /ordfeminine /.notdef /.notdef /.notdef /.notdef
/Lslash /Oslash /OE /ordmasculine /.notdef /.notdef /.notdef /.notdef
/.notdef /ae /.notdef /.notdef /.notdef /dotlessi /.notdef /.notdef
/lslash /oslash /oe /germandbls /.notdef /.notdef /.notdef /.notdef
256 packedarray def
% Define the ISO Latin-1 encoding vector.
% The first half is the same as the standard encoding.
/ISOLatin1Encoding
StandardEncoding 0 128 getinterval aload pop
%****** NOTE: the following are missing in the Adobe documentation,
%****** but appear in the displayed table:
%****** macron at 225, dieresis at 230, cedilla at 233, space at 240.
% \20x
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent
/dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
% \24x
/space /exclamdown /cent /sterling
/currency /yen /brokenbar /section
/dieresis /copyright /ordfeminine /guillemotleft
/logicalnot /hyphen /registered /macron
/degree /plusminus /twosuperior /threesuperior
/acute /mu /paragraph /periodcentered
/cedilla /onesuperior /ordmasculine /guillemotright
/onequarter /onehalf /threequarters /questiondown
% \30x
/Agrave /Aacute /Acircumflex /Atilde
/Adieresis /Aring /AE /Ccedilla
/Egrave /Eacute /Ecircumflex /Edieresis
/Igrave /Iacute /Icircumflex /Idieresis
/Eth /Ntilde /Ograve /Oacute
/Ocircumflex /Otilde /Odieresis /multiply
/Oslash /Ugrave /Uacute /Ucircumflex
/Udieresis /Yacute /Thorn /germandbls
% \34x
/agrave /aacute /acircumflex /atilde
/adieresis /aring /ae /ccedilla
/egrave /eacute /ecircumflex /edieresis
/igrave /iacute /icircumflex /idieresis
/eth /ntilde /ograve /oacute
/ocircumflex /otilde /odieresis /divide
/oslash /ugrave /uacute /ucircumflex
/udieresis /yacute /thorn /ydieresis
256 packedarray def
% Define a stub for the Symbol encoding.
userdict begin
/SymbolEncoding
{ userdict begin (acadpss.ps) run /SymbolEncoding load end
} bind def
end
% Construct a dictionary of all available devices.
mark
% Loop until the getdevice gets a rangecheck.
0 { {dup getdevice exch 1 add} loop} stopped pop
dict /devicedict exch def
devicedict begin % 2nd copy of count is on stack
{ dup devicename cvn dup 3 -1 roll def
counttomark 1 roll
} repeat
end
] /devicenames exch def
$error /newerror false put % remove error indication
% Define a special version of `run' that aborts on errors.
/run0
{ dup /.currentfilename exch def
{ findlibfile not { stop } if } stopped
{ pop (Can't find initialization file ) print = flush quit } if
cvx stopped
{ (While reading ) print .currentfilename print (:\n) print flush
handleerror quit
} if
} bind def
% Internal procedure used by ARUN to read a 32 bit word in Intel
% byte order. Not fast, but squeaky-clean PostScript wise. Leaves
% the file positioned after the value read.
/.arunRlong { % fileid -- integer
dup read pop
1 index read pop 8 bitshift or
1 index read pop 16 bitshift or
1 index read pop 24 bitshift or
exch pop
} bind def
% Pseudo-intelligent version of RUN. This version accepts all the
% odd crypto-PostScript files one sees in the real world. It knows
% about positioning over the binary EPSF header tacked on for
% PostScript annotated with bitmap images, and if all else fails it
% will scan over garbage in a file until it finds the file sentinel.
/arun {dup type /filetype eq { true } { findlibfile } ifelse
% Test for the EPSF binary sentinel
{ dup .arunRlong 16#C6D3D0C5 eq
{
% Matched binary sentinel. Position past it
% (Position past binary EPSF header\n) print flush
dup .arunRlong % PostScript code start address
1 index .arunRlong % PostScript code length
1 index add % Calculate end of PostScript text
2 index exch setsubfilelimit % Set logical EOF at text end
1 index exch setfileposition % Seek to start of PostScript
true
}
{
% This is not actually a binary EPSF sentinel. Seek
% back to the start of the file.
% (No EPSF Header\n) print flush
dup 0 setfileposition
false
}
ifelse
not
{
% (Searching for %!\n) print flush
{ dup read
{ 37 eq { dup read { 33 eq
{ dup dup fileposition 2 sub setfileposition exit }
{ unread } } { exit} ifelse
ifelse } if }
{ exit } ifelse
} loop
} if
cvx execute
}
{(r) file} % let the error happen
ifelse
} bind def
% Define statusdict, for the benefit of programs
% that think they are running on a LaserWriter or similar printer.
(acadpsd.ps) run0
% Load the initialization files for optional features.
[ (acadpsc.ps) run0 ] % a list of file names
{ run0 } forall
% Establish a default upper limit in the character cache,
% namely, 10 times the average expected character size.
mark
cachestatus 5 index 10 mul 2 index 1 max idiv % bmax, cmax
mark exch dup 10 idiv exch setcacheparams
cleartomark
% Conditionally disable the character cache.
NOCACHE { 1 setcachelimit } if
VMDEBUG
% Load the standard font environment.
(acadpsf.ps) run0
% Create a null font. This is the initial font.
7 dict dup begin
/FontMatrix [ 1 0 0 1 0 0 ] def
/FontType 3 def
/FontName () def
/Encoding StandardEncoding def
/FontBBox [ 0 0 0 0 ] cvx def % cvx is bogus, but customary ...
/BuildChar { pop pop 0 0 setcharwidth } bind def
end
/NullFont exch definefont setfont
% Define NullFont as the font, but remove it from FontDirectory.
/NullFont currentfont def
FontDirectory /NullFont undef
% Bind all the operators defined as procedures.
systemdict
{ dup type /operatortype eq
{ % This might be a real operator, so bind might cause a typecheck.
{ bind } stopped pop
$error /newerror false put % remove error indication
}
if pop pop
} forall
% Close up systemdict.
end
systemdict readonly pop
% Establish a default environment.
DISPLAYING
{ defaultdevice
systemdict /DEVICEWIDTH known systemdict /DEVICEHEIGHT known or
{ matrix deviceparams
exch /DEVICEWIDTH where
{ pop pop DEVICEWIDTH }
if
exch /DEVICEHEIGHT where
{ pop pop DEVICEHEIGHT
% Replace the Y translation if the Y axis is inverted
2 index 5 get 0 gt
{ 2 index 5 2 index put
}
if
}
if
defaultdevice 4 1 roll makedevice
counttomark 1 add 1 roll cleartomark
}
if setdevice % does an erasepage
}
{ nulldevice
}
ifelse
1 setflat % initgraphics doesn't set this
{ } settransfer % ditto
% The following 'ordered dither' spot function was contributed by
% Gregg Townsend. Thanks, Gregg!
72 72 dtransform abs exch abs min % min(|dpi x|,|dpi y|)
16.001 div 0 % not 16: avoids rounding problems
{ 1 add 7.9999 mul cvi exch 1 add 7.9999 mul cvi 16 mul add <
0E 8E 2E AE 06 86 26 A6 0C 8C 2C AC 04 84 24 A4
CE 4E EE 6E C6 46 E6 66 CC 4C EC 6C C4 44 E4 64
3E BE 1E 9E 36 B6 16 96 3C BC 1C 9C 34 B4 14 94
FE 7E DE 5E F6 76 D6 56 FC 7C DC 5C F4 74 D4 54
01 81 21 A1 09 89 29 A9 03 83 23 A3 0B 8B 2B AB
C1 41 E1 61 C9 49 E9 69 C3 43 E3 63 CB 4B EB 6B
31 B1 11 91 39 B9 19 99 33 B3 13 93 3B BB 1B 9B
F1 71 D1 51 F9 79 D9 59 F3 73 D3 53 FB 7B DB 5B
0D 8D 2D AD 05 85 25 A5 0F 8F 2F AF 07 87 27 A7
CD 4D ED 6D C5 45 E5 65 CF 4F EF 6F C7 47 E7 67
3D BD 1D 9D 35 B5 15 95 3F BF 1F 9F 37 B7 17 97
FD 7D DD 5D F5 75 D5 55 FF 7F DF 5F F7 77 D7 57
02 82 22 A2 0A 8A 2A AA 00 80 20 A0 08 88 28 A8
C2 42 E2 62 CA 4A EA 6A C0 40 E0 60 C8 48 E8 68
32 B2 12 92 3A BA 1A 9A 30 B0 10 90 38 B8 18 98
F2 72 D2 52 FA 7A DA 5A F0 70 D0 50 F8 78 D8 58
> exch get 256 div } bind setscreen
initgraphics
% The interpreter relies on there being at least 2 entries
% on the graphics stack. Establish the second one now.
gsave
VMDEBUG
% Define control-D as a no-op. This is a hack to get around problems
% in some common P*stScr*pt-generating applications.
(\004) cvn { } def
% Turn off array packing for interactive use.
false setpacking
QUIET not { (done.\n) print flush } if
% Set no pause on copypage and showpage
/NOPAUSE true def
% The interpreter will run the initial procedure (start).

View File

@ -0,0 +1,140 @@
% Copyright (C) 1991 Aladdin Enterprises. All rights reserved.
% Distributed by Free Software Foundation, Inc.
%
% This file is part of Ghostscript.
%
% Ghostscript is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
% to anyone for the consequences of using it or for whether it serves any
% particular purpose or works at all, unless he says so in writing. Refer
% to the Ghostscript General Public License for full details.
%
% Everyone is granted permission to copy, modify and redistribute
% Ghostscript, but only under the conditions described in the Ghostscript
% General Public License. A copy of this license is supposed to have been
% given to you along with Ghostscript so you can know your rights and
% responsibilities. It should be in a file named COPYING. Among other
% things, the copyright notice and this notice must be preserved on all
% copies.
%
% ***********************************************************************
% * *
% * M M OOO DDDD III FFFFF III EEEEE DDDD *
% * MM MM O O D D I F I E D D *
% * M M M O O D D I F I E D D *
% * M M O O D D I FFF I EEE D D *
% * M M O O D D I F I E D D *
% * M M O O D D I F I E D D *
% * M M OOO DDDD III F III EEEEE DDDD *
% * *
% * *
% * FFFFF III L EEEEE *
% * F I L E *
% * F I L E *
% * FFF I L EEE *
% * F I L E *
% * F I L E *
% * F III LLLLL EEEEE *
% * *
% ***********************************************************************
%
% .-------------.
% | /\ |
% | / \ |
% | / /\ \ |
% | / / \ \ |
% | / / /\ \ \ |
% | / / / \ \ \|
% `-------------' (R)
% Autodesk, Inc.
% Tools For the Golden Age of Engineering
%
% In keeping with subparagraph 2a of the Gnu General Public License
% (Version 1, February 1989):
%
% 2. You may modify your copy or copies of the Program or any
% portion of it, and copy and distribute such modifications under
% the terms of Paragraph 1 above, provided that you also do the
% following:
%
% a) cause the modified files to carry prominent notices stating
% that you changed the files and the date of any change; and...
%
% the following is a summary of the changes to this file made by
% Autodesk, Inc. in August 1991 in order to adapt Ghostscript to run
% as an ADS application and thereby to perform rendering of
% PostScript files within AutoCAD.
%
% ACADPSS.PS Ghostscript symbol font encoding vector. Called
% SYMBOL_E.PS in standard Ghostscript.
%
% ************************************************************************
% Define the Symbol encoding vector.
/SymbolEncoding
% \000
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
% \040
/space /exclam /universal /numbersign
/existential /percent /ampersand /suchthat
/parenleft /parenright /asteriskmath /plus
/comma /minus /period /slash
/zero /one /two /three
/four /five /six /seven
/eight /nine /colon /semicolon
/less /equal /greater /question
% \100
/congruent /Alpha /Beta /Chi
/Delta /Epsilon /Phi /Gamma
/Eta /Iota /theta1 /Kappa
/Lambda /Mu /Nu /Omicron
/Pi /Theta /Rho /Sigma
/Tau /Upsilon /sigma1 /Omega
/Xi /Psi /Zeta /bracketleft
/therefore /bracketright /perpendicular /underscore
% \140
/radicalex /alpha /beta /chi
/delta /epsilon /phi /gamma
/eta /iota /phi1 /kappa
/lambda /mu /nu /omicron
/pi /theta /rho /sigma
/tau /upsilon /omega1 /omega
/xi /psi /zeta /braceleft
/bar /braceright /similar /.notdef
% \200
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
% \240
/.notdef /Upsilon1 /minute /lessequal
/fraction /infinity /florin /club
/diamond /heart /spade /arrowboth
/arrowleft /arrowup /arrowright /arrowdown
/degree /plusminus /second /greaterequal
/multiply /proportional /partialdiff /bullet
/divide /notequal /equivalence /approxequal
/ellipsis /arrowvertex /arrowhorizex /carriagereturn
% \300
/aleph /Ifraktur /Rfraktur /weierstrass
/circlemultiply /circleplus /emptyset /intersection
/union /propersuperset /reflexsuperset /notsubset
/propersubset /reflexsubset /element /notelement
/angle /gradient /registerserif /copyrightserif
/trademarkserif /product /radical /dotmath
/logicalnot /logicaland /logicalor /arrowdblboth
/arrowdblleft /arrowdblup /arrowdblright /arrowdbldown
% \340
/lozenge /angleleft /registersans /copyrightsans
/trademarksans /summation /parenlefttp /parenleftex
/parenleftbt /bracketlefttp /bracketleftex /bracketleftbt
/bracelefttp /braceleftmid /braceleftbt /braceex
/.notdef /angleright /integral /integraltp
/integralex /integralbt /parenrighttp /parenrightex
/parenrightbt /bracketrighttp /bracketrightex /bracketrightbt
/bracerighttp /bracerightmid /bracerightbt /.notdef
256 packedarray def

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,276 @@
<?xml version="1.0" encoding="utf-8"?>
<FontConfig>
<Languages> <!-- specify the default fonts for each language -->
<LangInfo>
<Language>English</Language>
<DefaultRscFont>Standard</DefaultRscFont>
<DefaultTTFont>Arial</DefaultTTFont>
<DefaultShxFont>simplex,msdefault</DefaultShxFont>
<DefaultShxBigFont>bigfont,kanjibig</DefaultShxBigFont>
</LangInfo>
<LangInfo>
<Language>Japanese</Language>
<DefaultRscFont>Kanji</DefaultRscFont>
<DefaultTTFont>MS Gothic</DefaultTTFont>
<DefaultShxFont>kanji</DefaultShxFont>
<DefaultShxBigFont>bigfont,kanjibig</DefaultShxBigFont>
<CustomFontCreation>True</CustomFontCreation>
</LangInfo>
<LangInfo>
<Language>SimpChinese</Language>
<DefaultRscFont>Standard</DefaultRscFont>
<DefaultTTFont>SimSun</DefaultTTFont>
<DefaultShxFont>simplex,msdefault</DefaultShxFont>
<DefaultShxBigFont>gbcbig</DefaultShxBigFont>
<CustomFontCreation>True</CustomFontCreation>
</LangInfo>
<LangInfo>
<Language>TradChinese</Language> <!-- also used for HongKongChinese -->
<DefaultRscFont>chinese_traditional</DefaultRscFont>
<DefaultTTFont>MingLiU</DefaultTTFont>
<DefaultShxFont>tradch</DefaultShxFont>
<DefaultShxBigFont>chineset</DefaultShxBigFont>
<CustomFontCreation>True</CustomFontCreation>
</LangInfo>
<LangInfo>
<Language>Korean</Language>
<DefaultRscFont>Gothic_single</DefaultRscFont>
<DefaultTTFont>GulimChe</DefaultTTFont>
<DefaultShxFont>kor</DefaultShxFont>
<DefaultShxBigFont>whgtxt,korbig</DefaultShxBigFont>
<CustomFontCreation>True</CustomFontCreation>
</LangInfo>
<LangInfo>
<Language>Arabic</Language>
<DefaultRscFont>Standard</DefaultRscFont>
<DefaultTTFont>Arial</DefaultTTFont>
<DefaultShxFont>simplex,msdefault</DefaultShxFont>
<DefaultShxBigFont>bigfont,kanjibig</DefaultShxBigFont>
<TTFontLayout>2</TTFontLayout>
</LangInfo>
<LangInfo>
<Language>Hebrew</Language>
<DefaultRscFont>Standard</DefaultRscFont>
<DefaultTTFont>Arial</DefaultTTFont>
<DefaultShxFont>simplex,msdefault</DefaultShxFont>
<DefaultShxBigFont>bigfont,kanjibig</DefaultShxBigFont>
<TTFontLayout>1</TTFontLayout>
</LangInfo>
<LangInfo>
<Language>Thai</Language>
<DefaultRscFont>Standard</DefaultRscFont>
<DefaultTTFont>Arial</DefaultTTFont>
<DefaultShxFont>simplex,msdefault</DefaultShxFont>
<DefaultShxBigFont>bigfont,kanjibig</DefaultShxBigFont>
<TTFontLayout>3</TTFontLayout>
</LangInfo>
<LangInfo>
<Language>Vietnamese</Language>
<DefaultRscFont>Standard</DefaultRscFont>
<DefaultTTFont>Arial</DefaultTTFont>
<DefaultShxFont>simplex,msdefault</DefaultShxFont>
<DefaultShxBigFont>bigfont,kanjibig</DefaultShxBigFont>
</LangInfo>
</Languages>
<Fonts>
<!-- put RSC fonts here -->
<RscFontInfo>
<Name>architectural,block_outline,char_fast_font,compressed,engineering,fancy,iso_fontleft,iso_fontright,
italics,low_res_filled,standard,uppercase,working</Name>
<Hidden>False</Hidden>
<CodePage>1252</CodePage>
<DiameterChar>201</DiameterChar>
<PlusMinusChar>200</PlusMinusChar>
<DegreeChar>94</DegreeChar>
<CreateShxUnifont>True</CreateShxUnifont>
<CreateEditorTempFont>True</CreateEditorTempFont>
</RscFontInfo>
<RscFontInfo>
<Name>intl_engineering,intl_iso</Name>
<Hidden>False</Hidden>
<CodePage>1252</CodePage>
<DegreeChar>176</DegreeChar>
<DiameterChar>248</DiameterChar>
<PlusMinusChar>177</PlusMinusChar>
<CreateShxUnifont>True</CreateShxUnifont>
<CreateEditorTempFont>True</CreateEditorTempFont>
</RscFontInfo>
<RscFontInfo>
<Name>intl_working</Name>
<Hidden>False</Hidden>
<CodePage>1252</CodePage>
<DegreeChar>94</DegreeChar>
<DiameterChar>248</DiameterChar>
<PlusMinusChar>240</PlusMinusChar>
<CreateShxUnifont>True</CreateShxUnifont>
<CreateEditorTempFont>True</CreateEditorTempFont>
</RscFontInfo>
<RscFontInfo>
<Name>ansi_symbols,feature_control_symbols</Name>
<Hidden>False</Hidden>
<CodePage>1252</CodePage>
<DegreeChar>94</DegreeChar>
<DiameterChar>110</DiameterChar>
<PlusMinusChar>126</PlusMinusChar>
<CreateShxUnifont>False</CreateShxUnifont>
<CreateEditorTempFont>True</CreateEditorTempFont>
</RscFontInfo>
<RscFontInfo>
<Name>font_iso,gen_eng</Name>
<Hidden>False</Hidden>
<CodePage>1252</CodePage>
<DegreeChar>94</DegreeChar>
<DiameterChar>126</DiameterChar>
<PlusMinusChar>200</PlusMinusChar>
<CreateShxUnifont>True</CreateShxUnifont>
<CreateEditorTempFont>True</CreateEditorTempFont>
</RscFontInfo>
<RscFontInfo>
<Name>iges1001</Name>
<Hidden>False</Hidden>
<CodePage>1252</CodePage>
<DegreeChar>94</DegreeChar>
<DiameterChar>110</DiameterChar>
<PlusMinusChar>200</PlusMinusChar>
<CreateShxUnifont>True</CreateShxUnifont>
<CreateEditorTempFont>True</CreateEditorTempFont>
</RscFontInfo>
<RscFontInfo>
<Name>iges1002</Name>
<Hidden>False</Hidden>
<CodePage>1252</CodePage>
<DegreeChar>94</DegreeChar>
<DiameterChar>201</DiameterChar>
<PlusMinusChar>35</PlusMinusChar>
<CreateShxUnifont>True</CreateShxUnifont>
<CreateEditorTempFont>True</CreateEditorTempFont>
</RscFontInfo>
<RscFontInfo>
<Name>iges1003</Name>
<Hidden>False</Hidden>
<CodePage>1252</CodePage>
<DegreeChar>94</DegreeChar>
<DiameterChar>201</DiameterChar>
<PlusMinusChar>35</PlusMinusChar>
<CreateShxUnifont>True</CreateShxUnifont>
<CreateEditorTempFont>True</CreateEditorTempFont>
</RscFontInfo>
<RscFontInfo>
<Name>cs_char_fast_font,cs_font_iso,cs_font_eng</Name>
<Hidden>False</Hidden>
<CodePage>1250</CodePage>
</RscFontInfo>
<RscFontInfo>
<Name>kanji</Name>
<Hidden>False</Hidden>
<CodePage>932</CodePage>
<DiameterChar>934</DiameterChar>
<DegreeChar>33163</DegreeChar>
<PlusMinusChar>33149</PlusMinusChar>
<CreateShxUnifont>True</CreateShxUnifont>
<CreateEditorTempFont>False</CreateEditorTempFont>
</RscFontInfo>
<RscFontInfo>
<Name>myongjo_outline,myongjo_fill,gothic_outline,gothic_fill,myongjo_single,gothic_single</Name>
<Hidden>False</Hidden>
<CodePage>949</CodePage>
<CreateShxUnifont>True</CreateShxUnifont>
<CreateEditorTempFont>False</CreateEditorTempFont>
</RscFontInfo>
<RscFontInfo>
<Name>chinese_traditional</Name>
<Hidden>False</Hidden>
<CodePage>950</CodePage>
<CreateShxUnifont>True</CreateShxUnifont>
<CreateEditorTempFont>False</CreateEditorTempFont>
</RscFontInfo>
<RscFontInfo>
<Name>atisb,atisn</Name>
<Hidden>False</Hidden>
<CodePage>1256</CodePage>
<CreateShxUnifont>True</CreateShxUnifont>
<CreateEditorTempFont>True</CreateEditorTempFont>
</RscFontInfo>
<RscFontInfo>
<Name>*</Name> <!-- for RSC fonts not listed above -->
<Hidden>False</Hidden>
<DegreeChar>94</DegreeChar>
<DiameterChar>216</DiameterChar>
<PlusMinusChar>200</PlusMinusChar>
<CreateShxUnifont>True</CreateShxUnifont>
<CreateEditorTempFont>True</CreateEditorTempFont>
</RscFontInfo>
<!-- put SHX fonts here -->
<ShxFontInfo> <!-- Japanese SHX fonts -->
<Name>kanji,kanjibig,bigfont,extfont,extfont2,@extfont2,spec_bar,spec_sl,special</Name>
<CodePage>932</CodePage>
<Hidden>False</Hidden>
</ShxFontInfo>
<ShxFontInfo> <!-- Simplified Chinese SHX fonts -->
<Name>gbcbig,tssdchn,hzjd,hztxt</Name>
<CodePage>936</CodePage>
<Hidden>False</Hidden>
</ShxFontInfo>
<ShxFontInfo> <!-- Traditional Chinese SHX fonts -->
<Name>tradch,chineset,tradchbig,chinese_traditionalbig</Name>
<CodePage>950</CodePage>
<Hidden>False</Hidden>
</ShxFontInfo>
<ShxFontInfo> <!-- Korean SHX fonts -->
<Name>whgdtxt,whgtxt,whtgtxt,whtmtxt,kor,korbig,myongjo_outlinebig,myongjo_fillbig,gothic_outlinebig,gothic_fillbig,myongjo_singlebig,gothic_singlebig</Name>
<CodePage>949</CodePage>
<Hidden>False</Hidden>
</ShxFontInfo>
<ShxFontInfo> <!-- Cyrillic SHX fonts -->
<Name>russ</Name>
<CodePage>1251</CodePage>
<Hidden>False</Hidden>
</ShxFontInfo>
<ShxFontInfo> <!-- for SHX fonts not listed above -->
<Name>*</Name>
<Hidden>False</Hidden>
<CreateEditorTempFont>True</CreateEditorTempFont>
</ShxFontInfo>
<!-- this section allows hiding (removing from user interface) TrueType fonts -->
<TTFontInfo>
<Name>*</Name>
<Hidden>False</Hidden> <!-- set this to True to hide all TrueType Fonts -->
</TTFontInfo>
</Fonts>
<HideDuplicateNames>True</HideDuplicateNames> <!-- Hide fonts with the same name as another font of a different type. Set to False to
show all fonts, even if another font with the same name but a different type exists. -->
</FontConfig>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More