gpt4 book ai didi

c# - 使用 SolidWorks API 打开 .dwg

转载 作者:太空狗 更新时间:2023-10-30 00:49:12 25 4
gpt4 key购买 nike

我正在尝试在 SolidWorks 2015 中打开一个 .dwg 文件。我已经成功地通过使用打开了一个 .slddrw

IModelDoc2 doc = swApp.OpenDoc6("C:/Temp/BlankDraw.SLDDRW", (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", 0, 0);

当我用 .dwg 替换 .slddrw 部分时,问题就变成了,它返回 null。

是否有其他方法需要研究以打开 .dwg?

最佳答案

SOLIDWORKS API 建议使用方法 ISldWorks::LoadFile4加载非本地文件。

这就是 API 文档所说的使用 LoadFile4 启动 dwg 文件的内容。

DXF/DWG files:

You can:

Let SOLIDWORKS determine the default values:

Paper size and sheet scale are computed to fit the input data.

Length unit is determined from the header of the input DXF/DWG file.

Sheet name is the same as the layout name in the input DXF/DWG file.

  • or -

Set your own values by using:

ISldWorks::GetImportFileData to obtain the IImportDxfDwgDatainterface.

Use the following methods with a Sheet argument of "" (an emptystring) to set up your defaults before loading the file:

IImportDxfDwgData::GetPaperSize

IImportDxfDwgData::GetPosition

IImportDxfDwgData::GetSheetScale

IImportDxfDwgData::ImportMethod

IImportDxfDwgData::LengthUnit

IImportDxfDwgData::SetPaperSize

IImportDxfDwgData::SetPosition

IImportDxfDwgData::SetSheetScale

IImportDxfDwgData::SheetName

See IImportDxfDwgData for details about importing DXF/DWG data.

NOTES:

Getting the IImportDxfDwgData interface does not get default valuesfrom the input file. Any values not set by you are set to the valuescomputed by SOLIDWORKS.

If the DWG/DXF file has multiple sheets, use these methods with avalid layout name in the Sheet argument to set up sheet specificsettings, which overrides the default settings. If any of theindividual items are not specified for a given layout name, the valueused is from the defaults (layout name ""). If the default value isnot specified, SOLIDWORKS computes and uses a meaningful value forthat item.

关于c# - 使用 SolidWorks API 打开 .dwg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39757719/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com