日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

IDrawingDoc Interface 学习笔记

發(fā)布時(shí)間:2023/12/18 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 IDrawingDoc Interface 学习笔记 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Solidworks學(xué)習(xí)筆記-鏈接Solidworks

在此基礎(chǔ)上

允許訪問執(zhí)行繪圖操作的函數(shù)。

屬性

NameDescription備注
ActiveDrawingViewGets the currently active drawing view. ?獲取當(dāng)前活動(dòng)的圖紙視圖。
AutomaticViewUpdateGets or sets whether the drawing views in this drawing are automatically updated if the underlying model in that drawing view changes. ?獲取或設(shè)置該工程圖中的工程視圖是否在該工程視圖中的基礎(chǔ)模型發(fā)生更改時(shí)自動(dòng)更新。
BackgroundProcessingOptionGets or sets the background processing option for this drawing. ?獲取或設(shè)置此繪圖的后臺(tái)處理選項(xiàng)。
HiddenViewsVisibleShows or hides all of the hidden drawing views. ?顯示或隱藏所有隱藏的圖紙視圖。
IActiveDrawingViewGets the currently active drawing view. ?獲取當(dāng)前活動(dòng)的圖紙視圖。
SheetGets the specified sheet. ?獲取指定的工作表。

System.int BackgroundProcessingOption {get; set;}

This example shows how to fire notifications when background processing events occur.//---------------------------------------------------------------------------- // Preconditions: // 1. Create a VSTA C# macro. // a. Copy and paste SolidWorksMacro.cs code in the macro. // b. Create a form, Form1, that contains the following // controls: // * CheckBox1 with caption Enable background processing and open // drawing. // * button1 with caption Close after background processing end event // fires". // c. Copy and paste Form1.cs code in your form's code window. // d. Modify the path in Form1.cs to open a huge drawing document that // contains many parts. // 2. Press F5 to start and close the debugger. // 3. Click Build > Build macro_name to build a DLL for the macro. // 4. Save and close the macro. // // Postconditions: // 1. Open the Windows Task manager, click the Processes tab, and click the CPU column // header to sort the processes in descending order. // 2. In SOLIDWORKS, click Tools > Macro > Run. // a. Locate your macro's \SwMacro\bin\Debug folder. // b. Select macro_name.dll. // c. Click Open to open the form. // 3. Select the Enable background processing and open drawing checkbox on the form. // 4. Displays a checkmark in the check box. // 5. Click OK to close the Background processing enabled message box. // 6. Opens the specified drawing. // 7. Fires the background processing start events. // 8. Click OK to close the Background processing start event fired message box. // 9. In the Windows Task Manager, observe that several sldbgproc.exe processes are // occupying most of the CPU. // 10. Click OK to close the Background processing stop event fired message box. // 11. Click Close after background processing end event fired button on the form. // 12. Unloads Form1. //----------------------------------------------------------------------------------//SolidWorksMacro.csusing SolidWorks.Interop.sldworks; using System.Runtime.InteropServices; using System; using System.Windows.Forms;namespace BackgroundProcessingEventsCSharp.csproj {public partial class SolidWorksMacro{public SldWorks swApp;public void Main(){//Create and show an instance of the formForm1 myForm = new Form1();myForm.Show();}} }//Form1using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Windows.Forms; using System.Diagnostics; using System.Collections; using System.Runtime.InteropServices; using System; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text;namespace BackgroundProcessingEventsCSharp.csproj {public partial class Form1 : Form{public Form1(){InitializeComponent();}public SldWorks swApp;public bool checkBoxClicked;private void checkBox1_CheckedChanged(object sender, EventArgs e){try{swApp = (SldWorks)System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application");}catch (Exception ex){MessageBox.Show(ex.Message);return;}ModelDoc2 swModelDoc = default(ModelDoc2);DrawingDoc swDrawingDoc = default(DrawingDoc);string filePath = null;filePath = "path_and_filename_of_huge_drawing";DocumentSpecification docSpecification = default(DocumentSpecification);// Set up eventsAttachEventHandlers();// Enable background processingswApp.EnableBackgroundProcessing = true;MessageBox.Show("Background processing enabled");// Open huge drawingdocSpecification = (DocumentSpecification)swApp.GetOpenDocSpec(filePath);docSpecification.Silent = true;swModelDoc = (ModelDoc2)swApp.OpenDoc7(docSpecification);swDrawingDoc = (DrawingDoc)swModelDoc;// Set document background processing to application settingswDrawingDoc.BackgroundProcessingOption = (int)swBackgroundProcessOption_e.swBackgroundProcessing_DeferToApplication;}public void AttachEventHandlers(){AttachSWEvents();}public void AttachSWEvents(){swApp.BackgroundProcessingStartNotify += this.mySwApp_BackgroundProcessingStartNotify;swApp.BackgroundProcessingEndNotify += this.mySwApp_BackgroundProcessingEndNotify;}private int mySwApp_BackgroundProcessingStartNotify(string filename){MessageBox.Show("Background processing start event fired");return 1;}private int mySwApp_BackgroundProcessingEndNotify(string filename){MessageBox.Show("Background processing end event fired");swApp.EnableBackgroundProcessing = false;return 1;}public void CheckBox1_Click(object sender, System.EventArgs e){checkBoxClicked = true;}private void button1_Click(object sender, EventArgs e){this.Close();}} }

Sheet Sheet( System.string Name) {get;}

This example shows how to get each sheet in a multi-sheet drawing document regardless whether the sheet is loaded.//---------------------------------------------------------------------- // Preconditions: // 1. Click File > Open. // 2. Open public_documents\samples\tutorial\advdrawings\foodprocessor.sldrw. // 3. Click Select sheets to open > Selected > Sheet1* (load) > OK >Open. // 4. Open the Immediate window. // // Postconditions: // 1. Loads Sheet1 only. // 2. Mouse over Sheet2, Sheet3, and Sheet4 tabs and examine the // Immediate window. // // NOTE: Because this drawing is used elsewhere, do not save changes. //--------------------------------------------------------------------- using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System; using System.Diagnostics;namespace SheetDrawingDocCSharp.csproj {partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);DrawingDoc swDraw = default(DrawingDoc);string[] vSheetName = null;int i = 0;bool bRet = false;string sheetName; swModel = (ModelDoc2)swApp.ActiveDoc;swDraw = (DrawingDoc)swModel; // Get the sheets in the drawing document vSheetName = (string[])swDraw.GetSheetNames();// Traverse the sheets and determine whether // they're loaded for (i = 0; i < vSheetName.Length; i++){sheetName = (string)vSheetName[i];bRet = swDraw.ActivateSheet(sheetName);Sheet swSheet = default(Sheet);swSheet = (Sheet)swDraw.get_Sheet(vSheetName[i]);if ((swSheet.IsLoaded())){Debug.Print(vSheetName[i] + " is loaded.");}else{Debug.Print(vSheetName[i] + " is not loaded.");}}}/// <summary> /// The SldWorks swApp variable is pre-assigned for you. /// </summary> public SldWorks swApp;} }

方法

