C# SolidWorks 二次开发 API —工程图尺寸信息的读取

工程图尺寸信息的读取

前提条件: 在打开的工程图选中一个尺寸
本文目标: 通过转换选择的尺寸为一个尺寸对象,获取该尺寸的值与公差。


 private void btnGetDimensionInfo_Click(object sender, EventArgs e)
        {
            ISldWorks swApp = Utility.ConnectToSolidWorks();
            swApp.CommandInProgress = true;

            ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc;

            SelectionMgr selectionMgr = (SelectionMgr)swModel.SelectionManager;

            //转换成尺寸显示对象
            var swDisplayDimension = (DisplayDimension)selectionMgr.GetSelectedObject6(1, 0);

            DisplayData displayData = (DisplayData)swDisplayDimension.GetDisplayData();

            //获取尺寸上的文字
            var anno = (Annotation)swDisplayDimension.GetAnnotation();

            //获取所在视图 ---如果是图纸,这里会报错。需要用OwnerType来判断
            var thisView = (View)anno.Owner;//

            var textwidth = displayData.GetTextInBoxWidthAtIndex(0);

            var textHeight = displayData.GetTextHeightAtIndex(0);

            // dat.GetLineCount 几条线
            var lineCount = displayData.GetLineCount();
            var lineAngle = displayData.GetTextAngleAtIndex(0);
            var linePoints = (double[])displayData.GetLineAtIndex(0);
            var linePoints2 = (double[])displayData.GetLineAtIndex(1);
            var textPoint = (double[])displayData.GetTextPositionAtIndex(0);

            var thisDimAng = lineAngle * 180 / Math.PI;

            //尺寸对象
            var swDimension = (Dimension)swDisplayDimension.GetDimension();

            //获取尺寸的公差
            var cruToleranceType = swDimension.GetToleranceType();
            var cruTolerance = swDimension.Tolerance;

            if (cruToleranceType == (int)swTolType_e.swTolBILAT)
            {
                cruTolerance.GetMaxValue2(out double ToleranceValueMax); //上公差

                cruTolerance.GetMinValue2(out double ToleranceValueMin);//下公差
            }

            var TextAll = swDisplayDimension.GetText((int)swDimensionTextParts_e.swDimensionTextAll);
            var TextPrefix = swDisplayDimension.GetText((int)swDimensionTextParts_e.swDimensionTextPrefix);
            var TextSuffix = swDisplayDimension.GetText((int)swDimensionTextParts_e.swDimensionTextSuffix);
            var CalloutAbove = swDisplayDimension.GetText((int)swDimensionTextParts_e.swDimensionTextCalloutAbove);
            var CalloutBelow = swDisplayDimension.GetText((int)swDimensionTextParts_e.swDimensionTextCalloutBelow);

            var relValue = Math.Round(swDimension.GetSystemValue2("") * 1000, 3).ToString();

            MessageBox.Show(relValue);
        }

上面是代码,有一些备注。

这是初学markdown写的, 源代码继续在码云或者github上拿。

C# SolidWorks 二次开发 API —dll插件如何让 winform 类似ShowDialog,但还能操作solidworks

这篇文章记录一下,这次看api帮助解决到的一个问题:

          由于之前我都是先做好的exe独立开发,后来改成插件形式后遇到的问题。以前经常利用窗体的ShowDialog特性,让程序暂停,让用户进行对象的自定义选择操作,但是到了dll中出现了问题,因为dll和solidworks主进程是一个,所以当用了页面的ShowDialog之后,solidworks就再也无法操作了。这个问题之前花了一天多时间都没搞定,想了好多办法,最后利用的doevents解决的,但是效果不是特别好。

         原来solidworks的帮助文件中已经有了解决方案: 只需要使用 Application.Run(winform)就可以了,我刚才进行了测试,很好用,至于还有没有别的问题,后面再测试一下。

        

         参考链接:

http://help.solidworks.com/2018/English/api/sldworksapiprogguide/overview/Keystrokes_and_Accelerator_Keys_and_ActiveX_Modeless_Dialogs_and_PropertyManager_Pages.htm

C# SolidWorks 二次开发 API —只开工程图的情况下直接转出3D和2D

##昨天晚上有网友咨询了一个问题,问如何只打开工程图的情况下导出step与pdf.

之前我写的博客中存3D格式是在打开的情况下做的,之前我的一篇文章中有写过怎么在工程图中获取零件对象,所以我们只需要在那上面改一改就可以了。直接调用ModelDoc2.Extension.SaveAs方法就可以存成想要的格式,而不产生单独打开窗口的动作了。

