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 / Insert_ViewTiles_in_Model_Example_VBA.htm
Size: Mime:
<html>

<head>
<title>Insert ViewTiles in Model Example (VBA)</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="VBA examples">
<meta name=MS-HKWD content="VBA examples,ViewTiles">
<meta name=MS-HKWD content="VBA examples,models">
<meta name=MS-HKWD content="VBA examples,custom coordinate systems">


</head>


<body>
<h1>Insert ViewTiles in Model Example (VBA)</h1>

<p>This example shows how to:</p>
<ul>
	<li><font face="Verdana" style="font-size: 8pt">insert ViewTiles in a model document.</font></li>
	<li><font face="Verdana" style="font-size: 8pt">turn 
off and on the display of the coordinate system icon in each ViewTile.</font></li>
</ul>
<pre>'<span style="font-size: 8pt">--------------------------------------------------------------</span>
' Preconditions:
' 1. Create a VBA macro in a software product in which VBA is
'    embedded.
' 2. Copy and paste this example into the Visual Basic IDE.
' 3. Add a reference to the DraftSight type library,
'    <i>install_dir</i>\<b>bin\dsAutomation.dll</b>.
' 4. Start DraftSight.
' 5. Ensure that the file specified to open exists.
' 6. Press F5 and click <b>Step Into </b>to step into the code.
' 7. Press F8 repeatedly to step through the code. Observe
'    the changes in the model document and ViewTiles.
'
' Postconditions:
' 1. Opens the specified file.
' 2. Inserts four ViewTiles.
' 3. Iterates through the four ViewTiles. For each ViewTile:
'    a. Turns off displaying the coordinate system at the
'       the origin.
'    b. Specifies to display the coordinate system at the origin.
'    c. Turns on displaying the coordinate system at the
'       origin.
' 4. Close the model document without saving any changes.
'----------------------------------------------------------------
Option Explicit</pre>
<pre>Sub main()    </pre>
<pre>    'Connect to DraftSight
    Dim dsApp As DraftSight.Application
    Set dsApp = GetObject(, &quot;DraftSight.Application&quot;)  

    'Abort any command currently running in DraftSight
    'to avoid nested commands
    dsApp.<b>AbortRunningCommand</b>
  
    'Open document
    Dim dsDoc As DraftSight.Document
    Dim docName As String
    docName = &quot;C:\ProgramData\Dassault Systemes\DraftSight\Examples\A-54643.DWG&quot;
    Set dsDoc = dsApp.<b>OpenDocument2</b>(docName, dsDocumentOpenOption_e.dsDocumentOpen_Default, dsEncoding_e.dsEncoding_Default)
    If dsDoc Is Nothing Then
        MsgBox &quot;There are no open documents in DraftSight.&quot;
        Return
    End If
    'Get active document
    dsApp.<b>GetActiveDocument</b>    </pre>
<pre>    'Get model
    Dim dsModel As DraftSight.Model
    Set dsModel = dsDoc.<b>GetModel</b>    </pre>
<pre>    'Insert ViewTiles
    Dim viewTiles As Variant
    Dim index As Long
    Dim dsViewTile As DraftSight.ViewTile
    viewTiles = dsModel.<b>InsertViewTiles</b>(dsViewTilesMode_e.dsViewTilesMode_4_Left, dsViewTilesApplyTo_e.dsViewTilesApplyTo_ActiveViewTile)
    If IsArray(viewTiles) Then
        For index = LBound(viewTiles) To UBound(viewTiles)
            Set dsViewTile = viewTiles(index) 
            'Turn off displaying coordinate system icon at origin
            dsViewTile.<b>CSIconIsOn</b> = False
            If Not (dsViewTile.<b>CSIconIsOn</b>) Then
                'Display coordinate system at origin 
                dsViewTile.<b>CSIconAtOrigin</b> = True
                'Turn on displaying coordinate system icon at origin
                dsViewTile.<b>CSIconIsOn</b> = True
            End If            </pre>
<pre>        Next
    End If </pre>
<pre>End Sub</pre>

</body>

</html>