NameDescription備注
ActivateSheetActivates the specified drawing sheet. ?激活指定的圖紙。
ActivateViewActivates the specified drawing view. ?激活指定的圖紙視圖。
AddChamferDimAdds a chamfer dimension. ?添加倒角尺寸。
AddHoleCallout2Adds a?hole callout at the specified position to the hole whose edge is selected. ?將指定位置的孔標(biāo)注添加到其邊緣被選中的孔中。
AddLineStyleAdds a line style to the current drawing. ?向當(dāng)前圖形添加線型。
AlignHorzUses the selected edge to align the current drawing view. ?使用選定邊對(duì)齊當(dāng)前工程視圖。
AlignOrdinateAligns the ordinate dimension. ?對(duì)齊縱坐標(biāo)尺寸。
AlignVertUses the selected edge to align the current drawing view. ?使用選定邊對(duì)齊當(dāng)前工程視圖。
AttachAnnotationAttaches an existing annotation to a drawing sheet or view. ?將現(xiàn)有注釋附加到工程圖圖紙或視圖。
AttachDimensionsAttaches unattached dimensions. ?附加未附加的尺寸。
AutoBalloon5Automatically inserts BOM balloons in selected drawing views. ?在選定的工程視圖中自動(dòng)插入 BOM 球標(biāo)。
AutoDimensionAutomatically dimensions the selected drawing view. ?自動(dòng)標(biāo)注選定的工程視圖。
BreakViewBreaks the drawing view along the existing break lines. ?沿現(xiàn)有斷開線斷開工程視圖。
ChangeComponentLayerPuts the selected components on the specified layer. ?將選定的組件放在指定的層上。
ChangeOrdDirChanges the ordinate direction. ?改變縱坐標(biāo)方向。
ChangeRefConfigurationOfFlatPatternViewChanges the referenced configuration of the flat-pattern view. ?更改平面模式視圖的參考配置。
Create1stAngleViews2Creates standard three orthographic views (first angle projection) for the specified model. ?為指定模型創(chuàng)建標(biāo)準(zhǔn)的三個(gè)正交視圖(第一角度投影)。
Create3rdAngleViews2Creates standard three orthographic views (third angle projection) for the specified model. ?為指定模型創(chuàng)建標(biāo)準(zhǔn)的三個(gè)正交視圖(第三角度投影)。
CreateAngDim4Creates a non-associative angular dimension. ?創(chuàng)建非關(guān)聯(lián)角度尺寸。
CreateAutoBalloonOptionsCreates an object that stores auto balloon options. ?創(chuàng)建一個(gè)存儲(chǔ)自動(dòng)氣球選項(xiàng)的對(duì)象。
CreateAuxiliaryViewAt2Creates an auxiliary view based on a selected edge in a drawing view. ?基于工程視圖中的選定邊創(chuàng)建輔助視圖。
CreateBreakOutSectionCreates a broken-out section in a drawing document. ?在工程圖文檔中創(chuàng)建斷開的部分。
CreateConstructionGeometrySets?the selected sketch segments to?be construction geometry instead of sketch geometry. ?將選定的草圖段設(shè)置為構(gòu)造幾何體而不是草圖幾何體。
CreateDetailViewAt4Creates a detail view in a drawing document. ?在工程圖文檔中創(chuàng)建局部視圖。
CreateDiamDim4Creates a non-associative diameter dimension. ?創(chuàng)建非關(guān)聯(lián)直徑尺寸。
CreateDrawViewFromModelView3Creates a drawing view on the current drawing sheet using the specified model view. ?使用指定的模型視圖在當(dāng)前工程圖紙上創(chuàng)建工程視圖。
CreateFlatPatternViewFromModelView3Creates a flat-pattern view from a model view. ?從模型視圖創(chuàng)建平面圖案視圖。
CreateLayer2Creates a layer for this document. ?為此文檔創(chuàng)建一個(gè)圖層。
CreateLinearDim4Creates a non-associative linear dimension. ?創(chuàng)建非關(guān)聯(lián)線性標(biāo)注。
CreateOrdinateDim4Creates a non-associative ordinate dimension. ?創(chuàng)建非關(guān)聯(lián)的縱坐標(biāo)標(biāo)注。
CreateRelativeViewCreates a relative drawing?view. ?創(chuàng)建相對(duì)繪圖視圖。
CreateSectionViewCreates a section view in the drawing using the selected section line. ?使用選定的剖面線在工程圖中創(chuàng)建剖面視圖。
CreateSectionViewAt5Creates the specified section view. ?創(chuàng)建指定的剖面視圖。
CreateText2Creates a?note?containing the specified text at a given location. ?在給定位置創(chuàng)建包含指定文本的注釋。
CreateUnfoldedViewAt3Creates an unfolded drawing view from the selected drawing view and places it in the drawing at the specified location. ?從選定的圖紙視圖創(chuàng)建展開的圖紙視圖,并將其放置在圖紙中的指定位置。
CreateViewport3Creates a an empty view in a drawing. ?在工程圖中創(chuàng)建一個(gè)空視圖。
DeleteAllCosmeticThreadsDeletes all cosmetic threads, which do not have callouts,?in a drawing of an assembly only. ?僅在裝配體的工程圖中刪除所有沒有標(biāo)注的裝飾螺紋。
DeleteLineStyleDeletes the specified line style from the current drawing. ?從當(dāng)前圖形中刪除指定的線型。
DimensionsAdds dimensions to the drawing from model. ?從模型向工程圖中添加尺寸。
DragModelDimensionCopies or moves dimensions to a different drawing view. ?將尺寸復(fù)制或移動(dòng)到不同的工程視圖。
DrawingViewRotateRotates the selected drawing view. ?旋轉(zhuǎn)選定的工程視圖。
DropDrawingViewFromPalette2Moves the specified drawing view from the View Palette to the current drawing sheet. ?將指定的工程視圖從視圖調(diào)色板移動(dòng)到當(dāng)前工程圖紙。
EditCenterMarkPropertiesEdits center mark properties. ?編輯中心標(biāo)記屬性。
EditOrdinateEdits an ordinate dimension. ?編輯縱坐標(biāo)尺寸。
EditSelectedGtolGets the?selected GTol to edit. ?獲取要編輯的選定 GTol。
EditSheetPuts the current drawing sheet in edit mode. ?將當(dāng)前圖紙置于編輯模式。
EditSketchAllows editing of?a sketch?in?the selected drawing view or sheet. ?允許在選定的圖紙視圖或圖紙中編輯草圖。
EditTemplatePuts the template of the current drawing sheet in edit mode. ?將當(dāng)前圖紙的模板置于編輯模式。
EndDrawingProvides faster creation of entities in a drawing when used with?IDrawingDoc::StartDrawing. ?與 IDrawingDoc::StartDrawing 一起使用時(shí),可以更快地在繪圖中創(chuàng)建實(shí)體。
FeatureByNameGets?the specified feature in the drawing. ?獲取繪圖中的指定特征。
FlipSectionLineFlips the cut direction of the selected section line. ?翻轉(zhuǎn)選定剖面線的切割方向。
GenerateViewPaletteViewsAdds the specified document's predefined drawing views to the View Palette. ?將指定文檔的預(yù)定義工程視圖添加到視圖調(diào)色板。
GetCurrentSheetGets the currently active drawing sheet. ?獲取當(dāng)前活動(dòng)的圖紙。
GetDrawingPaletteViewNamesGets the names of drawing views in the View Palette for the active drawing sheet. ?獲取活動(dòng)圖紙的視圖調(diào)色板中圖紙視圖的名稱。
GetEditSheetGets whether the current drawing is in edit sheet mode or edit template mode. ?獲取當(dāng)前圖形是處于編輯圖紙模式還是編輯模板模式。
GetFirstViewGets the first drawing?view?on the current sheet. ?獲取當(dāng)前圖紙上的第一個(gè)繪圖視圖。
GetInsertionPointGets the current insertion (pick) point in a drawing. ?獲取繪圖中的當(dāng)前插入(拾取)點(diǎn)。
GetLineFontCount2Gets the a number line fonts supported by this drawing. ?獲取此繪圖支持的數(shù)字線字體。
GetLineFontIdGets the associated line font ID. ?獲取關(guān)聯(lián)的行字體 ID。
GetLineFontInfo2Gets the detailed information about the specified line font. ?獲取指定線條字體的詳細(xì)信息。
GetLineFontName2Gets the name of the specified line font. ?獲取指定線條字體的名稱。
GetLineStylesGets all of the line styles used in the current document. ?獲取當(dāng)前文檔中使用的所有線條樣式。
GetPenCountGets the number of pens currently defined in SOLIDWORKS. ?獲取當(dāng)前在 SOLIDWORKS 中定義的筆數(shù)。
GetPenInfoGets information about the pens used in SOLIDWORKS. ?獲取有關(guān) SOLIDWORKS 中使用的筆的信息。
GetSheetCountGets the number of drawing sheets in this drawing. ?獲取此繪圖中的繪圖頁數(shù)。
GetSheetNamesGets a list of the names of the drawing sheets in this drawing. ?獲取此圖紙中圖紙名稱的列表。
GetViewCountGets all of the number of all of?views, including the number of?sheets, in this drawing document. ?獲取此繪圖文檔中所有視圖的所有數(shù)量,包括圖紙數(shù)量。
GetViewsGets the all of the views, including the?sheets, in this drawing document. ?獲取此繪圖文檔中的所有視圖,包括圖紙。
HideEdgeHides selected visible edges in a drawing document. ?在工程圖文檔中隱藏選定的可見邊。
HideShowDimensionsSets whether to display?suppressed dimensions as dimmed and hide them. ?設(shè)置是否將抑制的尺寸顯示為灰色并隱藏它們。
HideShowDrawingViewsSets whether to hide or show hidden drawing views. ?設(shè)置是隱藏還是顯示隱藏的工程視圖。
IAddChamferDimAdds a chamfer dimension. ?添加倒角尺寸。
IAddHoleCallout2Adds a?hole callout at the specified position to the hole whose edge is selected. ?將指定位置的孔標(biāo)注添加到其邊緣被選中的孔中。
ICreateAngDim4Creates a non-associative angular dimension. ?創(chuàng)建非關(guān)聯(lián)角度尺寸。
ICreateAuxiliaryViewAt2Creates an auxiliary view based on a selected edge in a drawing view. ?基于工程視圖中的選定邊創(chuàng)建輔助視圖。
ICreateDiamDim4Creates a non-associative diameter dimension. ?創(chuàng)建非關(guān)聯(lián)直徑尺寸。
ICreateLinearDim4Creates a non-associative linear dimension. ?創(chuàng)建非關(guān)聯(lián)線性標(biāo)注。
ICreateOrdinateDim4Creates a non-associative ordinate dimension. ?創(chuàng)建非關(guān)聯(lián)的縱坐標(biāo)標(biāo)注。
ICreateSectionViewAt5Creates a section view from the section line?up to the specified distance at the specified distance. ?在指定距離處創(chuàng)建從剖面線到指定距離的剖面視圖。
ICreateText2Creates a?note?containing the specified text at a given location. ?在給定位置創(chuàng)建包含指定文本的注釋。
IEditSelectedGtolGets the?selected GTol to edit. ?獲取要編輯的選定 GTol。
IFeatureByNameGets?the specified feature in the drawing. ?獲取繪圖中的指定特征。
IGetCurrentSheetGets the currently active drawing sheet. ?獲取當(dāng)前活動(dòng)的圖紙。
IGetFirstViewGets the first drawing?view?on the current sheet. ?獲取當(dāng)前圖紙上的第一個(gè)繪圖視圖。
IGetInsertionPointGets the current insertion (pick) point in a drawing. ?獲取繪圖中的當(dāng)前插入(拾取)點(diǎn)。
IGetPenInfoGets information about the pens used in SOLIDWORKS. ?獲取有關(guān) SOLIDWORKS 中使用的筆的信息。
IGetSheetNamesGets a list of the names of the drawing sheets in this drawing. ?獲取此圖紙中圖紙名稱的列表。
IInsertDowelSymbolInserts a dowel pin symbol on the currently selected edge or edges. ?在當(dāng)前選定的一條或多條邊上插入定位銷符號(hào)。
IInsertMultiJogLeader3Inserts a multi-jog leader. ?插入多轉(zhuǎn)折引線。
IInsertRevisionCloudInserts a revision cloud annotation with the specified shape into a view or sheet. ?將具有指定形狀的修訂云線注釋插入到視圖或圖紙中。
INewGtolCreates a new GTol. ?創(chuàng)建一個(gè)新的幾何公差。
InsertAngularRunningDimInserts an angular running dimension into this drawing. ?在此工程圖中插入角度運(yùn)行尺寸。
InsertBaseDimInserts the base model dimensions into this drawing. ?將基礎(chǔ)模型尺寸插入此工程圖中。
InsertBreakHorizontalInserts a horizontal break in the drawing view. ?在工程視圖中插入水平中斷。
InsertBreakVerticalInserts a vertical break in this drawing. ?在此圖形中插入垂直中斷。
InsertCenterLine2Inserts a centerline on the selected entities. ?在選定實(shí)體上插入中心線。
InsertCenterMark3Inserts a center mark in a drawing document. ?在工程圖文檔中插入中心標(biāo)記。
InsertCircularNotePatternInserts a circular note pattern using the selected?note. ?使用所選筆記插入圓形筆記模式。
InsertDowelSymbolInserts a dowel pin symbol on the currently selected edge or edges in this drawing. ?在此圖形中當(dāng)前選定的一條或多條邊上插入定位銷符號(hào)。
InsertGroupInserts the currently selected items into a group (or view). ?將當(dāng)前選定的項(xiàng)目插入到一個(gè)組(或視圖)中。
InsertHorizontalOrdinateInserts a horizontal ordinate dimension into this drawing. ?在此圖形中插入水平坐標(biāo)尺寸。
InsertLinearNotePatternInserts a linear note pattern using the selected?note. ?使用選定的音符插入線性音符模式。
InsertModelAnnotations3Inserts model annotations into this drawing document in the currently selected drawing view. ?在當(dāng)前選定的工程圖視圖中將模型注釋插入到此工程圖文檔中。
InsertModelDimensionsInserts model dimensions into the selected drawing view according to the option specified. ?根據(jù)指定的選項(xiàng)將模型尺寸插入選定的工程視圖中。
InsertModelInPredefinedViewInserts the model into the predefined drawing views in the active drawing sheet. ?將模型插入到活動(dòng)圖紙中的預(yù)定義圖紙視圖中。
InsertMultiJogLeader3Inserts a multi-jog leader. ?插入多轉(zhuǎn)折引線。
InsertNewNote2Creates a new note in this drawing. ?在此繪圖中創(chuàng)建一個(gè)新注釋。
InsertOrdinateInserts an ordinate dimension into this drawing. ?在此工程圖中插入縱坐標(biāo)尺寸。
InsertRefDimInserts reference dimensions in this drawing. ?在此工程圖中插入?yún)⒖汲叽纭?/span>
InsertRevisionCloudInserts a revision cloud annotation with the specified shape into a view or sheet. ?將具有指定形狀的修訂云線注釋插入到視圖或圖紙中。
InsertRevisionSymbolInserts a revision symbol note in this drawing. ?在此工程圖中插入修訂符號(hào)注釋。
InsertTableAnnotation2Inserts a table annotation in this drawing. ?在此圖形中插入表格注釋。
InsertThreadCalloutInserts a thread callout into this drawing. ?在此圖形中插入螺紋標(biāo)注。
InsertVerticalOrdinateInserts a vertical ordinate dimension in this drawing. ?在此圖形中插入垂直縱坐標(biāo)尺寸。
InsertWeldSymbolCreates a weld symbol located at the last edge selection. ?在最后一個(gè)邊選擇處創(chuàng)建一個(gè)焊接符號(hào)。
IReorderSheetsReorders the drawing sheets per their positions in the input array. ?根據(jù)它們?cè)谳斎霐?shù)組中的位置對(duì)圖紙重新排序。
IsolateChangedDimensionsIsolates changed dimensions. ?隔離更改的尺寸。
LoadLineStylesLoads the specified line styles into the current drawing. ?將指定的線型加載到當(dāng)前圖形中。
MakeSectionLineMakes a section line from a set of connected sketch lines. ?從一組連接的草圖線制作剖面線。
ModifySurfaceFinishSymbolModifies the selected surface finish symbol. ?修改選定的表面粗糙度符號(hào)。
NewGtolCreates a new GTol object and returns the pointer to that object. ?創(chuàng)建一個(gè)新的 GTol 對(duì)象并返回指向該對(duì)象的指針。
NewNoteCreates a new note at the selected location. ?在選定位置創(chuàng)建新筆記。
NewSheet4Creates a new drawing sheet in this drawing document. ?在此工程圖文檔中創(chuàng)建新的工程圖圖紙。
OnComponentPropertiesDisplays the?Component Properties?dialog for the selected view. ?顯示所選視圖的組件屬性對(duì)話框。
PasteSheetCopies and pastes a drawing sheet?to the specified location of the drawing document, optionally renaming whenever duplicate names occur. ?將工程圖復(fù)制并粘貼到工程圖文檔的指定位置,可以在出現(xiàn)重復(fù)名稱時(shí)選擇重命名。
ReorderSheetsReorders the drawing sheets per their positions in the input array. ?根據(jù)它們?cè)谳斎霐?shù)組中的位置對(duì)圖紙重新排序。
ReplaceViewModelReplaces the specified instances of a model in the specified drawing views. ?替換指定工程視圖中模型的指定實(shí)例。
ResolveOutOfDateLightWeightComponentsResolves out-of-date lightweight components in the selected drawing view or drawing sheet. ?解決選定工程視圖或工程圖紙中過時(shí)的輕化零部件。
RestoreRotationRestores rotation for the selected drawing view. ?恢復(fù)選定工程視圖的旋轉(zhuǎn)。
SaveLineStylesExports to a file the specified line styles in the current drawing. ?將當(dāng)前圖形中指定的線型導(dǎo)出到文件。
SetCurrentLayerSets the current layer used by this document. ?設(shè)置此文檔使用的當(dāng)前層。
SetLineColorSets the line color for a selected edge or sketch entity. ?設(shè)置選定邊線或草圖實(shí)體的線條顏色。
SetLineStyleSets the style or font for the line for a selected edge or sketch entity. ?為選定邊線或草圖實(shí)體設(shè)置線條的樣式或字體。
SetLineWidthSets the line thickness for a selected edge or sketch entity to a SOLIDWORKS-supplied weight (width). ?將選定邊線或草圖實(shí)體的線寬設(shè)置為 SOLIDWORKS 提供的粗細(xì)(寬度)。
SetLineWidthCustomSets the line thickness to the specified custom width for a selected edge or sketch entity. ?將線條粗細(xì)設(shè)置為選定邊線或草圖實(shí)體的指定自定義寬度。
SetSheetsSelectedSets the specified drawing sheets whose setups to modify. ?設(shè)置要修改其設(shè)置的指定圖紙。
SetupSheet6Sets up?the specified?drawing sheet. ?設(shè)置指定的圖紙。
SheetNextMoves to the next sheet in the drawing. ?移動(dòng)到工程圖中的下一張圖紙。
SheetPreviousReturns to the previous sheet in a drawing. ?返回到工程圖中的上一張圖紙。
ShowEdgeShows the selected hidden edges in a drawing document. ?顯示工程圖文檔中選定的隱藏邊。
SketchDimInserts a sketch dimension in this drawing. ?在此工程圖中插入草圖尺寸。
StartDrawingProvides faster creation of entities within a drawing. ?提供在繪圖中更快地創(chuàng)建實(shí)體。
SuppressViewHides the selected drawing view. ?隱藏選定的工程視圖。
TranslateDrawingTranslates the entire drawing. ?翻譯整個(gè)繪圖。
UnBreakViewRemoves a break in the selected drawing view. ?刪除選定工程視圖中的中斷。
UnsuppressViewHides the selected drawing view. ?隱藏選定的工程視圖。
ViewDisplayHiddenSets the current display mode?to?Hidden Lines Removed. ?將當(dāng)前顯示模式設(shè)置為隱藏線已刪除。
ViewDisplayHiddengreyedSets the current display mode to?Hidden Lines Visible. ?將當(dāng)前顯示模式設(shè)置為隱藏線可見。
ViewDisplayShadedSets the current display mode to?Shaded. ?將當(dāng)前顯示模式設(shè)置為陰影。
ViewDisplayWireframeSets the current display mode to?Wireframe. ?將當(dāng)前顯示模式設(shè)置為線框。
ViewFullPageFits the drawing to the full page. ?使繪圖適合整頁。
ViewHlrQualityToggles the?Hidden Lines Removed?mode for the drawing view. ?切換繪圖視圖的隱藏線刪除模式。
ViewModelEdgesToggles the mode for viewing model edges when in shaded mode. ?在著色模式下切換查看模型邊緣的模式。
ViewTangentEdgesToggles display of tangent edges in the selected drawing view. ?在選定工程視圖中切換相切邊的顯示。

