Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
draftsight / opt / dassault-systemes / DraftSight / APISDK / Switch_Layouts_Example_VBNET.htm
Size: Mime:
<html>

<head>
<title>Switch Layouts Example (VB.NET)</title>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="ApiHelp.css">
<meta name=MS-HKWD content="VB.NET examples">
<meta name=MS-HKWD content="VB.NET examples,Sheets">
<meta name=MS-HKWD content="VB.NET examples,layouts">
<meta name=MS-HKWD content="VB.NET examples,models">
</head>


<body>
<h1>Switch Layouts Example (VB.NET)</h1>
<p>This example shows how to switch layouts.</p>
<pre>'--------------------------------------------------------------
'Preconditions:
' 1. Create a VB.NET Windows console project.
' 2. Copy and paste this example into the VB.NET IDE.
' 3. Add a reference to:
'    <i>install_dir</i>\<b>APISDK\tlb\DraftSight.Interop.dsAutomation.dll</b>.
' 4. Start DraftSight and open a document.
' 5. Start debugging the project.
'
'Postconditions: Message boxes pop up when a model or sheet
'is activated. Read the text in each message box before clicking
'OK to close it.
'----------------------------------------------------------------
Imports DraftSight.Interop.dsAutomation</pre>
<pre>Module Module1</pre>
<pre>    Sub Main()
</pre>
<pre>        Dim dsApp As Application
        Dim dsDoc As Document</pre>
<pre>        'Connect to DraftSight
        dsApp = GetObject(, &quot;DraftSight.Application&quot;)
	dsApp.<b>AbortRunningCommand</b>() ' abort any command currently running in DraftSight to avoid nested commands</pre>
<pre>        'Get active document
        dsDoc = dsApp.GetActiveDocument()
        If Not dsDoc Is Nothing Then</pre>
<pre>            'Activate each layout, one by one
            SwitchLayouts(dsDoc)</pre>
<pre>        Else
            MsgBox(&quot;There are no open documents in DraftSight.&quot;)
        End If
    End Sub
    Sub SwitchLayouts(ByVal dsDoc As Document)
        Dim dsSheet As Sheet
        Dim dsModel As Model
        Dim dsVarSheets As Object
        Dim index As Integer
        Dim sheetName As String</pre>
<pre>        'Get all sheets
        dsVarSheets = dsDoc.GetSheets</pre>
<pre>        If IsArray(dsVarSheets) Then</pre>
<pre>            For index = LBound(dsVarSheets) To UBound(dsVarSheets)</pre>
<pre>                dsSheet = dsVarSheets(index)</pre>
<pre>                'Get sheet name
                sheetName = dsSheet.Name</pre>
<pre>                'Change sheet name, if it is not a model
                If sheetName &lt;&gt; &quot;Model&quot; Then</pre>
<pre>                    'Activate sheet
                    dsSheet.Activate()</pre>
<pre>                    'Verify if the sheet was activated
                    If dsSheet.IsActive Then
                        MsgBox(&quot;The sheet &quot; &amp; sheetName &amp; &quot; was activated.&quot;)
                    End If</pre>
<pre>                Else</pre>
<pre>                    'Activate model sheet
                    dsModel = dsDoc.GetModel</pre>
<pre>                    If Not dsModel Is Nothing Then</pre>
<pre>                        'Activate model sheet
                        dsModel.Activate()</pre>
<pre>                        'Verify if the sheet was activated
                        If dsModel.IsActive Then
                            MsgBox(&quot;The model sheet was activated.&quot;)
                        End If</pre>
<pre>                    End If</pre>
<pre>                End If</pre>
<pre>            Next</pre>
<pre>        End If
</pre>
<pre>    End Sub
</pre>
<pre>End Module</pre>
<p>&nbsp;</p>

</body>

</html>