当前位置: 首页 > news >正文

3D CAD SDK 安装

Aspose.CAD for Python via .NET专门用于处理 CAD 图纸。它的安装过程非常简单。只需联系慧都科技下载SDK 文件或在 CMD 中运行以下命令:

pip install aspose-cad

使用 Python 将 SVG 转换为 PNG - 代码示例

除了转换功能外,这款强大的 SDK 还允许您选择特定图层并跟踪转换过程。现在,让我们开始查看代码步骤和代码示例。

步骤:

  • 通过调用load方法从给定的输入路径加载 SVG 文件。
  • 配置光栅化选项以将矢量转换为光栅。
  • 设置输出图像的宽度、高度和缩放级别。
  • 创建PngOptions类的对象。
  • 使用配置的光栅化将加载的 CAD 图像保存为 PNG。

使用下面给出的代码片段在 Python 中将 SVG 更改为 PNG:

import aspose.cad as cad from aspose.cad.imageoptions import PngOptions # A class to handle CAD image conversion using Aspose.CAD for Python via .NET class CadImageConverter: def __init__(self, input_path, output_path, license_path): # Store input, output, and license file paths self.input_path = input_path self.output_path = output_path self.license_path = license_path self.image = None self.raster_options = None def apply_license(self): # Apply the Aspose.CAD license to unlock full functionality print("Applying Aspose.CAD license...") license_obj = cad.License() license_obj.set_license(self.license_path) print("License applied successfully.") def load_cad_image(self): # Load a CAD (or SVG) file from the given input path print(f"Loading CAD image froms: {self.input_path}") self.image = cad.Image.load(self.input_path) print("Image loaded successfully.") def configure_rasterization(self, width=800.5, height=800.5, zoom=0.5, layers="Layer"): # Configure rasterization options for converting vector to raster print("Configuring rasterization options...") self.raster_options = cad.imageoptions.CadRasterizationOptions() # Set output image width self.raster_options.page_width = width # Set output image height self.raster_options.page_height = height # Define zoom level self.raster_options.zoom = zoom # Specify which layers to render self.raster_options.layers = layers print("Rasterization configured.") def save_as_png(self): # Save the loaded CAD image as a PNG using the configured rasterization print(f"Saving image as PNG to: {self.output_path}") png_options = PngOptions() png_options.vector_rasterization_options = self.raster_options self.image.save(self.output_path, png_options) print("Image saved as PNG successfully.") def main(): input_svg = "sample1.svg" output_png = "result-file.png" license_file = "license.lic" # Initialize converter with file paths converter = CadImageConverter(input_svg, output_png, license_file) # Apply license, load the image, configure rasterization, and save as PNG converter.apply_license() converter.load_cad_image() converter.configure_rasterization() converter.save_as_png() # Run the script if executed directly. if __name__ == "__main__": main()

输出:

http://www.jsqmd.com/news/1099519/

相关文章:

  • Spring AI + RAG
  • 大模型服务弹性伸缩:从 GPU 利用率到 K8s HPA 的全链路实战
  • 告别Keil律师函!手把手教你用VSCode+GNU Arm+STM32CubeMX搭建免费单片机开发环境(Windows版)
  • 从零到一:基于Dify的AI应用开发全流程实践指南
  • 气泡特效的核心在于BubbleEffect类,它继承自Manim的Animation类,通过重写关键方法来实现气泡的上升、变大和透明度变化效果。
  • 操作系统缓存机制深度解析:从页缓存到内存映射,超越Redis的性能优化之道
  • 深智微:华润微官方授权代理商,如何让型号、库存交期与项目交付协同推进
  • 新用户福利,千问新用户福利怎么领,领取8元优惠券,附最新口令
  • Redis缓存:Python操作Redis实战
  • 行测申论试卷|公务员申论刷题|数量关系备考
  • 2026年人工智能发展的新风口:从“数字智能”到“物理智能”的范式革命
  • Qt——文本绘制技巧
  • 学习一门语言——Python(自学版)
  • 你的输出第一行肯定和我不一样,且每次运行的输出肯定不一样。
  • 乳牙蛀了不用管?避开护牙误区,科学守护孩子恒牙健康
  • info = {“k1“:1,“k2“:“222“,“k3“:“guohan“} 可变类型不可以做字典的键(列表,字典,集合) 因此键可以是整数什么的如 info = {1:2}公
  • 闪迪 x300 2.5-sata
  • 通用二进制协议分析:基于AST的Protobuf动态解析与容错设计
  • — 一款针对 IT 团队开发的文档管理系统,基于 Golang 开发,内置项目管理,用户管理,权限管理等功能,可以用来储存日常接口文档,数据库字典,手册说明等文档。功能特色:
  • 零基础使用VMware虚拟机安装CentOS Linux超详细教程
  • 硬件学习第三天(阅读芯片手册)
  • c语言项目驱动学习--实例化(图书管理)--005-代码对比
  • 基于51单片机RFID车位车库管理系统/RC522读卡/车库收费系统2(设计源文件+万字报告+讲解)(支持资料、图片参考_降重降ai)
  • [智能体-612]:AGENTS.md 完整详解(OpenClaw 体系,对应 workspace 里的工作规范文件)
  • 技术速递|通过全新开放数据集,加速研究人员和开发者构建多语言 AI
  • 中餐厅摆台 点击UI图片拖拽预制体到桌面并 实现预制体拖拽
  • 家庭精细化洗护怎么选?海信全家筒·棉花糖 U7S 四筒洗衣机深度体验
  • MHmarkets:把产品理解成本做扎实,更谨慎的使用者更容易感受到的清单
  • 基于STM32单片机甲醛温湿度烟雾火灾报警 空气质量检测PM2系统2(设计源文件+万字报告+讲解)(支持资料、图片参考_降重降ai)
  • 全国大学真实生活环境一键查询工具(在线免费)