System.bool ActivateSheet( System.string Name)

This example shows how to copy and paste drawing sheets. //---------------------------------------------------------- // Preconditions: // 1. Open a drawing document containing one sheet // named Sheet1. // 2. Open the Immediate window. // // Postconditions: // 1. Activates Sheet1. // 2. Copy and pastes Sheet1 as Sheet1(2) and activates Sheet1(2). // 3. Copy and pastes Sheet1 as Sheet1(3) and activates Sheet1(3). // 4. Examine the FeatureManager design tree and 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(){DrawingDoc Part = default(DrawingDoc);ModelDoc2 swModel = default(ModelDoc2);bool boolstatus = false;swModel = (ModelDoc2)swApp.ActiveDoc;Part = (DrawingDoc)swModel;if ((Part == null)){Debug.Print(" Please open a drawing document. ");return;}Sheet currentsheet = default(Sheet);currentsheet = (Sheet)Part.GetCurrentSheet();Part.ActivateSheet(currentsheet.GetName());Debug.Print("Active sheet: " + currentsheet.GetName());boolstatus = swModel.Extension.SelectByID2("Sheet1", "SHEET", 0.09205356547875, 0.10872368523, 0, false, 0, null, 0);swModel.EditCopy();boolstatus = Part.PasteSheet((int)swInsertOptions_e.swInsertOption_BeforeSelectedSheet, (int)swRenameOptions_e.swRenameOption_No);currentsheet = (Sheet)Part.GetCurrentSheet();Part.ActivateSheet(currentsheet.GetName());Debug.Print("Active sheet: " + currentsheet.GetName());boolstatus = swModel.Extension.SelectByID2("Sheet1", "SHEET", 0.09205356547875, 0.10872368523, 0, false, 0, null, 0);swModel.EditCopy();boolstatus = Part.PasteSheet((int)swInsertOptions_e.swInsertOption_AfterSelectedSheet, (int)swRenameOptions_e.swRenameOption_No);currentsheet = (Sheet)Part.GetCurrentSheet();Part.ActivateSheet(currentsheet.GetName());Debug.Print("Active sheet: " + currentsheet.GetName());}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} } This example shows how to determine which sheets in a drawing are loaded.//---------------------------------------------- // Preconditions: // 1. Click File > Open. // 2. Browse to public_documents\samples\tutorial\advdrawings. // 3. Select foodprocessor.slddrw. // 4. Click Select sheets to open > Selected > Sheet1* (Load) > OK > Open. // 5. Open the Immediate window. // // Postconditions: // 1. Loads Sheet1 only. // 2. Mouse over the Sheet2, Sheet3, and Sheet4 tabs and // examine the Immediate window to verify step 1. // // NOTE: Because this drawing is used elsewhere, do not save // changes. //----------------------------------------------using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System; using System.Diagnostics; namespace IsLoadedSheetCSharp.csproj {partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);DrawingDoc swDraw = default(DrawingDoc);object[] vSheetName = null;int i = 0;bool bRet = false;string sheetName;swModel = (ModelDoc2)swApp.ActiveDoc;swDraw = (DrawingDoc)swModel;// Get the sheets in the drawing document vSheetName = (object[])swDraw.GetSheetNames(); // Traverse the sheets and determine whether // they're loaded for (i = 0; i < vSheetName.Length; i++){sheetName = (string)vSheetName[i];bRet = swDraw.ActivateSheet(sheetName);Sheet swSheet = default(Sheet);swSheet = (Sheet)swDraw.GetCurrentSheet();if ((swSheet.IsLoaded())){Debug.Print(vSheetName[i] + " is loaded.");}else{Debug.Print(vSheetName[i] + " is not loaded.");}}}/// <summary> /// The SldWorks swApp variable is pre-assigned for you. /// </summary> public SldWorks swApp;} }

System.bool ActivateView( System.string ViewName)

This example demonstrates firing Undo pre- and post-notification events in a drawing document.//--------------------------------------------------------------------------- // Preconditions: Open public_documents\samples\tutorial\AutoCAD\7550-021.slddrw. // // Postconditions: // 1. Selects and deletes the note in Drawing View1. // 2. Undoes the deleted note. // 3. Fires pre-notification event indicating that an undo action is about to // occur and fires post-notification event indicating that an undo // action occurred. // 4. Click OK to close each message box. // // NOTE: Because the drawing is used elsewhere, do not save changes. //---------------------------------------------------------------------------using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System; using System.Collections; using System.Windows.Forms;namespace UndoPostNotifyDrawingCSharp.csproj { partial class SolidWorksMacro {public DrawingDoc swDrawing;public void Main(){ModelDoc2 swModel = default(ModelDoc2);ModelDocExtension swModelDocExt = default(ModelDocExtension);bool boolstatus = false;Hashtable openDrawing = default(Hashtable);swModel = (ModelDoc2)swApp.ActiveDoc;swModelDocExt = (ModelDocExtension)swModel.Extension; // Event notification swDrawing = (DrawingDoc)swModel;openDrawing = new Hashtable();AttachEventHandlers(); // Activate the drawing view that contains // the note you want to delete boolstatus = swDrawing.ActivateView("Drawing View3");boolstatus = swModelDocExt.SelectByID2("DetailItem77@Drawing View3", "NOTE", 0.3058741216774, 0.1870419466786, 0, false, 0, null, 0); // Delete the selected note swModel.EditDelete(); // Undo deletion of note swModel.EditUndo2(1); // Post-notification is fired // Rebuild the drawing swModel.ForceRebuild3(true);} public void AttachEventHandlers(){AttachSWEvents();}public void AttachSWEvents(){swDrawing.UndoPostNotify += this.swDrawing_UndoPostNotify;swDrawing.UndoPreNotify += this.swDrawing_UndoPreNotify;} private int swDrawing_UndoPostNotify(){// Display message after Undo// NOTE: Because the message box may be displayed // behind an opened window, you might not see it. // If so, then check the Taskbar. MessageBox.Show("An undo post-notification event has been fired.");return 1;} private int b(){// Display message after Undo// NOTE: Because the message box may be displayed // behind an opened window, you might not see it. // If so, then check the Taskbar. MessageBox.Show("An Undo pre-notification event has been fired.");return 1;} /// <summary> /// The SldWorks swApp variable is pre-assigned for you. /// </summary> public SldWorks swApp; } } //This example shows how to automatically insert a model's dimensions marked for drawings //into a drawing.//--------------------------------------------------------------------------- // Preconditions: // 1. Assembly document to open exists. // 2. Run the macro. // // Postconditions: // 1. A new drawing document is opened. // 2. A drawing view of the assembly document is created. // 3. The dimensions in the assembly document that are marked for drawings, // including any duplicate dimensions, appear in the drawing view. // 4. The dimensions in the drawing, which are annotations, // are selected and marked. //--------------------------------------------------------------------------- using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System;namespace SelectAnnotationsCSharp.csproj {public partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel;ModelDocExtension swModelDocExt;DrawingDoc swDrawing;SelectionMgr swSelmgr;View swView;object[] annotations;object selAnnot;Annotation swAnnotation;SelectData swSelData;int mark;string retval;bool status;retval = swApp.GetUserPreferenceStringValue((int)swUserPreferenceStringValue_e.swDefaultTemplateDrawing);swModel = (ModelDoc2)swApp.NewDocument(retval, 0, 0, 0);swDrawing = (DrawingDoc)swModel;swModelDocExt = (ModelDocExtension)swModel.Extension;swSelmgr = (SelectionMgr)swModel.SelectionManager;// Create drawing from assemblyswView = (View)swDrawing.CreateDrawViewFromModelView3("C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\wrench.sldasm", "*Front", 0.1314541543147, 0.1407887187817, 0);// Select and activate the viewstatus = swModelDocExt.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, false, 0, null, 0);status = swDrawing.ActivateView("Drawing View1");swModel.ClearSelection2(true);// Insert the annotations marked for the drawingannotations = (object[])swDrawing.InsertModelAnnotations3((int)swImportModelItemsSource_e.swImportModelItemsFromEntireModel, (int)swInsertAnnotation_e.swInsertDimensionsMarkedForDrawing, true, false, false, false);// Select and mark each annotationswSelData = swSelmgr.CreateSelectData();mark = 0;foreach (object annot in annotations){selAnnot = annot;swAnnotation = (Annotation)selAnnot;status = swAnnotation.Select3(true, swSelData);swSelData.Mark = mark;mark = mark + 1;}}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

System.bool AttachAnnotation( System.int Option)

//This example shows how to attach an existing annotation to a drawing view.//---------------------------------------------------------------------------- // Preconditions: Open public_documents\samples\tutorial\api\replaceview.slddrw. // // Postconditions: // 1. Inserts a note annotation n the drawing. // 2. Selects the annotation. // 3. Appends a face in a drawing view to the selection list. // 4. Attaches the annotation to the selected face. // 5. Examine the drawing. // 6. Close the drawing without saving it. // --------------------------------------------------------------------------- using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System; namespace AttachAnnotation_CSharp.csproj {partial class SolidWorksMacro{ModelDoc2 part;DrawingDoc draw;Note aNote;Annotation anAnnot;SelectData selectData = null;int ret;bool boolstatus;public void Main(){part = (ModelDoc2)swApp.ActiveDoc;draw = (DrawingDoc)part;boolstatus = draw.ActivateSheet("Sheet1");aNote = (Note)draw.CreateText2("This is a note.", 0.21, 0.12, 0, 0.005, 0);anAnnot = (Annotation)aNote.GetAnnotation();ret = anAnnot.SetLeader3(swLeaderStyle_e.swBENT, swLeaderSide_e.swLS_SMART, true, false, false, false);anAnnot.Select3(false, selectData);boolstatus = draw.ActivateView("Drawing View1");boolstatus = part.Extension.SelectByID2("", "FACE", 0.0783563575357558, 0.17448024010205, -499.965138294658, true, 0, null, 0);draw.AttachAnnotation(swAttachAnnotationOption_e.swAttachAnnotationOption_View);}public SldWorks swApp;} }

System.object AutoBalloon5( AutoBalloonOptions BalloonOptions)

//This example shows how to automatically add BOM balloons to a drawing view.//------------------------------------------------------------------------------ // Preconditions: Open a drawing with a bill of materials (BOM) table. // // Postconditions: BOM balloons are added to the view. //------------------------------------------------------------------------------ using Microsoft.VisualBasic; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; namespace AutoBalloon_CSharp.csproj {partial class SolidWorksMacro{ModelDoc2 Part;DrawingDoc Draw;object vNotes;AutoBalloonOptions autoballoonParams;bool boolstatus;public void Main(){Part = (ModelDoc2)swApp.ActiveDoc;Draw = (DrawingDoc)Part;boolstatus = Draw.ActivateView("Drawing View1");boolstatus = Part.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, false, 0, null, 0);autoballoonParams = Draw.CreateAutoBalloonOptions();autoballoonParams.Layout = (int)swBalloonLayoutType_e.swDetailingBalloonLayout_Square;autoballoonParams.ReverseDirection = false;autoballoonParams.IgnoreMultiple = true;autoballoonParams.InsertMagneticLine = true;autoballoonParams.LeaderAttachmentToFaces = true;autoballoonParams.Style = (int)swBalloonStyle_e.swBS_Circular;autoballoonParams.Size = (int)swBalloonFit_e.swBF_5Chars;autoballoonParams.UpperTextContent = (int)swBalloonTextContent_e.swBalloonTextItemNumber;autoballoonParams.Layername = "-None-";autoballoonParams.ItemNumberStart = 1;autoballoonParams.ItemNumberIncrement = 1;autoballoonParams.ItemOrder = (int)swBalloonItemNumbersOrder_e.swBalloonItemNumbers_DoNotChangeItemNumbers;autoballoonParams.EditBalloons = true;autoballoonParams.EditBalloonOption = (int)swEditBalloonOption_e.swEditBalloonOption_Resequence;vNotes = Draw.AutoBalloon5(autoballoonParams);}public SldWorks swApp;} }

System.int AutoDimension(?
? ?System.int EntitiesToDimension,
? ?System.int HorizontalScheme,
? ?System.int HorizontalPlacement,
? ?System.int VerticalScheme,
? ?System.int VerticalPlacement)

//This example shows how to autodimension a selected drawing view.//----------------------------------------------------------------- // Preconditions: Verify that the specified drawing document to // open exists. // // Postconditions: // 1. Opens the specified drawing document. // 2. Activates Drawing View1. // 3. Selects a vertex. // 4. Autodimensions the drawing view based on the // selected vertex. // 5. Examine the drawing. // // NOTE: Because the drawing is used elsewhere, do not save changes. //------------------------------------------------------------------ using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System;namespace AutodimensionCSharp.csproj {public partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);DrawingDoc swDrawing = default(DrawingDoc);ModelDocExtension swModelDocExt = default(ModelDocExtension);bool status = false;string fileName = null;int errors = 0;int warnings = 0;int selmark = 0;int ret = 0;// Open drawing document of partfileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\advdrawings\\foodprocessor.slddrw";swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swDrawing = (DrawingDoc)swModel;status = swDrawing.ActivateView("Drawing View1");swModelDocExt = (ModelDocExtension)swModel.Extension;// Select drawing viewstatus = swModelDocExt.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, false, 0, null, 0);// Horizontal and vertical datum, or a vertex datum, baselines for// dimension creation// These are optional; if not selected, autodimension uses default datums,// the leftmost and bottommost edgesselmark = (int)swAutodimMark_e.swAutodimMarkHorizontalDatum;selmark = (int)swAutodimMark_e.swAutodimMarkVerticalDatum;selmark = (int)swAutodimMark_e.swAutodimMarkOriginDatum;// Select a vertexstatus = swModelDocExt.SelectByID2("", "VERTEX", 0.20215546544586, 0.2496899375, 0.00479999999998881, true, selmark, null, 0);// Autodimensions the drawing view based on the selected vertexret = swDrawing.AutoDimension((int)swAutodimEntities_e.swAutodimEntitiesBasedOnPreselect, (int)swAutodimScheme_e.swAutodimSchemeBaseline, (int)swAutodimHorizontalPlacement_e.swAutodimHorizontalPlacementAbove, (int)swAutodimScheme_e.swAutodimSchemeBaseline, (int)swAutodimVerticalPlacement_e.swAutodimVerticalPlacementRight);}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

