文件另存为——Autocad.doc.SaveAs

 

一、前言

  使用pyautocad编辑好cad图纸后,往往涉及到一个保存的问题,但是官方文档并未提及,所以只能自己来了,测试了好久,终于是找到了保存的命令和参数说明。

二、方法介绍 

  • Autocad.doc.SaveAs()

    autocad文档如下:

      

Signatures

object.SaveAs FileName, FileType [, SecurityParams]

Object

DocumentMenuGroup
The object or objects this method applies to.

Note This method has no effect for menu groups.

FileName

String; input-only
The full path and file name, or valid URL address, for the file. The active document takes on the new name.

FileType

AcSaveAsType enum; input-only; optional for Document objects

acR14_dwg

AutoCAD R14 DWG (*.dwg)

ac2000_dwg

AutoCAD 2000 DWG (*.dwg)

ac2000_dxf

AutoCAD 2000 DXF (*.dxf)

ac2000_Template

AutoCAD 2000 Drawing Template File (*.dwt)

ac2004_dwg

AutoCAD 2004 DWG (*.dwg)

ac2004_dxf

AutoCAD 2004 DXF (*.dxf)

ac2004_Template

AutoCAD 2004 Drawing Template File (*.dwt)

ac2007_dwg

AutoCAD 2007 DWG (*.dwg)

ac2007_dxf

AutoCAD 2007 DXF (*.dxf)

ac2007_Template

AutoCAD 2007 Drawing Template File (*.dwt)

acNative

A synonym for the latest drawing release. In this release, this value equals ac2007_dwg.

SecurityParams

SecurityParams object; variant; optional for Document objects
Security settings for an encrypted drawing.

Remarks

The default file type for documents is ac2007_dwg. The value acR14_dxf is obsolete.

Documents can be saved only as files with the extensions indicated above. To save a document in a different file type, use the Export method.

When saving to a secure URL, a dialog box prompts the user for the necessary password information. Message boxes appear if the user has not suppressed this activity in the browser.

Menu groups cannot be saved in AutoCAD 2006 and later releases. This method will be removed from the MenuGroup object in a future release.

   

  简单来说,该方法涉及三个参数:

  •  FileName 

          文件名,要求string类型,如要保存到指定位置,加上完整路径

  •  Filetype

          文件类型,枚举类型,但是python好像设置不了,默认2007.dwg

  •  SecurityParams  

     安全设置,暂时用不到,留空

二、方法实例

  

1
2
3
4
5
6
7
8
9
10
11
12
from pyautocad import Autocad,APoint
 
 
acad = Autocad(create_if_not_exists=True)
acad.prompt("hello,test saveas")
d1 = APoint(0,0,)
 
 
#默认保存为2007dwg
acad.doc.SaveAs('d:/22/test_SaveAs')
#保存为dwf
acad.doc.SaveAs('d:/22/test_SaveAs',1)

  

枚举类型测试:

1
2
3
4
5
6
for in range(100):
    try:
        acad.doc.SaveAs('d:/22/file-%s'%i,i)
        time.sleep(1)
    except:
        continue

  

    