代码如下:

           //连接到Solidworks
            ISldWorks swApp = Utility.ConnectToSolidWorks();

            ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc;

            // DrawingDoc dc = (DrawingDoc)swModel;

            SelectionMgr selectionMgr = (SelectionMgr)swModel.SelectionManager;

            //获取选择的视图对象
            View view = (View)selectionMgr.GetSelectedObject5(1);

            //获取视图中的引用模型
            var viewModel = view.ReferencedDocument;

            //其它读取属性请参考博文 读取零件属性 ->BtnGetPartData_Click

            MessageBox.Show(viewModel.GetPathName());

            //下面是导出,如果不需要请注释掉以下代码。
            int error = 0;
            int warnings = 0;

            var stepName = System.IO.Path.GetFileNameWithoutExtension(viewModel.GetPathName());

            var bRes = viewModel.Extension.SaveAs($@"D:\{stepName}.step", (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref error, ref warnings);

            if (bRes == true)
            {
                MessageBox.Show("Export step Done!");
            }
            else
            {
                MessageBox.Show("Export Error!");
            }

代码已经发布在码云和github.

C# SolidWorks 二次开发 API —注释引用点的坑

最近有个小需求,就是要把注释箭头指向的点的坐标提取出来。
刚开始发现Note.GetAttachPos功能,Annotation.GetPosition有这个功能。
但是经过测试发现,当注释的引线是多折线的时候,上两个函数就是读取的位置有时候对,有时候不对。
本来可以想着把所有的第二种换成第一种,那么获取的时候就应该正确了,但是发现API里面还不能直接转换。

经过大量的调试发现,如果使用的是多折线,但是只有一条折线信息的时候,可能是对的,如果是多折的,基本上不对。
当鼠标移动到引线上时,默认的一段直线直接显示的是注释的图标,当移动到是多段折线上时,显示的是另一个图标,说明它们不是一个对象。而更像是一个组合体。

经过api的检查,发现了这个多折线有一个专门的对象。里面是由多个线的信息组成。

然后又发现Annotation中两个方法 GetMultiJogLeaderCount 和 GetMultiJogLeaders,所以就更显明了。
在获取注释对象 Note的引用点位置时,需要做一个判断。
当GetMultiJogLeaderCount > 0 时,那么说明它是一个多折线的注释,需要使用 MultiJogLeader 来获取信息。遍历其它的关键点坐标。
这个坐标和视图的位置与比例有一定关联,它默认是的整个图纸的坐标。如果需要转换到视图中,还需要做个计算。

下面是一段宏的代码:

Option Explicit
Sub main()
    Dim swApp           As SldWorks.SldWorks
    Dim swModel         As ModelDoc2
    Dim swDraw          As DrawingDoc
    Dim swSelMgr        As SelectionMgr
    Dim swNote          As Note
    Dim swView          As View
    Dim viewPos         As Variant
    Dim notePos         As Variant
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    
     Dim ann As Annotation
     
    If Not swModel Is Nothing Then
        If swModel.GetType <> swDocumentTypes_e.swDocDRAWING Then Exit Sub
        Set swDraw = swModel
        Set swSelMgr = swModel.SelectionManager
        
        Dim selLeaders As SldWorks.MultiJogLeader
          Dim lineData As Variant
          
          
          If swSelMgr.GetSelectedObjectType3(1, -1) <> swSelectType_e.swSelNOTES Then Exit Sub
          
        Set swNote = swSelMgr.GetSelectedObject6(1, 0)
        
        Set swView = swDraw.ActiveDrawingView
        viewPos = swView.Position
        notePos = swNote.GetAttachPos
       
        Set ann = swNote.GetAnnotation
                  
         If ann.GetMultiJogLeaderCount > 0 Then
         
         
         Set selLeaders = ann.GetMultiJogLeaders(0)
         
           If selLeaders Is Nothing = False Then
           
            
            lineData = selLeaders.GetLineAtIndex(0)
            For i = 0 To selLeaders.GetLineCount - 1
            
                 lineData = selLeaders.GetLineAtIndex(i)
                If Not IsEmpty(lineData) Then
                    
                    Debug.Print ("x:" & Math.Round((lineData(1) - viewPos(0)) * 1000# / swView.ScaleDecimal, 4))
                    Debug.Print ("y:" & Math.Round((lineData(2) - viewPos(1)) * 1000# / swView.ScaleDecimal, 4))
                                
                    
                End If
            Next i
           End If
           
           Else
           
         
         End If

           
       
        
' 'ann.UseDocDispLeader = True
       'Debug.Print (swView.Angle * 57.295779513)
' Debug.Print (Math.Round((notePos(0) - viewPos(0)) * 1000# / swView.ScaleDecimal, 4))
' Debug.Print (Math.Round((notePos(1) - viewPos(1)) * 1000# / swView.ScaleDecimal, 4))
' Debug.Print
    End If
End Sub

反之,按正常的GetAttachPos获取对象就可以了。

C# SolidWorks 二次开发 API — 修改全局变量的值

今天来简单讲一下如何修改方程式中的一些数据,有时候一些简单的模型我们就可以利用这个全局变量来控制模型.

如下图: 我设定了零件的高度方程式与全局变量h相等.

等到我们需要更新高度时,就可以直接修改这个全局变量,做到更简单的参数化方式,这个全局变量可以是上级装配体中的信息.

 下面来具体演示下如何找api:

打开api帮助文件,搜索关键字 globalvariable,就会发现右侧的实例,是一个获取信息的.

This example shows how to get the values of equations.

//-----------------------------------------
// Preconditions:
// 1. Open public_documents\samples\tutorial\api\partequations.sldprt.
// 2. Open the Immediate window.
//
// Postconditions:
// 1. Gets each equation's value and index and whether the 
//    equation is a global variable. 
// 2. Examine the Immediate window.
//------------------------------------------
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System;
using System.Diagnostics;
 
namespace Macro1CSharp.csproj
{
    public partial class SolidWorksMacro
    {
        public void Main()
        {
            ModelDoc2 swModel = default(ModelDoc2);
            EquationMgr swEqnMgr = default(EquationMgr);
            int i = 0;
            int nCount = 0;
 
            swModel = (ModelDoc2)swApp.ActiveDoc;
            swEqnMgr = (EquationMgr)swModel.GetEquationMgr();
            Debug.Print("File = " + swModel.GetPathName());
            nCount = swEqnMgr.GetCount();
            for (i = 0; i < nCount; i++)
            {
                Debug.Print("  Equation(" + i + ")  = " + swEqnMgr.get_Equation(i));
                Debug.Print("    Value = " + swEqnMgr.get_Value(i));
                Debug.Print("    Index = " + swEqnMgr.Status);
                Debug.Print("    Global variable? " + swEqnMgr.get_GlobalVariable(i));
            }
 
        }
 
        /// <summary>
        ///  The SldWorks swApp variable is pre-assigned for you.
        /// </summary>
        public SldWorks swApp;
    }
}

我们参考这段代码来完成方程式信息的读取: 增加按钮写代码.

 参照帮助文件写完的版本大概为:

运行一下:

 

下面我们来做修改:

private void butGlobalVariables_Click(object sender, EventArgs e)
        {
            //连接solidworks
            ISldWorks swApp = Utility.ConnectToSolidWorks();

            if (swApp != null)
            {
                //获取当前模型
                ModelDoc2 swModel = (ModelDoc2)swApp.ActiveDoc;
                //定义方程式管理器
                EquationMgr swEqnMgr = default(EquationMgr);

                int i = 0;
                int nCount = 0;

                if (swModel != null)
                {
                    swEqnMgr = (EquationMgr)swModel.GetEquationMgr();
                    // nCount = swEqnMgr.GetCount();
                    //for (i = 0; i < nCount; i++)
                    //{
                    //    Debug.Print("  Equation(" + i + ")  = " + swEqnMgr.get_Equation(i));
                    //    Debug.Print("    Value = " + swEqnMgr.get_Value(i));
                    //    Debug.Print("    Index = " + swEqnMgr.Status);
                    //    Debug.Print("    Global variable? " + swEqnMgr.get_GlobalVariable(i));
                    //}

                    //修改高度为60

                    if (SetEquationValue(swEqnMgr, "h", 60))
                    {
                        swModel.ForceRebuild3(true);
                    }
                    else
                    {
                        MessageBox.Show("没有找到这个值!");
                    }
                }
            }
        }

        #region 修改全局变量所用到的方法

        public bool SetEquationValue(EquationMgr eqMgr, string name, double newValue)
        {
            int index = GetEquationIndexByName(eqMgr, name);

            if (index != -1)
            {
                eqMgr.Equation[index] = "\"" + name + "\"=" + newValue;

                return true;
            }
            else
            {
                return false;
            }
        }

        //通过名字找方程式的位置
        private int GetEquationIndexByName(EquationMgr eqMgr, string name)
        {
            int i;
            for (i = 0; i <= eqMgr.GetCount() - 1; i++)
            {
                var eqName = eqMgr.Equation[i].Split('=')[0].Replace("=", "");

                eqName = eqName.Substring(1, eqName.Length - 2); // removing the "" symbols from the name

                if (eqName.ToUpper() == name.ToUpper())
                {
                    return i;
                }
            }

            return -1;
        }

        #endregion 修改全局变量所用到的方法

到此,零件高度变成了60, 这一节先讲这么多吧.

最终代码请到码云或者github上下载.

C# SolidWorks 二次开发 API —获取预览图

最近有网友问到如何在界面上简单的显示一个预览图,就类似于资源管理器中显示的图片。
今天来带大家找一找,首先在我共享的中文翻译中搜索一下:“预览

我们找到了几个有用的。
先看这一个: 第一列是Web 帮助的地址,当然也可以去本地api帮助中查看。


vba中还有个例 子
问题是这帮助写的只能是进程内使用,像exe还不行。
继续看下面的,有另一个方法:

这个方法看描述好像可以使用:
Gets the specified preview bitmap of a document and saves it as a Windows bitmap file (.bmp) using the specified filename.

写上代码:

ISldWorks swApp = Utility.ConnectToSolidWorks();

            //此处路径请自己确保存在。
            string fileName = @"D:\09_Study\CSharpAndSolidWorks\CSharpAndSolidWorks\TemplateModel\bodies.sldasm";

            string configName = "Default";

            string bitmapPathName = @"D:\09_Study\CSharpAndSolidWorks\CSharpAndSolidWorks\TemplateModel\bodies.bmp";

            var status = swApp.GetPreviewBitmapFile(fileName, configName, bitmapPathName);

            if (System.IO.File.Exists(bitmapPathName))
            {
                swApp.SendMsgToUser("预览图获取完成。");
            }

结果出来的颜色有点怪,不理想。

到这里想了下,我们可以直接获取系统资源管理器的预览图,而不需要利用solidworks来处理。
这个就直接百度,找一找资源就行了。
我找了个类,直接调用 ,就可以获取到文件了,后缀是.li ,很奇怪的格式。

找到文件,复制到当前零件的文件夹。改后缀为.bmp,ok了。

这是利用系统的api的获取的,如果只是单配置零件也比较完美了。这种好像不能获取不同配置的预览图。

在查询api帮助的时候发现,在Document Manager API 中也提供了获取预览图的功能。
注意,这里需要一个key, 正版用户请找对应的代理商获取,每一个版本的key都不一样,并且带公司名称。


里面还有实例,那我们就来试试吧:
测试时发现,document mgr从2018开始,只支持64位程序。所以测试时大家要把编译的选项改成x64位的,不然一直会报无法创建dll的实例。

 			const string sLicenseKey = "your_license_key"; //这个不好公开。请下载代码 

            string sDocFileName = fileName;

            SwDMClassFactory swClassFact = default(SwDMClassFactory);
            SwDMApplication swDocMgr = default(SwDMApplication);
            SwDMDocument swDoc = default(SwDMDocument);
            SwDMDocument10 swDoc10 = default(SwDMDocument10);
            SwDmDocumentType nDocType = 0;
            SwDmDocumentOpenError nRetVal = 0;
            SwDmPreviewError nError = 0;

            // Determine type of SOLIDWORKS file based on file extension
            if (sDocFileName.EndsWith("sldprt"))
            {
                nDocType = SwDmDocumentType.swDmDocumentPart;
            }
            else if (sDocFileName.EndsWith("sldasm"))
            {
                nDocType = SwDmDocumentType.swDmDocumentAssembly;
            }
            else if (sDocFileName.EndsWith("slddrw"))
            {
                nDocType = SwDmDocumentType.swDmDocumentDrawing;
            }
            else
            {
                // Probably not a SOLIDWORKS file,
                // so cannot open
                nDocType = SwDmDocumentType.swDmDocumentUnknown;
                return;
            }

            swClassFact = new SwDMClassFactory();
            swDocMgr = (SwDMApplication)swClassFact.GetApplication(sLicenseKey);
            swDoc = (SwDMDocument)swDocMgr.GetDocument(sDocFileName, nDocType, true, out nRetVal);
            Debug.Print("File = " + swDoc.FullName);
            Debug.Print(" Version = " + swDoc.GetVersion());
            Debug.Print(" Author = " + swDoc.Author);
            Debug.Print(" Comments = " + swDoc.Comments);
            Debug.Print(" CreationDate = " + swDoc.CreationDate);
            Debug.Print(" Keywords = " + swDoc.Keywords);
            Debug.Print(" LastSavedBy = " + swDoc.LastSavedBy);
            Debug.Print(" LastSavedDate = " + swDoc.LastSavedDate);
            Debug.Print(" Subject = " + swDoc.Subject);
            Debug.Print(" Title = " + swDoc.Title);

            swDoc10 = (SwDMDocument10)swDoc;
            // SwDMDocument10::GetPreviewBitmap throws an unmanaged COM exception
            // for out-of-process C# console applications
            // Use the following code in SOLIDWORKS C# macros and add-ins
            object objBitMap = swDoc10.GetPreviewBitmap(out nError);
            System.Drawing.Image imgPreview = PictureDispConverter.Convert(objBitMap);
            imgPreview.Save(bitmapPathName, System.Drawing.Imaging.ImageFormat.Bmp);
            imgPreview.Dispose();

            Debug.Print(" Preview stream = " + swDoc10.PreviewStreamName);

执行成功之后 ,我们颜色不对的预览图就被替换成功了。

当然 ,现在也还是只是获取了最后保存的那个配置的缩略图。
如何获取别的配置的呢?
这个方法的备注里面有说明: 需要用别的方法:

里面有个实例:
Get PNG Preview Bitmap and Stream for Configuration Example (C#)
核心就在这里,需要去遍历配置。当然 ,如果知道配置名称,就不需要遍历一次了。
下面的代码我没有测试哈

 swCfgMgr = swDoc.ConfigurationManager;
 
                Debug.Print("File = " + swDoc.FullName);
                Debug.Print("Active configuration name = " + swCfgMgr.GetActiveConfigurationName());
                vCfgNameArr = (string[])swCfgMgr.GetConfigurationNames();
 
                foreach (string vCfgName in vCfgNameArr)
                {
 
                    swCfg = (SwDMConfiguration7)swCfgMgr.GetConfigurationByName(vCfgName);
                    // SwDMConfiguration7::GetPreviewPNGBitmap throws an unmanaged COM exception 
                    // for out-of-process C# console applications
                    // Use the following code in SOLIDWORKS C# macros and add-ins 
                    object objBitMap = swCfg.GetPreviewPNGBitmap(out nError);
                    System.Drawing.Image imgPreview = PictureDispConverter.Convert(objBitMap);
                    imgPreview.Save("C:\\temp\\" + vCfgName + ".PNG", System.Drawing.Imaging.ImageFormat.Png);
                    imgPreview.Dispose();
 
                    Debug.Print(" " + vCfgName);
                    Debug.Print(" PNG preview stream = " + swCfg.PreviewPNGStreamName);
 
                    Debug.Print(" ");
                }

C# SolidWorks 二次开发 API — 实例:屏幕上1:1显示零件

这个功能很多年前就有人提过,这只是其中一个: https://forum.solidworks.com/message/878652

因为现在的屏幕越来越大,设计好的零件可能 需要按照料模型实际尺寸,投影到屏幕上。

做这个功能是很早之前有人有这种需求,问我能不能做到,因为他们需要在一个超大的电视上显示实际的产品大小,用来介绍产品,经过我的研究,solidworks中显示有个内置比例,并且当solidworks窗口大小不一样的时候,要想1:1显示也是要调整的,而不是一次性的。

解决这个问题的思路:先得到屏幕的实际物理尺寸,然后利用solidworks中的设计尺寸,与在屏幕外用卡尺测量出来的实际尺寸之前的比例关系,可以得到当前状态下solidworks显示模型在1:1时的比例关系。

我们要的效果就是如下:

      测量尺寸和零件的实体尺寸是一致的:

 先点击自动校准,然后点右侧的1:1就可以实物显示了。 在不改窗口大小的情况,不需要再次校准。

 

 

代码就不贴了,自已去下载吧。

C# SolidWorks 二次开发 API — 2018版 中文翻译 ModelDocExtension 方法

AddAngularRunningDim Method (IModelDocExtension) 为选定实体添加指定的角度运行标注。
AddComment Method (IModelDocExtension) 将注释添加到此文档的注释文件夹中。
AddDecal Method (IModelDocExtension) 向模型添加贴花。
AddDefaultRenderMaterial Method (IModelDocExtension) solidworks 2011及以后版本不支持,也不被取代。
AddDimension Method (IModelDocExtension) 在选定实体的指定位置创建显示维度。
AddDisplayStateSpecificRenderMaterial Method (IModelDocExtension) 将指定的外观添加到活动配置中的指定显示状态,并返回分配给该外观的ID。
AddOrdinateDimension Method (IModelDocExtension) 插入坐标标注。
AddOrUpdateSearchData Method (IModelDocExtension) 向模型文档添加或更新solidworks搜索、第三方、应用程序关键字和值。
AddPathLengthDim Method (IModelDocExtension) 在选定路径的指定坐标处插入路径长度标注。
AddRenderMaterial Method (IModelDocExtension) solidworks 2011及更高版本不支持。被imodeldocextension::addDisplayStateSpecificRenderMaterial和imodeldocextension::iaddDisplayStateSpecificRenderMaterial取代。
AddSpecificDimension Method (IModelDocExtension) 在选定实体的指定位置创建指定的显示维度。
AddSymmetricDimension Method (IModelDocExtension) 在选定实体的指定位置创建完全对称的角度标注。
AlignDimensions Method (IModelDocExtension) 对齐工程图文档中选定的尺寸。
AlignRunningDimension Method (IModelDocExtension) 对齐所有角度标注的尺寸界线,使其距中心的距离与角度运行标注集中的基线标注(0_)相同。
ApplyFormatPainterToAll Method (IModelDocExtension) 将格式刷应用于活动文档中的所有维度和批注。
BreakAllExternalFileReferences2 Method (IModelDocExtension) 打断所有外部参照,并允许您插入原始零件的特征(如果外部参照已打断)。
Capture3DView Method (IModelDocExtension) 捕获此零件或部件的三维视图。
ChangeSketchPlane Method (IModelDocExtension) 通过将选定草图移动到指定配置中的选定平面来更改草图使用的平面。
Compare3DPMI Method (IModelDocExtension) 比较同一零件文档的不同版本之间的dimxpert注释、参考尺寸和其他注释。
CopyDraftingStandard Method (IModelDocExtension) 复制当前的自定义绘图标准。
Create3DBoundingBox Method (IModelDocExtension) 为焊接件零件中的剪切列表项创建三维边界框。
CreateAdvancedHoleElementData Method (IModelDocExtension) 创建指定类型的高级孔元素数据对象。
CreateBalloonOptions Method (IModelDocExtension) 创建存储bom气球选项的对象。
CreateCallout Method (IModelDocExtension) 创建独立于选定内容的标注。
CreateDecal Method (IModelDocExtension) 为此模型创建贴花。
CreateMassProperty Method (IModelDocExtension) 创建imassproperty对象。
CreateMeasure Method (IModelDocExtension) 创建测量工具。
CreateOLEObject Method (IModelDocExtension) 在活动文档上创建OLE对象。
CreateRenderMaterial Method (IModelDocExtension) 创建此模型的外观。
CreateStackedBalloonOptions Method (IModelDocExtension) 创建存储堆叠引出序号选项的对象。
CreateTexture Method (IModelDocExtension) 创建纹理。
DeleteAllDecals Method (IModelDocExtension) 删除此模型上的所有贴花。
DeleteAttachment Method (IModelDocExtension) 删除FeatureManager设计树中“附件”文件夹中的指定文件。
DeleteDecal Method (IModelDocExtension) 从此模型中删除指定的贴花。
DeleteDisplayStateSpecificRenderMaterial Method (IModelDocExtension) 使用外观的ID从活动配置中删除指定的外观。
DeleteDraftingStandard Method (IModelDocExtension) 删除当前的自定义绘图标准。
DeleteFeatureMgrViewx64 Method (IModelDocExtension) 删除64位应用程序中FeatureManager设计树中的指定选项卡。
DeleteRenderMaterial Method (IModelDocExtension) solidworks 2011及更高版本不支持。已被imodelDocExtension::deleteDisplayStateSpecificRenderMaterial和imodelDocExtension::ideleteDisplayStateSpecificRenderMaterial取代。
DeleteScene Method (IModelDocExtension) 删除应用于此模型的场景。
DeleteSearchData Method (IModelDocExtension) 从模型文档中删除指定的SolidWorks搜索第三方关键字。
DeleteSelection2 Method (IModelDocExtension) 删除选定的项,可以选择删除吸收的特征、子特征或同时删除这两个特征。
EditBalloonProperties2 Method (IModelDocExtension) 编辑选定引出序号的特性。
EditDimensionProperties Method (IModelDocExtension) 编辑选定的维度。
EditRebuildAll Method (IModelDocExtension) 仅重建所有配置中需要重建的功能,而不激活每个配置。
FindTrackedObjects Method (IModelDocExtension) 查找分配给此文档中实体的跟踪ID。
FinishRecordingUndoObject2 Method (IModelDocExtension) 以指定的名称和可见性结束solidworks撤消对象的录制。
ForceRebuildAll Method (IModelDocExtension) 强制重新生成所有配置中的所有功能,而不激活每个配置。
Get3DView Method (IModelDocExtension) 获取具有此零件或部件的指定名称的三维视图。
Get3DViewCount Method (IModelDocExtension) 获取此零件或部件中的三维视图数。
Get3DViewNames Method (IModelDocExtension) 获取此零件或部件中三维视图的名称。
Get3DViews Method (IModelDocExtension) 获取此零件或部件的三维视图。
GetActivePropertyManagerPage Method (IModelDocExtension) 获取活动属性管理器页的名称。
GetAdvancedSpotLightProperties Method (IModelDocExtension) 获取此模型中指定的SolidWorks聚光灯的衰减相关高级属性。
GetAnnotationCount Method (IModelDocExtension) 获取此部件上的批注数。
GetAnnotations Method (IModelDocExtension) 获取此部件上的批注。
GetAppearanceSetting Method (IModelDocExtension) 获取此文档的外观设置。
GetAttachmentCount Method (IModelDocExtension) 获取此文档的附件数。
GetAttachments Method (IModelDocExtension) 获取此文档的附件。
GetCalloutVariableString Method (IModelDocExtension) 获取指定callout变量的字符串。
GetCameraById Method (IModelDocExtension) 获取使用指定相机ID的相机。
GetCameraCount Method (IModelDocExtension) 获取文档中的相机数。
GetCameraDefinition Method (IModelDocExtension) 获取相机,但不将新创建的相机添加到模型中。
GetCommandTabs Method (IModelDocExtension) 获取此文档中的所有solidworks commandmanager选项卡名称。
GetCoordinateSystemTransformByName Method (IModelDocExtension) 获取指定坐标系的转换。
GetCorresponding2 Method (IModelDocExtension) 获取与此工程视图或部件中的指定输入对象相对应的基础零件或部件文档中的对象。
GetCorrespondingEntity2 Method (IModelDocExtension) 获取与此部件或工程视图中的指定实体相对应的基础零件或子部件中的实体。
GetCostingManager Method (IModelDocExtension) 获取SolidWorks成本核算API的入口点接口,并获取成本核算管理器。
GetDecal Method (IModelDocExtension) 获取此模型中指定的贴花。
GetDecals Method (IModelDocExtension) 获取应用于模型的贴花。
GetDecalsCount Method (IModelDocExtension) 获取应用于此模型的贴花数。
GetDependencies Method (IModelDocExtension) 获取此模型的所有依赖项。
GetDisplayStateSetting Method (IModelDocExtension) 获取指定作用域的显示状态设置。
GetDraftingStandardNames Method (IModelDocExtension) 获取所有当前可用绘图标准的名称。
GetFlattenSheetMetalPersistReference Method (IModelDocExtension) 获取扁平钣金零件中指定实体(面、边或顶点)的持久引用ID的字节数组。
GetGeneralTableAnnotation Method (IModelDocExtension) 为solidworks mbd 3d pdf创建常规表格注释。
GetKeepLightInRenderScene Method (IModelDocExtension) 获取场景更改时是否保留灯光。
GetLastFeatureAdded Method (IModelDocExtension) 获取添加到模型的最后一个功能。
GetLicenseType Method (IModelDocExtension) 获取创建模型时使用的SolidWorks许可证的类型。
GetLightEnabledInRender Method (IModelDocExtension) 获取此模型中是否亮起灯。
GetMassProperties2 Method (IModelDocExtension) 获取模型中组件在指定精度下的实际质量属性。
GetMaterial Method (IModelDocExtension) 获取此模型文档中指定配置中指定外观ID的外观。
GetMaterialPropertyValues Method (IModelDocExtension) 获取此模型文档的材质属性。
GetMBD3DPdfData Method (IModelDocExtension) 获取solidworks mbd 3d pdf数据对象。
GetModelBreakViewNames Method (IModelDocExtension) 获取活动模型的当前配置中模型中断视图的名称和编号。
GetModelViewCount Method (IModelDocExtension) 获取此文档中的模型视图数。
GetModelViews Method (IModelDocExtension) 获取此文档中的模型视图。
GetMotionStudyManager Method (IModelDocExtension) 获取SolidWorks运动研究的MotionManager。
GetNamedViewRotation Method (IModelDocExtension) 获取相对于前视图的指定命名视图方向矩阵。
GetObjectByPersistReference3 Method (IModelDocExtension) 获取分配给指定的持久引用ID的对象。
GetObjectId Method (IModelDocExtension) 获取指定批注的对象ID。
GetOLEObjectCount Method (IModelDocExtension) 获取OLE对象的数目。
GetOLEObjects Method (IModelDocExtension) 获取OLE对象。
GetPackAndGo Method (IModelDocExtension) 获取打包对象。
GetPersistReference3 Method (IModelDocExtension) 获取此模型文档中指定对象的永久引用ID。
GetPersistReferenceCount3 Method (IModelDocExtension) 获取分配给此模型文档中选定对象的持久引用ID的大小。
GetPrint3DDialog Method (IModelDocExtension) 获取IPrint3DDialog对象。
GetPrintSpecification Method (IModelDocExtension) 获取此文档的IPrintSpecification对象。
GetRenderCustomReferences Method (IModelDocExtension) 获取此模型的自定义渲染引用。
GetRenderMaterials2 Method (IModelDocExtension) 获取在指定显示状态下应用于此模型文档的外观。
GetRenderMaterialsCount2 Method (IModelDocExtension) 获取在指定显示状态下应用于此模型文档的外观数。
GetRenderStockReferences Method (IModelDocExtension) 获取此模型的SolidWorks提供(库存)呈现引用。
GetRoutingComponentManager Method (IModelDocExtension) 获取路由组件管理器。
GetScanto3D Method (IModelDocExtension) 获取此文档的iscanto3d对象。
GetSceneBkgDIBx64 Method (IModelDocExtension) 在64位应用程序中获取作为dibsection的背景图像。
GetSearchData Method (IModelDocExtension) 从模型文档中获取solidworks搜索、第三方、应用程序关键字。
GetSearchDataCount Method (IModelDocExtension) 获取以前添加到此模型文档中的指定第三方应用程序的SolidWorks搜索关键字数。
GetSectionProperties2 Method (IModelDocExtension) 获取以下类型选定项的截面特性:截面平面上任意文档面中的平面模型面在工程图中截面视图中的剖面线截面面草图
GetSheetMetalObjectsByPersistReference Method (IModelDocExtension) 获取折叠钣金零件中与展开钣金零件中实体的持久引用ID的字节数组相对应的对象。
GetStream Method (IModelDocExtension) 获取指定流的句柄。
GetSunLightAdvancedPropertyValues Method (IModelDocExtension) 获取指定的日光高级属性。
GetSunLightSourcePropertyValues Method (IModelDocExtension) 获取阳光源的属性值。
GetSustainability Method (IModelDocExtension) 获取SolidWorks可持续性API的入口点接口。
GetTemplateSheetMetal Method (IModelDocExtension) 从在SolidWorks 2013或更高版本中创建的此钣金模型中获取钣金文件夹功能。
GetTexture Method (IModelDocExtension) 获取应用于指定配置的纹理。
GetUserPreferenceDouble Method (IModelDocExtension) 获取文档默认用户首选项值。此方法用于double类型的用户首选项。
GetUserPreferenceDoubleValueRange Method (IModelDocExtension) 获取当前文档默认用户首选项值和最小和最大有效文档用户偏好值。
GetUserPreferenceInteger Method (IModelDocExtension) 设置文档默认用户首选项值。此方法用于Integer类型的用户首选项。
GetUserPreferenceString Method (IModelDocExtension) 获取文档默认用户首选项值。此方法用于字符串类型的用户首选项。
GetUserPreferenceTextFormat Method (IModelDocExtension) 获取文档默认用户首选项值。此方法用于获取详细的文本格式。
GetUserPreferenceToggle Method (IModelDocExtension) 获取文档默认用户首选项值。此方法用于可切换的用户首选项。
GetVisibleBox Method (IModelDocExtension) 获取由IModelDocExtension::SetVisibleBox为部件或程序集设置的可见边界框。
GetWhatsWrong Method (IModelDocExtension) 获取此模型文档的错误对话框信息。
GetWhatsWrongCount Method (IModelDocExtension) 获取“错误”对话框中的项目数。
HasDesignTable Method (IModelDocExtension) 获取文档是否具有设计表。
HasMaterialPropertyValues Method (IModelDocExtension) 获取此模型是否具有外观。
HasRenamedDocuments Method (IModelDocExtension) 获取文档是否已重命名文件。
HideDecal Method (IModelDocExtension) 隐藏或显示应用于此模型的指定贴花。
HideFeatureManager Method (IModelDocExtension) 隐藏或显示管理器窗格。
IAddDisplayStateSpecificRenderMaterial Method (IModelDocExtension) 将指定的材质添加到活动配置中的指定显示状态,并返回指定给该材质的ID。
IChangeSketchPlane Method (IModelDocExtension) 通过将选定草图移动到指定配置中的选定平面来更改草图使用的平面。
ICreateOLEObject Method (IModelDocExtension) 在活动文档上创建OLE对象。
IDeleteDisplayStateSpecificRenderMaterial Method (IModelDocExtension) 使用材质的ID从活动配置中删除指定的材质。
IEditDimensionProperties Method (IModelDocExtension) 编辑选定的维度。
IGet3rdPartyStorageStore Method (IModelDocExtension) 获取此模型文档中的第三方IStorage接口。
IGetAnnotations Method (IModelDocExtension) 获取此模型上的批注。
IGetAnnotationViews Method (IModelDocExtension) 获取此零件或部件文档中的批注视图。
IGetAttachments Method (IModelDocExtension) 获取此文档的附件。
IGetDecals Method (IModelDocExtension) 获取应用于模型的贴花。
IGetFlattenSheetMetalPersistReference Method (IModelDocExtension) 获取扁平钣金零件中指定实体(面、边或顶点)的持久引用ID的字节数组。
IGetMaterialPropertyValues Method (IModelDocExtension) 获取此模型的材质属性。
IGetModelViews Method (IModelDocExtension) 获取此文档中的模型视图。
IGetNamedViewRotation Method (IModelDocExtension) 获取相对于前视图的指定命名视图方向矩阵。
IGetObjectByPersistReference3 Method (IModelDocExtension) 获取分配给指定的持久引用ID的对象。
IGetOLEObjects Method (IModelDocExtension) 获取OLE对象。
IGetPersistReference3 Method (IModelDocExtension) 获取此模型文档中指定对象的永久引用ID。
IGetSearchData Method (IModelDocExtension) 从模型文档中获取solidworks搜索、第三方、应用程序关键字。
IGetSectionProperties2 Method (IModelDocExtension) 获取以下类型选定项的截面特性:截面平面上任意文档面中的平面模型面在工程图中截面视图中的剖面线截面面草图
IGetSheetMetalObjectsByPersistReference Method (IModelDocExtension) 获取折叠钣金零件中的一个或多个对象,该折叠钣金零件对应于展开钣金零件中实体的永久引用ID的字节数组。
IListExternalFileReferences Method (IModelDocExtension) 获取部件上外部文件引用的名称和状态。
InsertAnnotationFavorite Method (IModelDocExtension) 在指定位置插入指定收藏夹文件中的批注。
InsertAnnotationView Method (IModelDocExtension) 在此零件或部件文档中插入注释视图。
InsertAttachment Method (IModelDocExtension) 将文件作为附件插入到此文档。
InsertBOMBalloon2 Method (IModelDocExtension) 为选定项插入一个bom气球。
InsertBomTable3 Method (IModelDocExtension) 在零件或部件文档中插入物料清单(bom)表。
InsertCamera Method (IModelDocExtension) 在此文档中插入相机。
InsertDatumTargetSymbol3 Method (IModelDocExtension) 创建基准目标符号。
InsertDeleteFace Method (IModelDocExtension) 插入删除面特征。
InsertGeneralTableAnnotation Method (IModelDocExtension) 在此模型文档中插入通用表批注。
InsertGeneralToleranceTableAnnotation Method (IModelDocExtension) 在此模型文档中插入通用公差表注释。
InsertObjectFromFile Method (IModelDocExtension) 从文件中插入OLE对象。
InsertScene Method (IModelDocExtension) 将指定的场景应用于模型。
InsertStackedBalloon2 Method (IModelDocExtension) 为选定项插入一组引出序号。
InsertSurfaceFinishSymbol3 Method (IModelDocExtension) 基于上次选择创建表面光洁度符号。
InsertTitleBlockTable Method (IModelDocExtension) 在零件或部件文档中插入标题栏表格。
InstallModelColorizer Method (IModelDocExtension) 安装iswcolorcontour接口的实现接口。
IRelease3rdPartyStorageStore Method (IModelDocExtension) 从此模型文档中发布第三方iStorage接口。
IRemoveMaterialProperty Method (IModelDocExtension) 从此模型中删除材质特性值。
IsAbbreviatedViewActive Method (IModelDocExtension) 获取或设置缩写视图是否处于活动状态。
IsConverted Method (IModelDocExtension) 获取活动文档是否已转换为当前版本更新打开,但尚未保存。
ISetMaterialPropertyValues Method (IModelDocExtension) 设置此模型文档的材质特性值。
IsExploded Method (IModelDocExtension) 获取当前在模型中显示的分解视图的名称。
IsFutureVersion Method (IModelDocExtension) 获取此文档是否用于solidworks的未来版本。
IsSamePersistentID Method (IModelDocExtension) 获取两个指定对象是否具有相同的持久引用ID。
IsVirtualComponent3 Method (IModelDocExtension) 获取到父程序集组件的路径,如果模型是虚拟组件,则该路径最多包括第一个非虚拟父程序集。
JogDimension Method (IModelDocExtension) 获取或设置交互选择的线性标注或坐标标注上的折弯点是打开还是关闭。
ListExternalFileReferences Method (IModelDocExtension) 获取部件上外部引用的名称和状态。
ListExternalFileReferencesCount Method (IModelDocExtension) 获取部件上的外部引用数。
LoadDraftingStandard Method (IModelDocExtension) 从文件加载自定义绘图标准。
MoveDecal Method (IModelDocExtension) 在应用于模型的贴花列表中向上或向下移动贴花。
MoveOrCopy Method (IModelDocExtension) 移动并可选地复制选定的草图实体或注释。
MultiSelect2 Method (IModelDocExtension) 选择多个对象并返回在模型中选定的对象数。
PrintOut4 Method (IModelDocExtension) 打印此文档而不显示任何对话框或消息框。
PublishSTEP242File Method (IModelDocExtension) 将solidworks mbd三维零件或部件导出到步骤242文件。
PublishTo3DPDF Method (IModelDocExtension) 为solidworks mbd创建三维pdf。
PurgeDisplayState Method (IModelDocExtension) 清除相同的显示状态,以便只保留唯一的显示状态。
RayIntersections Method (IModelDocExtension) 查找指定的光线集和指定的实体集之间的交点。
Rebuild Method (IModelDocExtension) 在部件和工程图文档中重建模型并返回重建的状态。
Refresh3DViews Method (IModelDocExtension) 更新此零件或部件的三维视图。
ReJogRunningDimension Method (IModelDocExtension) 在尺寸界线与角度标注中的标注文字重叠的位置应用折弯。
ReleaseStream Method (IModelDocExtension) 释放先前获得的流。
RemoveMaterialProperty Method (IModelDocExtension) 从此模型中删除材质特性值。
RemoveModelColorizer Method (IModelDocExtension) 删除iswcolorcontour接口的已安装实现接口。
RemoveTexture2 Method (IModelDocExtension) 从指定的配置中移除纹理。
RemoveTextureByDisplayState Method (IModelDocExtension) 删除在指定显示状态下应用于此模型的纹理。
RemoveVisibleBox Method (IModelDocExtension) 移除由imodeldocextension::set visible box设置的可见边界框,并将边界框的大小重置为solidworks为零件或部件计算的大小。
RenameDocument Method (IModelDocExtension) 使用指定的名称临时重命名选定的组件。
RenameDraftingStandard Method (IModelDocExtension) 将当前自定义绘图重命名为指定的名称。
ReorderFeature Method (IModelDocExtension) 将指定的特征移动到此零件或部件的FeatureManager设计树中的其他位置。
ResetStandardViews Method (IModelDocExtension) 将所有标准模型视图返回到其默认设置。
ReverseDecalsOrder Method (IModelDocExtension) 反转模型上贴花的顺序。
RotateOrCopy Method (IModelDocExtension) 旋转并可选地复制选定的草图实体或注释。
RunCommand Method (IModelDocExtension) 运行指定的solidworks命令。
SaveAs Method (IModelDocExtension) 以指定的格式将活动文档保存到指定的名称。
SaveDeFeaturedFile Method (IModelDocExtension) 从加载的零件或部件文档中删除除外表面以外的所有CAD数据,并将外表面保存为零件。
SaveDraftingStandard Method (IModelDocExtension) 将当前自定义绘图标准保存到文件中。
SavePackAndGo Method (IModelDocExtension) 保存指定用于打包的文件,然后转到文件夹或zip文件。
SaveSelection Method (IModelDocExtension) 创建包含选定实体的新选择集。
ScaleOrCopy Method (IModelDocExtension) 缩放并可选地复制选定的草图项或注释。
SelectAll Method (IModelDocExtension) 选择零件中的所有边、部件中的所有零部件或图形中的所有实体(默认情况下,草图实体、尺寸和注释)。
SelectByID2 Method (IModelDocExtension) 选择指定的实体。
SelectByRay Method (IModelDocExtension) 选择指定类型的第一个实体,该实体与从指定点开始并在指定半径内平行于指定方向矢量的光线相交。
SetAdvancedSpotLightProperties Method (IModelDocExtension) 设置此模型中指定的SolidWorks聚光灯的衰减相关高级属性。
SetApiUndoObject Method (IModelDocExtension) 实现外接程序应用程序的撤消对象。
SetKeepLightInRenderScene Method (IModelDocExtension) 设置场景更改时是否保留灯光。
SetLightEnabledInRender Method (IModelDocExtension) 设置此模型中的灯光是否打开。
SetMaterialPropertyValues Method (IModelDocExtension) 设置此模型文档的材质特性值。
SetSceneBkgDIBx64 Method (IModelDocExtension) 在64位应用程序中设置背景图像。
SetSunLightAdvancedPropertyValues Method (IModelDocExtension) 设置指定的日光高级属性。
SetSunLightSourcePropertyValues Method (IModelDocExtension) 设置日光源的特性值。
SetTexture Method (IModelDocExtension) 将纹理应用于指定的配置。
SetTextureByDisplayState Method (IModelDocExtension) 设置在指定显示状态下应用于此模型的纹理。
SetTopLevelTransparency Method (IModelDocExtension) 设置此零件或顶级部件的透明度。
SetUserPreferenceDouble Method (IModelDocExtension) 设置文档默认用户首选项值。此方法用于double类型的用户首选项。
SetUserPreferenceInteger Method (IModelDocExtension) 设置文档默认用户首选项值。此方法用于Integer类型的用户首选项。
SetUserPreferenceString Method (IModelDocExtension) 设置文档默认用户首选项值。此方法用于字符串类型的用户首选项。
SetUserPreferenceTextFormat Method (IModelDocExtension) 设置文档默认用户首选项值。此方法用于设置详细文本格式。
SetUserPreferenceToggle Method (IModelDocExtension) 设置文档默认用户首选项值。此方法用于可切换的用户首选项。
SetVisibleBox Method (IModelDocExtension) 将缩放的可见边界框设置为适合零件或部件。
ShowModelBreakView Method (IModelDocExtension) 获取是否在活动模型的当前配置中显示或隐藏指定的模型中断视图。
ShowSmartMessage Method (IModelDocExtension) 在图形区域和状态栏上显示solidworks样式消息作为工具提示。
SketchBoxSelect Method (IModelDocExtension) 框在选择框的指定坐标内选择草图中的所有实体。
SketchOffsetOnSurface Method (IModelDocExtension) 偏移选定边以在面或曲面上创建三维草图。
StartFormatPainter Method (IModelDocExtension) 启动格式绘制程序。
StartRecordingUndoObject Method (IModelDocExtension) 开始录制solidworks撤消对象。
StopFormatPainter Method (IModelDocExtension) 停止格式刷。
Stretch Method (IModelDocExtension) 拉伸选定的实体。
UpdateExternalFileReferences Method (IModelDocExtension) 更新此模型上的外部文件引用。
UpdateFrozenFeatures Method (IModelDocExtension) 更新模型的冻结特征。
UpdateRenderMaterialsInSceneGraph Method (IModelDocExtension) 设置是否更新模型中图形区域中的外观。
UpdateStandardViews Method (IModelDocExtension) 将指定的标准视图更改为当前模型视图。
UpdateSunLight Method (IModelDocExtension) 更新日光位置、颜色和背景图像。
ViewZoomToSheet Method (IModelDocExtension) 将绘图页放大到窗口内的最大尺寸。