void BreakView()

//This example shows how to create and remove a broken view.//---------------------------------------------------------------------------- // Preconditions: // 1. Verify that the specified file to open exists. // 2. Open the Immediate window. // // Postconditions: // 1. Opens the specified drawing and selects Drawing View1. // 2. Examine the drawing, then press F5. // 3. Inserts break lines in Drawing View1. // 4. Examine the drawing, then press F5. // 5. Modifies the positions of the break lines and breaks the view. // 6. Examine the drawing, then press F5. // 7. Removes the break from Drawing View1. // 8. Examine the drawing and the Immediate window. // // NOTE: Because this drawing document is used elsewhere, // do not save changes. //---------------------------------------------------------------------------- using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System; using System.Diagnostics;namespace BreakViewDrawingDocCSharp.csproj {public partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel;DrawingDoc swDrawingDoc;ModelDocExtension swModelDocExt;SelectionMgr swSelectionManager;SelectData swSelectData;View swView;BreakLine swBreakLine;string fileName;bool status;int errors = 0;int warnings = 0;fileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\box.slddrw";swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swModel = (ModelDoc2)swApp.ActiveDoc;swDrawingDoc = (DrawingDoc)swModel;swModelDocExt = (ModelDocExtension)swModel.Extension;// Activate and select the view to breakstatus = swDrawingDoc.ActivateView("Drawing View1");status = swModelDocExt.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, false, 0, null, 0);swSelectionManager = (SelectionMgr)swModel.SelectionManager; swSelectData = (SelectData)swSelectionManager.CreateSelectData();swView = (View)swSelectionManager.GetSelectedObject6(1, -1);System.Diagnostics.Debugger.Break();// Examine the drawing; press F5// Insert the break linesswBreakLine = (BreakLine)swView.InsertBreak(0, -0.0291950859897372, 0.0198236302285804, 1);System.Diagnostics.Debugger.Break();// Break lines inserted; press F5// Reset position of break linesstatus = swBreakLine.SetPosition(-0.03, 0.05);swModel.EditRebuild3Debug.Print("Break line: ");Debug.Print(" Selected: " + swBreakLine.Select(true, null));Debug.Print(" Style: " + swBreakLine.Style);Debug.Print(" Orientation: " + swBreakLine.Orientation);Debug.Print(" Position: " + swBreakLine.GetPosition(0));swDrawingDoc.BreakView();System.Diagnostics.Debugger.Break();// Positions of the break lines are modified, and view is broken// Press F5status = swModelDocExt.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, false, 0, null, 0);swDrawingDoc.UnBreakView();// Break is removed}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

void ChangeComponentLayer(?
? ?System.string Layername,
? ?System.bool AllViews)

This example shows how to create a layer for the part in the selected drawing view.'---------------------------------------------------------------------------- ' Preconditions: ' 1. Open a drawing of a part. ' 2. Select a drawing view in the FeatureManager design tree. ' 3. Open the Immediate window. ' ' Postconditions: ' 1. Creates a layer for the part in the selected drawing view. ' 2. Click the Layer Properties tool on the Line Format toolbar to verify ' that the newly created layer is selected in the Layers dialog box. ' 3. Examine the Immediate window. '---------------------------------------------------------------------------- Option ExplicitPrivate Sub ChangeComponentLayer _ ( _swApp As SldWorks.SldWorks, _swDraw As SldWorks.DrawingDoc, _sLayerName As String _ )Dim bRet As Boolean' Form a valid layer namesLayerName = Replace(sLayerName, "/", "_")sLayerName = Replace(sLayerName, "@", "_")bRet = swDraw.CreateLayer2( _sLayerName, _"Layer for part in " & sLayerName, _0, swLineCONTINUOUS, swLW_NORMAL, True, True)' Change in all drawing viewsswDraw.ChangeComponentLayer sLayerName, TrueEnd SubSub main()Dim swApp As SldWorks.SldWorksDim swModel As SldWorks.ModelDoc2Dim swDraw As SldWorks.DrawingDocDim swSelMgr As SldWorks.SelectionMgrDim swView As SldWorks.ViewDim swDrawModel As SldWorks.ModelDoc2Dim swDrawPart As SldWorks.PartDocDim vBody As VariantDim swBody As SldWorks.Body2Dim swFace As SldWorks.Face2Dim swEnt As SldWorks.EntityDim nErrors As LongDim nWarnings As LongDim bRet As BooleanSet swApp = Application.SldWorksSet swModel = swApp.ActiveDocSet swDraw = swModelSet swSelMgr = swModel.SelectionManagerSet swView = swSelMgr.GetSelectedObject6(1, -1)Set swDrawModel = swApp.OpenDoc6(swView.GetReferencedModelName, swDocPART, swOpenDocOptions_Silent, "", nErrors, nWarnings)Set swDrawPart = swDrawModelDebug.Print "File = " & swModel.GetPathNameDebug.Print " View = " & swView.NameDebug.Print " View Model = " & swView.GetReferencedModelNamevBody = swDrawPart.GetBodies2(swSolidBody, True)Set swBody = vBody(0)Set swFace = swBody.GetFirstFaceSet swEnt = swFacebRet = swView.SelectEntity(swEnt, False)ChangeComponentLayer swApp, swDraw, swView.NameEnd Sub

System.object CreateDetailViewAt4(?
? ?System.double X,
? ?System.double Y,
? ?System.double Z,
? ?System.int Style,
? ?System.double Scale1,
? ?System.double Scale2,
? ?System.string LabelIn,
? ?System.int Showtype,
? ?System.bool FullOutline,
? ?System.bool JaggedOutline,
? ?System.bool NoOutline,
? ?System.int ShapeIntensity)

//This example shows how to create a detail circle and a detail view.//--------------------------------------------------------------------------- // Preconditions: // 1. Verify that the drawing to open exists. // 2. Open the Immediate window. // // Postconditions: // 1. Opens the specified drawing. // 2. Activates Drawing View4. // 3. Creates a detail circle and a detail view using the visible // corner of Drawing View4. // 4. Activates the detail view. // 5. Gets and sets some properties of the detail circle and detail view. // 6. Examine the drawing document and Immediate window. // // NOTE: Because the drawing is used elsewhere, do not save changes. //------------------------------------------------------------------------------ using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System; using System.Diagnostics;namespace Macro1CSharp.csproj {partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);DrawingDoc swDrawing = default(DrawingDoc);SketchManager swSketchManager = default(SketchManager);SketchSegment swSketchSegment = default(SketchSegment);View swView = default(View);DetailCircle swDetailCircle = default(DetailCircle);SelectionMgr swSelMgr = default(SelectionMgr);SelectData swSelData = default(SelectData);string fileName = null;bool status = false;int errors = 0;int warnings = 0;// Open drawingfileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\replaceview.slddrw";swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swDrawing = (DrawingDoc)swModel;swSelMgr = (SelectionMgr)swModel.SelectionManager;swSelData = (SelectData)swSelMgr.CreateSelectData();swApp.ActivateDoc3("replaceview - Sheet1", false, (int)swRebuildOnActivation_e.swDontRebuildActiveDoc, ref errors);// Activate Drawing View4 and create detail circle and detail viewstatus = swDrawing.ActivateView("Drawing View4");swSketchManager = (SketchManager)swModel.SketchManager;swSketchSegment = (SketchSegment)swSketchManager.CreateCircle(0.007581, 0.053509, 0.0, 0.013533, 0.016475, 0.0);swView = (View)swDrawing.CreateDetailViewAt4(0.22305342706156, 0.0762140266484527, 0, (int)swDetViewStyle_e.swDetViewSTANDARD, 1, 1, "A", (int)swDetCircleShowType_e.swDetCircleCIRCLE, true, true, false, 5);swModel.ClearSelection2(true);// Activate detail viewstatus = swDrawing.ActivateView("Drawing View5");// Get and set some properties of detail circle and detail viewswDetailCircle = (DetailCircle)swView.GetDetail();Debug.Print("Detail circle:");Debug.Print(" Selected: " + swDetailCircle.Select(true, null));Debug.Print(" Label: " + swDetailCircle.GetLabel());Double xpos;Double ypos;swDetailCircle.GetLabelPosition(out xpos, out ypos);Debug.Print(" Label X position: " + xpos);Debug.Print(" Label Y position: " + ypos);Debug.Print(" Type of circle: " + swDetailCircle.GetDisplay());Debug.Print(" Name: " + swDetailCircle.GetName());Debug.Print(" Style: " + swDetailCircle.GetStyle());Debug.Print(" Default document text formatting? " + swDetailCircle.GetUseDocTextFormat());if (swDetailCircle.NoOutline == false){Debug.Print(" No outline? False");if (swDetailCircle.JaggedOutline == true){swDetailCircle.ShapeIntensity = 2;Debug.Print(" Jagged outline and shape intensity? True and 2");} } }/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

System.bool CreateBreakOutSection(?
? ?System.double Depth)

//This example shows how to create a broken-out section in a drawing view.//---------------------------------------------------------------------------- // Preconditions: // 1. Open a drawing. // 2. Select Drawing View1. // // Postconditions: A broken-out section is created in Drawing View1 // using the specified closed spline. // --------------------------------------------------------------------------- using Microsoft.VisualBasic; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; namespace CreateBreakOutSection_CSharp.csproj {partial class SolidWorksMacro{ModelDoc2 Part;object pointArray;double[] points = new double[12];SketchSegment skSegment;SelectData selectData = null;DrawingDoc dDoc;public void Main(){Part = (ModelDoc2)swApp.ActiveDoc;points[0] = -0.0544316967839374;points[1] = 0.0413619530906299;points[2] = 0;points[3] = 0.0530556603589196;points[4] = 0.0413619530906299;points[5] = 0;points[6] = 0.00783232107320536;points[7] = 0.00720299635749822;points[8] = 0;points[9] = -0.0544316967839374;points[10] = 0.0413619530906299;points[11] = 0;pointArray = points;skSegment = Part.SketchManager.CreateSpline((pointArray));skSegment.Select4(true, selectData);dDoc = (DrawingDoc)Part;dDoc.CreateBreakOutSection(0.00254);Part.ClearSelection2(true);}public SldWorks swApp;}}

View CreateRelativeView(?
? ?System.string ModelName,
? ?System.double XPos,
? ?System.double YPos,
? ?System.int ViewDirFront,
? ?System.int ViewDirRight)

//This example shows how to create a relative drawing view.// ****************************************************************************** // Preconditions: // 1. Open public_documents\samples\tutorial\api\maingrip.sldprt. // 2. Select File > Make Drawing from Part. // 3. Run the macro. // // Postconditions: // 1. Iterates through the drawing views // in the View Palette and drops // *Current drawing view in the drawing. // 2. Activates the part. // 3. Selects two faces for the relative drawing view. // 4. Activates the drawing. // 5. Creates and inserts a relative drawing // view using the selected faces. // // NOTE: Because the part document is used elsewhere, do not // save any changes when closing it. // ******************************************************************************using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System;namespace CreateRelativeViewCSharp.csproj {partial class SolidWorksMacro{ModelDoc2 swModel;DrawingDoc swDrawing;View swView;ModelDocExtension swModelDocExt;string fileName;bool status;int errors;int warnings;int numViews;object[] viewNames;string viewName;string viewPaletteName;int i;public void Main(){swDrawing = (DrawingDoc)swApp.ActiveDoc;// Get number of views on View PalettenumViews = 0;viewNames = (object[])swDrawing.GetDrawingPaletteViewNames();// Iterate through views on View Palette// When view name equals *Current, drop// that view in drawingif (!((viewNames == null))){numViews = (viewNames.GetUpperBound(0) - viewNames.GetLowerBound(0));for (i = 0; i <= numViews; i++){viewPaletteName = (string)viewNames[i];if ((viewPaletteName == "*Current")){swView = (View)swDrawing.DropDrawingViewFromPalette2(viewPaletteName, 0.0, 0.0, 0.0);}}}// Activate the part document and// select two faces for the relative drawing viewswApp.ActivateDoc3("maingrip.sldprt", false, (int)swRebuildOnActivation_e.swUserDecision, ref errors);swModel = (ModelDoc2)swApp.ActiveDoc;swModelDocExt = (ModelDocExtension)swModel.Extension;swModel.ClearSelection2(true);status = swModelDocExt.SelectByID2("", "FACE", 0.0466263268498324, 0.00558799999987514, -0.00617351393179888, false, 1, null, 0);status = swModelDocExt.SelectByID2("", "FACE", 0.0504738910727269, 0.00167315253537481, -0.00496149996774875, true, 2, null, 0);// Activate the drawing document// Create and insert the relative drawing view using// the selected faces// Activate the relative drawing viewswApp.ActivateDoc3("maingrip - Sheet1", false, (int)swRebuildOnActivation_e.swUserDecision, ref errors);swDrawing = (DrawingDoc)swApp.ActiveDoc;fileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\maingrip.sldprt";swView = (View)swDrawing.CreateRelativeView(fileName, 0.203608914116486, 0.493530187561698, (int)swRelativeViewCreationDirection_e.swRelativeViewCreationDirection_FRONT, (int)swRelativeViewCreationDirection_e.swRelativeViewCreationDirection_RIGHT);status = swDrawing.ActivateView("Drawing View2");}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

View CreateSectionViewAt5(?
? ?System.double X,
? ?System.double Y,
? ?System.double Z,
? ?System.string SectionLabel,
? ?System.int Options,
? ?System.object ExcludedComponents,
? ?System.double SectionDepth)