CAD的更多相关文章

  1. CAD打印线条太粗、线条颜色设置

    不管你是使用打印机,还是将CAD转换为PDF文件,如果出现以下情况,线条太粗,根本看不清楚,怎么解决呢? 或者,不想通过图层复杂.繁琐的设置,想将各种颜色线条的CAD全部打印成黑白,或者指定某一种颜色 ...

  2. CAD调试时抛出“正试图在 os 加载程序锁内执行托管代码。不要尝试在 DllMain 或映像初始化函数内运行托管代码”异常的解决方法

    这些天重装了电脑Win10系统,安装了CAD2012和VS2012,准备进行软件开发.在调试程序的时候,CAD没有进入界面就抛出 “正试图在 os 加载程序锁内执行托管代码.不要尝试在 DllMain ...

  3. AnyCAD.NET C#开发CAD软件实践(一)

    免费的AnyCAD.NET发布了!俺喜欢的C#有了大展前途的机会了. 打算用这个框架搭建一套实用的CAD系统,目标是能买出去10套以上. 先看看AnyCAD.NET的自我介绍. http://www. ...

  4. 高精度快速预览打开dwg文件的CAD控件CAD Image DLL介绍及下载

    CAD Image DLL对于DXF格式, DWG格式(AutoCAD R12 到AutoCAD 2004/2005), PLT 以及 HPGL/HPGL2文件都有快速的显示速度和精度,开发者再也不会 ...

  5. 基于.NET的CAD二次开发学习笔记二:AutoCAD .NET中的对象

    1.CAD对象:一个CAD文件(DWG文件)即对应一个数据库,数据库中的所有组成部分,看的见(包括点.多段线.文字.圆等)和看不见(图层.线型.颜色等)的都是对象,数据库本身也是一个对象. 直线.圆弧 ...

  6. 基于.NET的CAD二次开发学习笔记一:CAD开发入门

    1.AutoCAD .NET API由不同的DLL文件组成,它们提供用于访问图形文件或AutoCAD应用程序的包含丰富的类.结构.方法和事件.每一个DLL文件都定义不同的使用基于功能的库组织组件的命名 ...

  7. CAD厂商的一丢丢笔记

    Cadence Cadence是个公司名,产品有: OrCAD,画原理图的 Allegro,画PCB的,PrintedCircuitBoard. Mentor,暂时还不知道画什么的 Autodesk ...

  8. 采集的GPS数据如何正确显示在arcgis和cad中

    利用GPS定位卫星,在全球范围内实时进行定位.导航的系统,称为全球卫星定位系统,简称GPS.GPS是由美国国防部研制建立的一种具有全方位.全天候.全时段.高精度的卫星导航系统,能为全球用户提供低成本. ...

  9. Cad 二次开发关于SelectCrossingPolygon和SelectFence返回结果Status为error的小测试

    CAD2008的二次开发,有个很奇怪的现象,只要你选择的点集不在当前视图上SelectCrossingPolygon和SelectFence返回结果Status就会为error,所以要获取正确的结果, ...

  10. CAD二次开发---导入外部文件中的块并输出预览图形(五)

    思路: 1)首先要定义一个数据库对象来表示包含块的文件,改数据库对象会被加载到内存中,但不会被显示在CAD窗口中. 2)调用Database类的ReadDwgFile函数将外部文件DWG文件读入到新创 ...

随机推荐

  1. 重启监听卡在connecting to的问题

    问题描述:lsnrctl start启动监听起不来,一直卡在connecting to半天 1.[oracle@orcl ~]$ lsnrctl start 一直卡半天,就是连不上,按照以前的解决办法 ...

  2. LeetCode 965. 单值二叉树 (遍历二叉树)

    题目链接:https://leetcode-cn.com/problems/univalued-binary-tree/ 如果二叉树每个节点都具有相同的值,那么该二叉树就是单值二叉树. 只有给定的树是 ...

  3. [ERR] Node goodsleep.vip:6379 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.

    解决方案 以前的cluster节点信息 保留 要删除 dump.rdb node.conf集群启动时自动生成文件

  4. Netty中CompositeByteBuf的理解以及读写操作

    转载请注明出处 https://www.cnblogs.com/majianming/articles/the_composite_byte_buf_read_and_wite_operation_o ...

  5. Mysql快速入门(三)

    MySQL性能优化之查看执行计划explain 介绍: (1).MySQL 提供了一个 EXPLAIN 命令, 它可以对 SELECT 语句进行分析, 并输出 SELECT 执行的详细信息, 以供开发 ...

  6. Hadoop学习之路(4)Intelij+Maven搭建Hadoop项目

    1创建工程 点击project--Maven--next 2通过maven导入项目依赖jar包 (1)设置maven自动导入依赖jar包 勾选 Import Maven projects automa ...

  7. 关于spring整合前两大框架的一些小问题04

    关于spring中对延迟关闭session的配置,以及工具类BaseDao和BaseAction 一.HibernateTemplate执行查询时的一些小问题 1.当两个PO类的关系是多对一时: 我们 ...

  8. PP: Shallow RNNs: a method for accurate time-series classification on tiny devices

    Problem: time series classification shallow RNNs: the first layer splits the input sequence and runs ...

  9. 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。”

    出现场景: From1中事件B绑定在事件A,事件A由工厂模式下的设备产生,当离开Form1时,设备中的事件A仍然会触发事件B,此时就会导致如上问题 原因(个人理解): 1.Form1已经被销毁了,但仍 ...

  10. Javascript数组与字符串常用api

    目录 javaScript(api学习) 数组有关的api 创建数组 数组的增删改查 indexOf(); push(),pop(),unshift(),shift() forEach() map() ...