zoukankan      html  css  js  c++  java
  • CAD

    文件另存为——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

      

        

  • 相关阅读:
    函数 free 的原型
    malloc 返回值的类型是 void *
    malloc 函数本身并不识别要申请的内存是什么类型
    用 free 或 delete 释放了内存之后,立即将指针设置为 NULL,防止产 生“野指针”
    动态内存的申请与释放必须配对,防止内存泄漏
    避免数组或指针的下标越界,特别要当心发生“多 1”或者“少 1” 操作
    不要忘记为数组和动态内存赋初值
    用 malloc 或 new 申请内存之后,应该立即检查指针值是否为 NULL
    释放了内存却继续使用它
    忘记了释放内存,造成内存泄露
  • 原文地址:https://www.cnblogs.com/chargeworld/p/11908128.html
Copyright © 2011-2022 走看看