//This example creates a section view and sets and gets some of the section view's data.//-------------------------------------------------------------------------- // Preconditions: // 1. Open public_documents\samples\tutorial\driveworksxpress\mobile gantry.slddrw // 2. Open the Immediate window. // // Postconditions: // 1. Creates a section view of Drawing View4. // 2. Sets and gets some section view settings. // 3. Examine the drawing and the Immediate window. // // NOTE: Because this drawing is used elsewhere, do not save changes. //-------------------------------------------------------------------------- using System; using System.Diagnostics; using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices;namespace CreateSectionView_CSharp.csproj {partial class SolidWorksMacro{ModelDoc2 swModel;DrawingDoc swDrawing;SketchManager swSketchMgr;SketchSegment swSketchSegment;object excludedComponents;View swView;DrSection swSectionView;bool boolstatus;public void Main(){swModel = (ModelDoc2)swApp.ActiveDoc;swDrawing = (DrawingDoc)swModel;// Activate the view for which you want to create a section viewboolstatus = swDrawing.ActivateView("Drawing View4");swModel.ClearSelection2(true);// Create section-view lineswSketchMgr = swModel.SketchManager;swSketchSegment = swSketchMgr.CreateLine(-1.383705, 2.078706, 0.0, 2.747162, 0.0441, 0.0);// Create the section view at the specified coordinates// and up to the specified distance from the section-view lineexcludedComponents = null;swView = swDrawing.CreateSectionViewAt5(0.1604082711061, 0.2048687170364, 0, "D", 32, (excludedComponents), 0.00835);Debug.Print("View data: ");Debug.Print(" Emphasize outlines of section views? " + swView.EmphasizeOutline);swSectionView = (DrSection)swView.GetSection();// Set some section-view settingsswSectionView.SetAutoHatch(true);swSectionView.SetLabel2("ABCD");swSectionView.SetDisplayOnlySurfaceCut(false);swSectionView.SetPartialSection(false);swSectionView.SetReversedCutDirection(false);swSectionView.SetScaleWithModelChanges(true);swSectionView.CutSurfaceBodies = true;swSectionView.DisplaySurfaceBodies = true;swSectionView.ExcludeSliceSectionBodies = false;// Get some section-view settingsDebug.Print("Section view data: ");Debug.Print(" Label: " + swSectionView.GetLabel());Debug.Print(" Name of section line: " + swSectionView.GetName());Debug.Print(" Depth: " + swSectionView.SectionDepth * 1000.0 + " mm");Debug.Print(" Cut direction reversed from default direction? " + swSectionView.GetReversedCutDirection());Debug.Print(" Partial section cut? " + swSectionView.GetPartialSection());Debug.Print(" Display only the surface cut by the section line? " + swSectionView.GetDisplayOnlySurfaceCut());Debug.Print(" Display surface bodies? " + swSectionView.DisplaySurfaceBodies);Debug.Print(" Exclude slice section bodies? " + swSectionView.ExcludeSliceSectionBodies);swSectionView.SetDisplayOnlySpeedPakBodies(true);Debug.Print(" Display only SpeedPak bodies? " + swSectionView.GetDisplayOnlySpeedPakBodies());Debug.Print(" Scale with model changes? " + swSectionView.GetScaleWithModelChanges());Debug.Print(" Auto-hatch enabled? " + swSectionView.GetAutoHatch());Debug.Print(" Hide cut surface bodies? " + swSectionView.CutSurfaceBodies);swModel.EditRebuild3();}public SldWorks swApp;} }

View CreateUnfoldedViewAt3(?
? ?System.double X,
? ?System.double Y,
? ?System.double Z,
? ?System.bool NotAligned)

//This example shows how to create an unfolded view from an existing view.//---------------------------------------------------------------------------- // Preconditions: Open: // public_documents\samples\tutorial\advdrawings\foodprocessor.slddrw // // Postconditions: A new unfolded view is created from Drawing View1. // // NOTE: Because the model is used elsewhere, // do not save changes when closing it. // --------------------------------------------------------------------------- using Microsoft.VisualBasic; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; namespace InsertUnfoldedView_CSharp.csproj {partial class SolidWorksMacro{ModelDoc2 Part;DrawingDoc ddoc;View myView;bool boolstatus;public void Main(){Part = (ModelDoc2)swApp.ActiveDoc;ddoc = (DrawingDoc)Part;boolstatus = Part.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, false, 0, null, 0);myView = ddoc.CreateUnfoldedViewAt3(0.379074752406062, 0.276482735105582, 0, false);}public SldWorks swApp;} }

System.bool DrawingViewRotate(?
? ?System.double NewAngle)

This example shows how to rotate the selected drawing view 45o.//--------------------------------------------------------------- // Preconditions: Verify that the specified file to open exists. // // Postconditions: Rotates the selected drawing view 45o. //---------------------------------------- ----------------------using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System;namespace DrawingViewRotateCSharp.csproj {partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);ModelDocExtension swModelDocExt = default(ModelDocExtension);DrawingDoc swDrawing = default(DrawingDoc);bool status = false;int errors = 0;int warnings = 0;swModel = (ModelDoc2)swApp.OpenDoc6("C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\driveworksxpress\\mobile gantry.slddrw", (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swModelDocExt = (ModelDocExtension)swModel.Extension;swModel.ViewZoomtofit2();swDrawing = (DrawingDoc)swModel;status = swDrawing.ActivateView("Drawing View4");status = swModelDocExt.SelectByID2("Drawing View4", "DRAWINGVIEW", 0.1122300799499, 0.1471819585104, 0, false, 0, null, 0);//Convert degrees to radians, the default system unit // 1 radian = 180o/p = 57.295779513o or approximately 57.3o status = swDrawing.DrawingViewRotate(45 / 57.3);}/// <summary> /// The SldWorks swApp variable is pre-assigned for you. /// </summary> public SldWorks swApp;}}

View DropDrawingViewFromPalette2(?
? ?System.string PaletteViewName,
? ?System.double X,
? ?System.double Y,
? ?System.double Z)

//This example shows how to get the number of lines in a flat-pattern drawing view's //boundary-box sketch.//---------------------------------------------------------- // Preconditions: // 1. Open public_documents\samples\tutorial\api\SMGussetAPI.SLDPRT. // 2. Create a new drawing document. // 3. Select SMGussetAPI.SLDPRT in the View // Palette's dropdown list box. // 4. Open the Immediate window. // // Postconditions: // 1. Examine the Immediate window and the drawing. // 2. If necessary, drag the drawing onto the drawing sheet // and zoom in on the drawing view. // // NOTE: Because the part is used elsewhere, do not save // changes. //--------------------------------------------------------- using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System; using System.Diagnostics;namespace GetSMBoundaryBoxDisplayDataViewCSharp.csproj {partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel;DrawingDoc swDrawing;View swView;Sheet swSheet;DisplayData swDisplayData;double[] sheetProperties = null;double sheetScale = 0;swDwgPaperSizes_e paperSize;double width = 0;double height = 0;long numViews = 0;object[] viewNames = null;string viewPaletteName = "";string drawingViewName = "";int i = 0;bool status = false;swModel = (ModelDoc2)swApp.ActiveDoc;swDrawing = (DrawingDoc)swModel;// Get current sheet swSheet = (Sheet)swDrawing.GetCurrentSheet();sheetProperties = (double[])swSheet.GetProperties();sheetScale = (double)sheetProperties[2] / sheetProperties[3];paperSize = (swDwgPaperSizes_e)swSheet.GetSize(ref width, ref height);// Get number of views on View Palette numViews = 0;viewNames = (object[])swDrawing.GetDrawingPaletteViewNames();// Iterate through views on View Palette // When view name equals "Flat pattern", drop // that view in drawing if (!((viewNames == null))){numViews = viewNames.GetUpperBound(0) - viewNames.GetLowerBound(0);for (i = 0; i <= numViews; i++){viewPaletteName = (string)viewNames[i];if ((viewPaletteName == "Flat pattern")){Debug.Print("Dropping View Palette view named: " + viewPaletteName);swView = (View)swDrawing.DropDrawingViewFromPalette2(viewPaletteName, 0.0, 0.0, 0.0);drawingViewName = swView.GetName2();Debug.Print("Dropped View Palette view into drawing view named: " + drawingViewName);}}}// Activate view and get number of lines in // its boundary box sketch status = swDrawing.ActivateView(drawingViewName);swView = (View)swDrawing.ActiveDrawingView;swDisplayData = (DisplayData)swView.GetSMBoundaryBoxDisplayData();Debug.Print("Number of lines in boundary box of flat-pattern drawing view: " + swDisplayData.GetLineCount());}/// <summary> /// The SldWorks swApp variable is pre-assigned for you. /// </summary> public SldWorks swApp;}}

void EditSheet()

This example shows how to place a note behind a drawing sheet.//---------------------------------------------------------- // Preconditions: // 1. Verify that the specified drawing file to open exists. // 2. Open the Immediate window. // // Postconditions: // 1. Places the selected note, 2012-sm in the drawing template, // behind the drawing sheet. // 2. To verify: // a. Examine the Immediate window. // b. Right-click the drawing and click // Edit Sheet Format. // c. Right-click 2012-sm and examine the // the short-cut menu to verify that Display // Note Behind Sheet is selected. // d. Exit drawing sheet edit mode. // // NOTE: Because this drawing is used elsewhere, do not // save changes. //-----------------------------------------------------------using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System; using System.Diagnostics;namespace NoteBehindSheetCSharp.csproj { partial class SolidWorksMacro{ public void Main(){ModelDoc2 swModel = default(ModelDoc2);ModelDocExtension swModelDocExt = default(ModelDocExtension);DrawingDoc swDrawing = default(DrawingDoc);SelectionMgr swSelectionMgr = default(SelectionMgr);Note swNote = default(Note);string fileName = null;bool status = false;int errors = 0;int warnings = 0;// Open drawingfileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\2012-sm.slddrw";swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swDrawing = (DrawingDoc)swModel;// Put drawing template and sheet in edit modeswModelDocExt = (ModelDocExtension)swModel.Extension;status = swModelDocExt.SelectByID2("Sheet1", "SHEET", 0.0399580396732789, 0.20594194865811, 0, false, 0, null, 0);swDrawing.EditTemplate();swDrawing.EditSheet();swModel.ClearSelection2(true);// Select note to place behind the sheetstatus = swModelDocExt.SelectByID2("DetailItem3@Sheet Format1", "NOTE", 0.155548914819136, 0.017885845974329, 0, false, 0, null, 0);swSelectionMgr = (SelectionMgr)swModel.SelectionManager;swNote = (Note)swSelectionMgr.GetSelectedObject6(1, -1);swNote.BehindSheet = true;Debug.Print("Was the selected note placed behind the sheet? " + status);}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

System.object FeatureByName( System.string Name)

//This example shows how to get and set the table anchor of a hole table in a drawing.//----------------------------------------------------------------- // Preconditions: Verify that the specified drawing to open exists. // // Postconditions: // 1. Opens the drawing. // 2. At System.Diagnostics.Debugger.Break(), examine the position // of the hole table in the drawing. // 3. Click the Continue button in the SOLIDWORKS Visual Studio Tools for // Applications IDE. // 4. Sets the position of the hole table's anchor // to the specified location. // 5. Examine the hole table in the drawing. // // NOTE: If prompted, do not save changes when closing the drawing. //------------------------------------------------------------------ using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System; using System.Diagnostics;namespace TableAnchorPositionCSharp.csproj {partial class SolidWorksMacro{public void Main(){string filename = null;filename = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\SimpleHole.slddrw";ModelDoc2 model = default(ModelDoc2);int errors = 0;int warnings = 0;model = (ModelDoc2)swApp.OpenDoc6(filename, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);if (model == null)return;System.Diagnostics.Debugger.Break();TableAnnotation swTable = default(TableAnnotation);// If document is a drawing, then continueswitch (model.GetType()){case (int)swDocumentTypes_e.swDocDRAWING:DrawingDoc drw = default(DrawingDoc);drw = (DrawingDoc)model;// Get the current sheetSheet drwSheet = default(Sheet);drwSheet = (Sheet)drw.GetCurrentSheet();// Select the Sheet2 featureModelDocExtension modeldocext = default(ModelDocExtension);bool status = false;modeldocext = (ModelDocExtension)model.Extension;status = modeldocext.SelectByID2("Sheet2", "SHEET", 0, 0, 0, false, 0, null, 0);// Get the views on Sheet2object[] views = null;views = (object[])drwSheet.GetViews();foreach (object vView in views){View drwView = default(View);drwView = (View)vView;Feature viewFeature = default(Feature);viewFeature = (Feature)drw.FeatureByName(drwView.Name);// Traverse the features in the viewFeature subFeature = default(Feature);subFeature = (Feature)viewFeature.GetFirstSubFeature();// If the feature is HoleTableFeat, then get the table annotationswhile (!(subFeature == null)){if (subFeature.GetTypeName2() == "HoleTableFeat"){HoleTable swHoleTable = default(HoleTable);swHoleTable = (HoleTable)subFeature.GetSpecificFeature2();object[] holeTables = null;holeTables = (object[])swHoleTable.GetTableAnnotations();// If the annotation is a hole table, then continueif ((holeTables != null)){foreach (object table in holeTables){swTable = (TableAnnotation)table;// If the hole table is anchored, then continueif (swTable.Type == (int)swTableAnnotationType_e.swTableAnnotation_HoleChart){if (swTable.Anchored != false){TableAnchor holeTableAnchor = default(TableAnchor);holeTableAnchor = (TableAnchor)drwView.Sheet.get_TableAnchor((int)swTableAnnotationType_e.swTableAnnotation_HoleChart);// Get the position of the table anchordouble[] anchorPosition = null;anchorPosition = (double[])holeTableAnchor.Position;// Determine type of table anchorswBOMConfigurationAnchorType_e newCorner = default(swBOMConfigurationAnchorType_e);string corner = null;switch (swTable.AnchorType){case (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_BottomLeft:corner = " Bottom-left ";newCorner = swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopRight;break;case (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_BottomRight:corner = " Bottom-right ";newCorner = swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft;break;case (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft:corner = " Top-left ";newCorner = swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_BottomRight;break;case (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopRight:corner = " Top-right ";newCorner = swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_BottomLeft;break;}swTable.AnchorType = (int)newCorner;// Set the new position of the table anchordouble[] dNewPosition = new double[2];dNewPosition[0] = 0.0;dNewPosition[1] = 0.0;holeTableAnchor.Position = dNewPosition;}}}}}subFeature = (Feature)subFeature.GetNextSubFeature();}}break;case (int)swDocumentTypes_e.swDocASSEMBLY:case (int)swDocumentTypes_e.swDocPART:break;}}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

System.bool GenerateViewPaletteViews( System.string FileName)

//This example shows how to get and set whether to hide cutting line shoulders in a //section view.//-------------------------------------------------------------------------- // Preconditions: // 1. Verify that the part and templates exist. // 2. Open the Immediate window. // // Postconditions: // 1. Opens the part. // 2. Creates a drawing of the part. // 3. Creates a section view. // 4. Gets and sets whether to hide cutting line shoulders in the section // view. // 5. Examine the Immediate window. // // NOTE: Because the part is used elsewhere, do not save it or the drawing. //-------------------------------------------------------------------------- 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);DrawingDoc swDrawing = default(DrawingDoc);Sheet swSheet = default(Sheet);View swView = default(View);ModelDocExtension swModelDocExt = default(ModelDocExtension);SketchSegment swSketchSegment = default(SketchSegment);SketchManager swSketchMgr = default(SketchManager);DrSection swSectionView = default(DrSection);bool status = false;int errors = 0;int warnings = 0;string fileName = null;double swSheetWidth = 0;double swSheetHeight = 0;string drawingTemplate = null;string sheetTemplate = null;//Open partfileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\cam roller.sldprt";swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);//Create drawing of partswSheetWidth = 1.189;swSheetHeight = 0.841;drawingTemplate = "C:\\ProgramData\\SolidWorks\\SOLIDWORKS 2017\\templates\\Drawing.drwdot";swDrawing = (DrawingDoc)swApp.NewDocument(drawingTemplate, (int)swDwgPaperSizes_e.swDwgPapersUserDefined, swSheetWidth, swSheetHeight);swSheet = (Sheet)swDrawing.GetCurrentSheet();swSheet.SetProperties2((int)swDwgPaperSizes_e.swDwgPapersUserDefined, (int)swDwgTemplates_e.swDwgTemplateCustom, 1, 2, false, swSheetWidth, swSheetHeight, true);sheetTemplate = "C:\\ProgramData\\SolidWorks\\SOLIDWORKS 2017\\lang\\english\\sheetformat\\a0 - iso.slddrt";swSheet.SetTemplateName(sheetTemplate);swSheet.ReloadTemplate(true);status = swDrawing.GenerateViewPaletteViews(fileName);swView = (View)swDrawing.DropDrawingViewFromPalette2("*Left", 0.580930433566434, 0.431525272727273, 0);//Create section viewswDrawing = (DrawingDoc)swApp.ActiveDoc;status = swDrawing.ActivateView("Drawing View1");swModel.ClearSelection2(true);swModel = (ModelDoc2)swDrawing;swSketchMgr = (SketchManager)swModel.SketchManager;swSketchSegment = (SketchSegment)swSketchMgr.CreateLine(0.0, 0.0, 0.0, 0.012168, 0.021283, 0.0);swSketchSegment = (SketchSegment)swSketchMgr.CreateLine(0.0, 0.0, 0.0, 0.024347, -0.010966, 0.0);swModelDocExt = (ModelDocExtension)swModel.Extension;status = swModelDocExt.SelectByID2("Line1", "SKETCHSEGMENT", 0.690604633175108, 0.625483883858213, 0, false, 0, null, 0);status = swModelDocExt.SelectByID2("Line2", "SKETCHSEGMENT", 0.747211061353527, 0.357889859742052, 0, true, 0, null, 0);swView = (View)swDrawing.CreateSectionViewAt5(0.676815388637685, 0.116110180826413, 0, "A", (int)swCreateSectionViewAtOptions_e.swCreateSectionView_OffsetSection, null, 0);status = swDrawing.ActivateView("Drawing View2");swModel.ClearSelection2(true);//Get section view and get and set whether to hide cutting line shouldersswSectionView = (DrSection)swView.GetSection();if (swSectionView.CuttingLineShoulders){Debug.Print("Hide cutting line shoulders = True");Debug.Print("Setting hide cutting line shoulders to False");swSectionView.CuttingLineShoulders = false;Debug.Print(" Hide cutting line shoulders = " + swSectionView.CuttingLineShoulders);}else{Debug.Print("Hide cutting line shoulders = False");Debug.Print("Setting hide cutting line shoulders to True");swSectionView.CuttingLineShoulders = true;Debug.Print(" Hide cutting line shoulders = " + swSectionView.CuttingLineShoulders);}}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

System.object GetCurrentSheet()

This example shows how to create a title block in a drawing, if one does not already exist, and how to get the notes from an existing title block in a drawing.//-------------------------------------------------------- // Preconditions: Drawing document is open. // // Postconditions: If the drawing contains a title block, then // the notes of that block are printed // to the Immediate window. If not, // a title block is created. //-------------------------------------------------------using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System; using System.Diagnostics; using System.Runtime.InteropServices; namespace ExampleCS.csproj {public partial class SolidWorksMacro{ModelDoc2 swModel;ModelDocExtension swExt;SelectionMgr swSelMgr;View swView;DrawingDoc swDraw;public void Main(){swModel = swApp.ActiveDoc as ModelDoc2;swExt = swModel.Extension;swSelMgr = swModel.SelectionManager as SelectionMgr;swDraw = swModel as DrawingDoc;Sheet swSheet;swSheet = swDraw.GetCurrentSheet() as Sheet;TitleBlock swTitleBlock;swTitleBlock = swSheet.TitleBlock;object[] vNotes;int i;// Create title block if one doesn't existif (swTitleBlock == null){swView = swDraw.GetFirstView() as View;vNotes = (object[])swView.GetNotes();// Add first two notes to the title blockDispatchWrapper[] notesArray = new DispatchWrapper[2];notesArray[0] = new DispatchWrapper(vNotes[0]);notesArray[1] = new DispatchWrapper(vNotes[1]);swTitleBlock = swSheet.InsertTitleBlock(notesArray);}vNotes = (object[])swTitleBlock.GetNotes();for (i = 0; i < vNotes.Length; i++){Note swNote;swNote = (Note)vNotes[i];Debug.Print("Name: " + swNote.GetName());Debug.Print("Value: " + swNote.GetText());}}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

System.object GetFirstView()

//This example shows how to get the drawing view's bounding box, position, and position //lock status.//--------------------------------------------------------- // Preconditions: // 1. Verify that the drawing document to open exists. // 2. Open the Immediate window. // // Postconditions: // 1. Opens the specified drawing document. // 2. Gets each drawing view's: // * origin's x and y positions relative // to the drawing sheet origin // * bounding box // * position lock status // 3. Examine the Immediate window. // // NOTE: Because the drawing is used elsewhere, do not save // changes. //---------------------------------------------------------- using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System; using System.Diagnostics;namespace Macro1.csproj {public partial class SolidWorksMacro{public void Main(){DrawingDoc swDraw = default(DrawingDoc);View swView = default(View);double[] outline = null;double[] pos = null;string fileName = null;int errors = 0;int warnings = 0;fileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\replaceview.slddrw";swDraw = (DrawingDoc)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swView = (View)swDraw.GetFirstView();while ((swView != null)){outline = (double[])swView.GetOutline();pos = (double[])swView.Position;Debug.Print("View = " + swView.Name);Debug.Print(" X and Y positions = (" + pos[0] * 1000.0 + ", " + pos[1] * 1000.0 + ") mm");Debug.Print(" X and Y bounding box minimums = (" + outline[0] * 1000.0 + ", " + outline[1] * 1000.0 + ") mm");Debug.Print(" X and Y bounding box maximums = (" + outline[2] * 1000.0 + ", " + outline[3] * 1000.0 + ") mm");Debug.Print(" Position locked?" + swView.PositionLocked);swView = (View)swView.GetNextView();}}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

System.object GetSheetNames()

//This example shows how to modify and reload a sheet format template.//------------------------------------------------------------ // Preconditions: // 1. Make a copy of: // C:\ProgramData\SolidWorks\SOLIDWORKS version\lang\english\sheetformat\a0 - iso.slddrt. // 2. Create a new blank drawing using standard sheet size AO (ISO). // 3. Add another blank sheet to the drawing, for a total of two sheets. // 4. Open the Immediate window. // // Postconditions: // 1. Modifies the sheet format template to include a new // note. // 2. Examine Sheet1, Sheet2, and the Immediate window. // 3. Delete: // C:\ProgramData\SolidWorks\SOLIDWORKS version\lang\english\sheetformat\a0 - iso.slddrt. // 4. Rename the copy that you made in Preconditions step 1 to: // C:\ProgramData\SolidWorks\SOLIDWORKS version\lang\english\sheetformat\a0 - iso.slddrt. //------------------------------------------------------------ using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System; using System.Diagnostics;namespace Macro1CSharp.csproj {public partial class SolidWorksMacro{const bool TEST_APPLY_CHANGES_TO_ALL = true;private string GetReloadResult(swReloadTemplateResult_e result){string functionReturnValue = null;switch (result){case (swReloadTemplateResult_e)swReloadTemplateResult_e.swReloadTemplate_Success:functionReturnValue = "Success";break;case (swReloadTemplateResult_e)swReloadTemplateResult_e.swReloadTemplate_UnknownError:functionReturnValue = "FAIL - Unknown Error";break;case (swReloadTemplateResult_e)swReloadTemplateResult_e.swReloadTemplate_FileNotFound:functionReturnValue = "FAIL - File Not Found";break;case (swReloadTemplateResult_e)swReloadTemplateResult_e.swReloadTemplate_CustomSheet:functionReturnValue = "FAIL - Custom Sheet";break;case (swReloadTemplateResult_e)swReloadTemplateResult_e.swReloadTemplate_ViewOnly:functionReturnValue = "FAIL - View Only";break;default:functionReturnValue = "FAIL - <unrecognized error code - " + result + ">";break;}return functionReturnValue;}public void Main(){ModelDoc2 swModel = default(ModelDoc2);swModel = (ModelDoc2)swApp.ActiveDoc;if (swModel == null){Debug.Print("Create a new empty drawing and add a second sheet to the drawing.");return;}if (swModel.GetType() != (int)swDocumentTypes_e.swDocDRAWING)return;DrawingDoc swDrwng = default(DrawingDoc);swDrwng = (DrawingDoc)swModel;//Get the current sheetSheet activeSheet = default(Sheet);activeSheet = (Sheet)swDrwng.GetCurrentSheet();Debug.Print("Active sheet name: " + activeSheet.GetName());//Get the sheet format templatestring templateName = null;templateName = activeSheet.GetTemplateName();Debug.Print("Sheet format template name to modify: " + templateName);swDrwng.EditTemplate();//Add a new note to the sheet format templateNote swNote = default(Note);swNote = (Note)swModel.InsertNote("A New Note");Annotation swAnno = default(Annotation);swAnno = (Annotation)swNote.GetAnnotation();swAnno.SetPosition2(0, 0.2, 0);TextFormat txtFormat = default(TextFormat);txtFormat = (TextFormat)swAnno.GetTextFormat(0);txtFormat.BackWards = (txtFormat.BackWards == false);txtFormat.Bold = true;txtFormat.CharHeightInPts = 10 * txtFormat.CharHeightInPts;swAnno.SetTextFormat(0, false, txtFormat);swDrwng.EditSheet();//At this point, the active sheet's format has changed if (TEST_APPLY_CHANGES_TO_ALL){//Save sheet format back to original sheet format templateactiveSheet.SaveFormat(templateName);//Reload all other sheets from the updated sheet format templateobject[] vSheetNames = null;vSheetNames = (object[])swDrwng.GetSheetNames();foreach (string vName in vSheetNames){if (vName != (string)activeSheet.GetName()){Debug.Print("Other sheet name: " + vName);Sheet otherSheet = default(Sheet);otherSheet = (Sheet)swDrwng.get_Sheet(vName);if (otherSheet.GetTemplateName() == templateName){swReloadTemplateResult_e reloadResult = default(swReloadTemplateResult_e);//Keep modifications and and reload all other elements//from original sheet format templatereloadResult = (swReloadTemplateResult_e)otherSheet.ReloadTemplate(true);//Discard modifications and reload all elements from//original sheet format template//reloadResult = otherSheet.ReloadTemplate(False) Debug.Print("Reload sheet format for <" + otherSheet.GetName() + ">: " + GetReloadResult(reloadResult));}}}swDrwng.ActivateSheet(activeSheet.GetName());}else{//Discard the changes and reload the original sheet format templateswReloadTemplateResult_e reloadResult = default(swReloadTemplateResult_e);reloadResult = (swReloadTemplateResult_e)activeSheet.ReloadTemplate(false);Debug.Print("Done - " + GetReloadResult(reloadResult));}}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

System.int GetViewCount()

This example shows how to get all of the views and notes in a drawing document.'-------------------------------------------- ' Preconditions: Drawing document is open and at least ' one view has some notes. ' ' Postconditions: None ' ' NOTE: IDrawingDoc::GetViews returns both sheets and views. '----------------------------------------------Option Explicit Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swDrawDoc As SldWorks.DrawingDoc Dim swView As SldWorks.View Dim swNote As SldWorks.Note Dim sheetCount As Long Dim viewCount As Long Dim noteCount As Long Dim i As LongSub main()Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swDrawDoc = swModel Dim viewCount As Long viewCount = swDrawDoc.GetViewCount Dim ss As Variant ss = swDrawDoc.GetViews For sheetCount = LBound(ss) To UBound(ss)Dim vv As Variantvv = ss(sheetCount)For viewCount = LBound(vv) To UBound(vv)Debug.Print (vv(viewCount).GetName2())Dim vNotes As VariantnoteCount = vv(viewCount).GetNoteCountIf noteCount > 0 ThenvNotes = vv(viewCount).GetNotesFor i = 0 To noteCount - 1Debug.Print " Note text: " & vNotes(i).GetTextNextEnd IfNext viewCount Next sheetCount End Sub

void HideEdge()

//This example shows how to hide and then show all of the edges in the root component in //a drawing view.//--------------------------------------------------------------------------- // Preconditions: // 1. Verify that the specified drawing document to open exists. // 2. Open the Immediate window. // // Postconditions: // 1. Opens the specified drawing document. // 2. Hides and then shows all edges in the root component in // Drawing View1. // 3. Examine the drawing and Immediate window. //---------------------------------------------------------------------------- using Microsoft.VisualBasic; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; namespace HideShowEdges_CSharp.csproj {partial class SolidWorksMacro{ModelDoc2 swModel;DrawingDoc swDraw;DocumentSpecification swDocSpecification;Sheet swSheet;View swView;DrawingComponent swDrawingComponent;Component2 swComponent;Entity swEntity;object[] vEdges;bool bRet;int i;public void Main(){// Specify the drawing to openswDocSpecification = (DocumentSpecification)swApp.GetOpenDocSpec("C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\advdrawings\\foodprocessor.SLDDRW");swModel = (ModelDoc2)swApp.ActiveDoc;if (swModel == null){swModel = swApp.OpenDoc7(swDocSpecification);}swModel = (ModelDoc2)swApp.ActiveDoc;swDraw = (DrawingDoc)swModel;// Get the current sheetswSheet = (Sheet)swDraw.GetCurrentSheet();Debug.Print(swSheet.GetName());// Select Drawing View1bRet = swModel.Extension.SelectByID2("Drawing View1", "DRAWINGVIEW", 0.0, 0.0, 0.0, true, 0, null, (int)swSelectOption_e.swSelectOptionDefault);swView = (View)((SelectionMgr)swModel.SelectionManager).GetSelectedObject6(1, -1);// Print the drawing view name and get the component in the drawing viewDebug.Print(swView.GetName2());swDrawingComponent = swView.RootDrawingComponent;swComponent = swDrawingComponent.Component;// Get the component's visible entities in the drawing viewint eCount = 0;eCount = swView.GetVisibleEntityCount2(swComponent, (int)swViewEntityType_e.swViewEntityType_Edge);vEdges = (object[])swView.GetVisibleEntities2(swComponent, (int)swViewEntityType_e.swViewEntityType_Edge);Debug.Print("Number of edges found: " + eCount);// Hide all of the visible edges in the drawing viewfor (i = 0; i <= eCount - 1; i++){swEntity = (Entity)vEdges[i];swEntity.Select4(true, null);swDraw.HideEdge();}// Clear all selectionsswModel.ClearSelection2(true);// Show all hidden edgesswView.HiddenEdges = vEdges;}public SldWorks swApp;} }

void HideShowDrawingViews()

//This example shows how to set the display mode of a drawing view.//---------------------------------------------------------------------------- // Preconditions: // 1. Open a drawing document. // 2. Select a view. // 3. Inspect the graphics area and press F5 six times. // // Postconditions: The display mode, hide/show, and suppression // settings for the document are modified as specified. //----------------------------------------------------------------------------using Microsoft.VisualBasic; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; namespace DisplayHiddenLinesinDrawing_CSharp.csproj {partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);DrawingDoc swDraw = default(DrawingDoc);swModel = (ModelDoc2)swApp.ActiveDoc;swDraw = (DrawingDoc)swModel;swDraw.ViewDisplayHidden();System.Diagnostics.Debugger.Break();swDraw.ViewDisplayHiddengreyed();System.Diagnostics.Debugger.Break();swDraw.ViewDisplayWireframe();System.Diagnostics.Debugger.Break();swDraw.ViewDisplayShaded();System.Diagnostics.Debugger.Break();// Suppress viewswDraw.SuppressView();System.Diagnostics.Debugger.Break();// Display an X where the view was suppressedswDraw.HideShowDrawingViews();System.Diagnostics.Debugger.Break();// Unsuppress viewswDraw.UnsuppressView();}public SldWorks swApp;} }

Centerline InsertCenterLine2()

//This example shows how to get all of the centerlines in all of the drawing views in a //drawing.//------------------------------------ // Preconditions: // 1. Verify that the drawing document to open exists. // 2. Open the Immediate window. // // Postconditions: // 1. Opens the specified drawing. // 2. Inserts a centerline annotation. // 3. Prints the path and file name of the drawing document // to the Immediate window. // 4. Iterates the sheet and drawing view, prints their names, and // prints the name of the centerline annotation to // the Immediate window. // 5. Examine the Immediate window. // // NOTE: Because this drawing document is used elsewhere, // do not save any changes. //------------------------------------ using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System; using System.Diagnostics;namespace CenterLinesCSharp.csproj {public partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);ModelDocExtension swModelDocExt = default(ModelDocExtension);DrawingDoc swDrawing = default(DrawingDoc);View swView = default(View);Centerline swCenterLine = default(Centerline);Annotation swAnnotation = default(Annotation);bool status = false;int errors = 0;int warnings = 0;string fileName = null;fileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\cylinder20.SLDDRW";swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swDrawing = (DrawingDoc)swModel;swModelDocExt = (ModelDocExtension)swModel.Extension;status = swDrawing.ActivateView("Drawing View1");status = swModelDocExt.SelectByID2("cylinder20-9@Drawing View1", "COMPONENT", 0, 0, 0, false, 0, null, 0);status = swModelDocExt.SelectByID2("", "FACE", 0.513454307125032, 0.454946591641617, 250.013794595267, false, 0, null, 0);swCenterLine = (Centerline)swDrawing.InsertCenterLine2();swModel.ClearSelection2(true);swView = (View)swDrawing.GetFirstView();Debug.Print("File = " + swModel.GetPathName());while ((swView != null)){Debug.Print(" View = " + swView.GetName2());swCenterLine = (Centerline)swView.GetFirstCenterLine();while ((swCenterLine != null)){swAnnotation = (Annotation)swCenterLine.GetAnnotation();Debug.Print(" Name = " + swAnnotation.GetName());swCenterLine = swCenterLine.GetNext();}swView = (View)swView.GetNextView();}}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

System.bool InsertCircularNotePattern(?
? ?System.double ArcRadius,
? ?System.double ArcAngle,
? ?System.int PatternNum,
? ?System.double PatternSpacing,
? ?System.bool PatternRotate,
? ?System.string DeleteInstances)

This example shows how to insert linear and circular note patterns in a drawing.//--------------------------------------------------------- // // Preconditions: Verify that the specified drawing document // to open exists. // // Postconditions: // 1. Inserts a note in the drawing and selects the note. // 2. Inserts a linear note pattern (2 instances, including // the original note) in the drawing. // 3. Inserts a circular note pattern (4 instances, including // the original note) in the drawing. // // NOTE: Because the model is used elsewhere, do not save // changes. //---------------------------------------------------------- using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System;namespace InsertLinearCircularNotePatternsCSharp.csproj {partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);DrawingDoc swDrawingDoc = default(DrawingDoc);Note swNote = default(Note);bool status = false;int errors = 0;int warnings = 0;// Open drawing document, activate sheet, and make it the active documentswModel = (ModelDoc2)swApp.OpenDoc6("C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\advdrawings\\foodprocessor.slddrw", 3, 0, "", ref errors, ref warnings);swApp.ActivateDoc2("foodprocessor - Sheet1", false, ref errors);swDrawingDoc = (DrawingDoc)swApp.ActiveDoc;// Insert a noteswNote = (Note)swModel.InsertNote("Test inserting linear and circular note patterns");// Select the just-inserted notestatus = swModel.Extension.SelectByID2("DetailItem174@Sheet1", "NOTE", 0.2558797881203, 0.3700526, 0, false, 0, null, 0);// Create a linear note pattern using the selected notestatus = swDrawingDoc.InsertLinearNotePattern(2, 1, 0.01, 0.01, 0.7853981633975, 1.570796326795, "");// Create a circular pattern using the selected notestatus = swDrawingDoc.InsertCircularNotePattern(0.075, 4.03202193189, -4, 1.570796326795, true, "");}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

System.object InsertRevisionCloud(?System.int CloudShape)

//This example shows how to insert revision clouds into a drawing and access revision //cloud data.//---------------------------------------------------------------------------- // Preconditions: Open public_documents\samples\tutorial\api\resetsketchvisibility.slddrw. // // Postconditions: // 1. Inserts an elliptical revision cloud in the drawing. // 2. Examine the Immediate window. // // NOTE: Because the drawing is used elsewhere, do not save changes. // --------------------------------------------------------------------------- using Microsoft.VisualBasic; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; namespace InsertRevisionCloud_CSharp.csproj {partial class SolidWorksMacro{DrawingDoc Part;RevisionCloud RevCloud;Annotation RevCloudAnno;bool boolstatus;public void Main(){Part = (DrawingDoc)swApp.ActiveDoc;boolstatus = Part.ActivateView("Drawing View1");// Create a revision cloud with an elliptical shapeRevCloud = (RevisionCloud)Part.InsertRevisionCloud(1);if ((RevCloud != null)){RevCloudAnno = (Annotation)RevCloud.GetAnnotation();if ((RevCloudAnno != null)){// Position the center of the elliptical revision cloudboolstatus = RevCloudAnno.SetPosition(0.270847371964905, 0.553263328912467, 0);RevCloud.ArcRadius = 0.00508;// Create a path point on the corner of an ellipse-inscribed rectangleboolstatus = RevCloud.SetPathPointAtIndex(-1, 0.378419710263212, 0.511051398694144, 0);// Close the revision cloud pathboolstatus = RevCloud.Finalize();}}}public SldWorks swApp;} }

TableAnnotation InsertTableAnnotation2(?
? ?System.bool UseAnchorPoint,
? ?System.double X,
? ?System.double Y,
? ?System.int AnchorType,
? ?System.string TableTemplate,
? ?System.int Rows,
? ?System.int Columns)
?

This example shows how to get a general table feature and some of its table annotation data.//----------------------------------------------------------------- // Preconditions: // 1. Verify that the specified drawing document to open exists. // 2. Open the Immediate window. // // Postconditions: // 1. Opens the specified drawing document. // 2. Inserts a table annotation. // 3. Gets the general table feature. // 4. Prints the name of the general table feature and // some of its annotation table data the Immediate window. // 5. Examine the Immediate window. // // NOTE: Because the drawing document is used elsewhere, do not // save changes. //-----------------------------------------------------------------using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System; using System.Diagnostics;namespace GeneralTableFeatureCSharp.csproj {public partial class SolidWorksMacro{ public void Main(){ModelDoc2 swModel = default(ModelDoc2);DrawingDoc swDrawing = default(DrawingDoc);bool status = false;int errors = 0;int warnings = 0;string fileName = null;TableAnnotation swTableAnnotation = default(TableAnnotation);GeneralTableFeature swGeneralTableFeature = default(GeneralTableFeature);SelectionMgr swSelectionMgr = default(SelectionMgr);ModelDocExtension swModelDocExt = default(ModelDocExtension);Feature swFeature = default(Feature);int nbrTableAnnotations = 0;object[] tableAnnotations = null;int i = 0;bool anchorAttached = false;int anchorType = 0;int nbrColumns = 0;int nbrRows = 0;//Open drawing documentfileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\assem20.slddrw";swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);//Insert table annotationswDrawing = (DrawingDoc)swModel;swTableAnnotation = (TableAnnotation)swDrawing.InsertTableAnnotation2(false, 0.0275123456559767, 0.132124518483965, 1, "", 2, 2);if ((swTableAnnotation != null)){swTableAnnotation.BorderLineWeight = 0;swTableAnnotation.GridLineWeight = 0;}//Select and get general table featureswModelDocExt = (ModelDocExtension)swModel.Extension;status = swModelDocExt.SelectByID2("General Table1", "GENERALTABLEFEAT", 0, 0, 0, false, 0, null, 0);swSelectionMgr = (SelectionMgr)swModel.SelectionManager;swGeneralTableFeature = (GeneralTableFeature)swSelectionMgr.GetSelectedObject6(1, -1);swFeature = (Feature)swGeneralTableFeature.GetFeature();Debug.Print("General table feature name: " + swFeature.Name);//Get general table feature's annotation datanbrTableAnnotations = swGeneralTableFeature.GetTableAnnotationCount();Debug.Print("Number of annotations = " + nbrTableAnnotations);tableAnnotations = (object[])swGeneralTableFeature.GetTableAnnotations();for (i = 0; i <= (nbrTableAnnotations - 1); i++){swTableAnnotation = (TableAnnotation)tableAnnotations[i];anchorAttached = swTableAnnotation.Anchored;Debug.Print("Table anchored = " + anchorAttached);anchorType = swTableAnnotation.AnchorType;Debug.Print("Anchor type = " + anchorType);nbrColumns = swTableAnnotation.ColumnCount;Debug.Print("Number of columns = " + nbrColumns);nbrRows = swTableAnnotation.RowCount;Debug.Print("Number of rows = " + nbrRows);}}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

void IsolateChangedDimensions()

This example shows how to isolate a changed dimension.//------------------------------------------------------ // Preconditions: The specified drawing and part // documents exist. // // Postconditions: // 1. Opens the drawing document. // 2. Sets the system option to display // changed dimensions in the color selected // for Tools > Options > System Options > // Colors > Color scheme settings > // Drawings, Changed dimensions. // 3. Saves and closes the drawing document. // 4. Opens the part document of the drawing document. // 5. Changes a dimension. // 6. Saves and closes the part document. // 7. Opens the previously saved drawing document. // 8. Examine the drawing document to verify that // the changed dimension is displayed in the // changed-dimension color. Place your cursor over // the dimension to see its previous value. //------------------------------------------------------- using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System;namespace IsolateChangedDimensionsDrawingDocCSharp.csproj {partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);ModelDocExtension swModelDocExt = default(ModelDocExtension);DrawingDoc swDrawing = default(DrawingDoc);string fileName = null;string saveFileName = null;int errors = 0;int warnings = 0;bool status = false;// Open drawing document fileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\box.slddrw";swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);// Isolate changed dimensions // Equivalent to selecting Tools > Options > System Options > Colors > // Use specified color for changed drawing dimensions on openswApp.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swUseChangedDimensions, true);swDrawing = (DrawingDoc)swModel;swDrawing.IsolateChangedDimensions();// Save drawing document to another namesaveFileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\box_changed.slddrw";swModelDocExt = (ModelDocExtension)swModel.Extension;status = swModelDocExt.SaveAs(saveFileName, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)swSaveAsOptions_e.swSaveAsOptions_Silent, null, ref errors, ref warnings);swApp.CloseDoc(saveFileName);// Open the part document referenced by the drawing document,// change a dimension, and save the documentfileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\box.sldprt";swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocPART, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swModelDocExt = (ModelDocExtension)swModel.Extension;status = swModelDocExt.SelectByID2("Sketch1", "SKETCH", 0, 0, 0, true, 0, null, 0);status = swModelDocExt.SelectByID2("D2@Sketch1@box.SLDPRT", "DIMENSION", -0.03613329319351, -0.02215939491444, 0.02938582119709, true, 0, null, 0);Dimension swDimension = default(Dimension);swDimension = (Dimension)swModel.Parameter("D2@Sketch1");swDimension.SystemValue = 0.185;swModel.ClearSelection2(true);status = swModel.EditRebuild3();status = swModel.Save3((int)swSaveAsOptions_e.swSaveAsOptions_Silent, ref errors, ref warnings);swApp.CloseDoc(fileName);// Open the previously saved drawing document// and place your cursor on the changed dimension,// which displays in the color specified for// changed dimensions, to see its previous valueswModel = (ModelDoc2)swApp.OpenDoc6(saveFileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

System.bool NewSheet4(?
? ?System.string Name,
? ?System.int PaperSize,
? ?System.int TemplateIn,
? ?System.double Scale1,
? ?System.double Scale2,
? ?System.bool FirstAngle,
? ?System.string TemplateName,
? ?System.double Width,
? ?System.double Height,
? ?System.string PropertyViewName,
? ?System.double ZoneLeftMargin,
? ?System.double ZoneRightMargin,
? ?System.double ZoneTopMargin,
? ?System.double ZoneBottomMargin,
? ?System.int ZoneRow,
? ?System.int ZoneCol)

This example shows how to create a drawing sheet with zones, modify the zones in the drawing sheet, and insert a revision table.//----------------------------------------------------------------------------- // Preconditions: // 1. Verify that the specified model document and templates exist. // 2. Open an Immediate window. // // Postconditions: // 1. Creates a new sheet named Test with four zones. // 2. Inspect the graphics area. // 3. Press F5. // 4. Modifies Test to contain nine zones. // 5. Creates Revision Table1. // 6. Adds a revision row to the table. // 7. Inspect the FeatureManager design tree, the graphics area, and the // Immediate window. // // NOTE: Because the model is used elsewhere, do not save changes to it. //--------------------------------------------------------------------------- using Microsoft.VisualBasic; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; namespace InsertRevisionTable_CSharp.csproj {partial class SolidWorksMacro{DrawingDoc swDraw;Sheet currentsheet;ModelDoc2 swModel;RevisionTableAnnotation revTableAnno;bool boolstatus;int longstatus;int longwarnings;public void Main(){swModel = swApp.OpenDoc6("C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\assem20.slddrw", 3, 0, "", ref longstatus, ref longwarnings);swApp.ActivateDoc2("assem20 - Sheet1", false, ref longstatus);swModel = (ModelDoc2)swApp.ActiveDoc;swDraw = (DrawingDoc)swModel;boolstatus = swModel.Extension.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swShowZoneLines, 0, true);boolstatus = swModel.Extension.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swRevisionTableMultipleSheetStyle, 0, (int)swRevisionTableMultipleSheetStyle_e.swRevisionTable_Independent);if ((swDraw == null)){Debug.Print(" Please open a drawing document. ");}currentsheet = (Sheet)swDraw.GetCurrentSheet();swDraw.ActivateSheet(currentsheet.GetName());// Create sheet, Test, with 4 zonesboolstatus = swDraw.NewSheet4("Test", (int)swDwgPaperSizes_e.swDwgPaperAsize, (int)swDwgTemplates_e.swDwgTemplateAsize, 1, 1, true, "", 0, 0, "",0.5, 0.5, 0.5, 0.5, 2, 2);System.Diagnostics.Debugger.Break();boolstatus = swModel.Extension.SelectByID2("Sheet Format2", "SHEET", 0, 0, 0, false, 0, null, 0);swDraw.EditTemplate();swModel.EditSketch();swModel.ClearSelection2(true);boolstatus = swModel.Extension.SelectByID2("Sheet Format2", "SHEET", 0.0812585524728589, 0.139959974668275, 0, false, 0, null, 0);// Modify Test to have 9 zonesboolstatus = swDraw.SetupSheet6("Test", (int)swDwgPaperSizes_e.swDwgPapersUserDefined, (int)swDwgTemplates_e.swDwgTemplateCustom, 1, 1, true, "C:\\Program Files\\SOLIDWORKS Corp\\SOLIDWORKS\\lang\\english\\sheetformat\\a - landscape.slddrt", 0.2794, 0.2159, "Default",false, 0.5, 0.5, 0.5, 0.5, 3, 3);swDraw.EditSheet();swModel.EditSketch();swModel.ForceRebuild3(true);currentsheet = (Sheet)swDraw.GetCurrentSheet();swDraw.ActivateSheet(currentsheet.GetName());// Insert a revision table and add a revision rowrevTableAnno = currentsheet.InsertRevisionTable2(true, 0.0, 0.0, (int)swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_TopLeft, "C:\\Program Files\\SOLIDWORKS Corp\\SOLIDWORKS\\lang\\English\\standard revision block.sldrevtbt", (int)swRevisionTableSymbolShape_e.swRevisionTable_CircleSymbol, true);Debug.Print("Revision table annotation");Debug.Print(" New revision: " + revTableAnno.AddRevision("A"));Debug.Print(" Current revision: " + revTableAnno.CurrentRevision);RevisionTableFeature revTableFeat = default(RevisionTableFeature);revTableFeat = revTableAnno.RevisionTableFeature;Debug.Print("Revision table feature");Debug.Print(" Number of revision table annotations: " + revTableFeat.GetTableAnnotationCount());Feature feat = default(Feature);feat = (Feature)revTableFeat.GetFeature();Debug.Print("Feature: " + feat.Name);}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

System.bool ReplaceViewModel(?
? ?System.string NewModelPathName,
? ?System.object Views,
? ?System.object Instances)

This example shows how to replace a model in drawing views.//--------------------------------------------------------------------------- // Preconditions: // 1. Open public_documents\samples\tutorial\api\assem20.slddrw. // 2. Verify that the specified replacement model exists. // // Postconditions: Replaces the specified component in Drawing View1 // with the specified model. // // NOTE: Because the model is used elsewhere, do not save changes // when closing it. //---------------------------------------------------------------------------using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System; namespace ReplaceViewModel_CSharp.csproj {partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel;ModelDocExtension swModelDocExt;DrawingDoc swDrawingDoc;SelectionMgr swSelectionMgr;DrawingComponent swDrawingComponent;View swView;Component2 swComponent;object view;object instance;object[] views = new object[1];object[] instances = new object[1];DispatchWrapper[] viewsIn = new DispatchWrapper[1];DispatchWrapper[] instancesIn = new DispatchWrapper[1];bool status;swModel = (ModelDoc2)swApp.ActiveDoc;swDrawingDoc = (DrawingDoc)swModel;status = swDrawingDoc.ActivateView("Drawing View1");//Select the view in which to replace the modelswModelDocExt = (ModelDocExtension)swModel.Extension;status = swModelDocExt.SelectByID2("Drawing View1", "DRAWINGVIEW", 0, 0, 0, false, 0, null, 0);swSelectionMgr = (SelectionMgr)swModel.SelectionManager;swView = (View)swSelectionMgr.GetSelectedObject6(1, -1);view = (object)swView;views[0] = view;viewsIn[0] = new DispatchWrapper(views[0]);// Select the instance of the model to replacestatus = swModelDocExt.SelectByID2("Assem20-3@Drawing View1", "COMPONENT", 0, 0, 0, false, 0, null, 0);swDrawingComponent = (DrawingComponent)swSelectionMgr.GetSelectedObject6(1, -1);swComponent = (Component2)swDrawingComponent.Component;instance = (object)swComponent;instances[0] = instance;instancesIn[0] = new DispatchWrapper(instances[0]);status = swDrawingDoc.ReplaceViewModel("C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\api\\bagel.sldprt", (viewsIn), (instancesIn));}public SldWorks swApp;} }

void SetSheetsSelected( System.object NewSheetList)

//This example shows how to modify the setups of multiple drawing sheets.//-------------------------------------------------------- // Preconditions: // 1. Verify that the drawing and sheet format files exist. // 2. Open the Immediate window. // // Postconditions: // 1. Opens the drawing. // 2. Sets Sheet1, Sheet2 and Sheet3 drawing sheet formats // to portrait. // 3. Rebuilds the drawing. // 4. Click each sheet tab, click Zoom to Fit, and examine // the sheet. // // NOTE: Because the drawing is used elsewhere, do not // save changes. //--------------------------------------------------------- using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System;namespace Macro1CSharp.csproj {public partial class SolidWorksMacro{public void Main(){ModelDoc2 swModel = default(ModelDoc2);ModelDocExtension swModelDocExt = default(ModelDocExtension);DrawingDoc swDrawing = default(DrawingDoc);string fileName = null;bool status = false;int errors = 0;int warnings = 0;object sheetNameArray = null;string[] sheetNames = new string[2];fileName = "C:\\Users\\Public\\Documents\\SOLIDWORKS\\SOLIDWORKS 2018\\samples\\tutorial\\advdrawings\\foodprocessor.slddrw";swModel = (ModelDoc2)swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);swModelDocExt = (ModelDocExtension)swModel.Extension;swDrawing = (DrawingDoc)swModel;sheetNames[0] = "Sheet2";sheetNames[1] = "Sheet3";sheetNameArray = sheetNames;swDrawing.SetSheetsSelected(sheetNameArray);status = swDrawing.SetupSheet6("Sheet3", (int)swDwgPaperSizes_e.swDwgPapersUserDefined, (int)swDwgTemplates_e.swDwgTemplateCustom, 1, 1, true, "C:\\ProgramData\\SOLIDWORKS\\SOLIDWORKS 2017\\lang\\english\\sheetformat\\a4 - portrait.slddrt", 0.2794, 0.2159, "Default",true, 0, 0, 0, 0, 0, 0);swModel.ForceRebuild3(true);swModel.ViewZoomtofit2();}/// <summary>/// The SldWorks swApp variable is pre-assigned for you./// </summary>public SldWorks swApp;} }

void SuppressView()

//This example shows how to automatically insert center marks in multiple drawing views.//---------------------------------------------------------------------------- // Preconditions: Open public_documents\samples\tutorial\advdrawings\foodprocessor.slddrw. // // Postconditions: // 1. Clears the Tools > Options > Document Properties > Centerlines/Center Marks > // Scale by view scale check box. // 2. Activates Sheet3. // 3. Suppresses Drawing View9. // 4. Inserts center marks in Drawing View9 and Drawing View11. // 5. Unsuppresses Drawing View9. // 6. Examine the drawing. // // NOTE: Because the drawing is used elsewhere, do not save changes. // --------------------------------------------------------------------------- using System; using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst;namespace AutoInsertCenterMarks_CSharp.csproj {partial class SolidWorksMacro{ModelDoc2 Part;DrawingDoc Draw;ModelDocExtension ModelDocExt;View swActiveView;bool boolstatus;public void Main(){Part = (ModelDoc2)swApp.ActiveDoc;Draw = (DrawingDoc)Part;ModelDocExt = (ModelDocExtension)Part.Extension;// Clear the Scale by view scale check box to set gapModelDocExt.SetUserPreferenceToggle((int)swUserPreferenceToggle_e.swDetailingCenterMarkScaleByViewScale, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, false);Draw.ActivateSheet("Sheet3");// Suppress Drawing View9 boolstatus = ModelDocExt.SelectByID2("Drawing View9", "DRAWINGVIEW", 0, 0, 0, false, 0, null, 0);Draw.SuppressView();// Insert center marks for all holes, fillets, and slots in the specified viewboolstatus = Draw.ActivateView("Drawing View9");swActiveView = (View)Draw.ActiveDrawingView;boolstatus = swActiveView.AutoInsertCenterMarks2(7, 11, true, true, true, 0.0025, 0.0025, true, true, 0);boolstatus = Draw.ActivateView("Drawing View11");swActiveView = (View)Draw.ActiveDrawingView;boolstatus = swActiveView.AutoInsertCenterMarks2(7, 11, true, true, false, 0.005, 0.005, true, false, 0);Part.ClearSelection2(true);// Unsuppress Drawing View9boolstatus = ModelDocExt.SelectByID2("Drawing View9", "DRAWINGVIEW", 0, 0, 0, false, 0, null, 0);Draw.UnsuppressView();}public SldWorks swApp;}}


?

總結(jié)

以上是生活随笔為你收集整理的IDrawingDoc Interface 学习笔记的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。