Repository URL to install this package:
|
Version:
2016.3.0.4050 ▾
|
draftsight
/
opt
/
dassault-systemes
/
DraftSight
/
APISDK
/
Insert_ViewTiles_in_Model_Example_VBNET.htm
|
|---|
<html>
<head>
<title>Insert ViewTiles in Model 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,ViewTiles">
<meta name=MS-HKWD content="VB.NET examples,models">
<meta name=MS-HKWD content="VB.NET examples,custom coordinate systems">
</head>
<body>
<h1>Insert ViewTiles in Model Example (VB.NET)</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 style="font-family: Consolas; font-size: 13; color: black; background: white"><span style="color:green;">'--------------------------------------------------------------</span>
<span style="color:green;">' Preconditions:</span>
<span style="color:green;">' 1. Create a VB.NET console project in Microsoft
' Visual Studio 2012.</span>
<span style="color:green;">' 2. Copy and paste this example into the VB.NET IDE.</span>
<span style="color:green;">' 3. Add a reference to:</span>
<span style="color:green;">' <i>install_dir</i>\<b>APISDK\tlb\DraftSight.Interop.dsAutomation.dll</b>.</span>
<span style="color:green;">' 4. Start DraftSight.</span>
<span style="color:green;">' 5. Ensure that the file specified to open exits.</span>
<span style="color:green;">' 7. Press F11 to step into the code.
' 8. Press F10 repeatedly to step through the code. Observe
' the changes in the model document and ViewTiles while
' stepping through the code.</span>
<span style="color:green;">'</span>
<span style="color:green;">' Postconditions:</span>
<span style="color:green;">' 1. Opens the specified file.</span>
<span style="color:green;">' 2. Inserts four ViewTiles.</span>
<span style="color:green;">' 3. Iterates through the four ViewTiles. For each ViewTile:</span>
<span style="color:green;">' a. Turns off displaying the coordinate system at the</span>
<span style="color:green;">' the origin.</span>
<span style="color:green;">' b. Specifies to display the coordinate system at the origin.</span>
<span style="color:green;">' c. Turns on displaying the coordinate system at the</span>
<span style="color:green;">' origin.
</span><span style="color:green;">' 4. Close the model document without saving any changes.</span>
<span style="color:green;">'----------------------------------------------------------------</span>
<span style="color:blue;">Imports</span> DraftSight.Interop.dsAutomation
<span style="color:blue;">Imports</span> System
<span style="color:blue;">Imports</span> System.Runtime.InteropServices
<span style="color:blue;">Module</span> <span style="color:#2b91af;">Module1</span>
<span style="color:blue;">Sub</span> Main()
<span style="color:blue;">Dim</span> dsApp <span style="color:blue;">As</span> <span style="color:#2b91af;">Application</span>
<span style="color:blue;">Dim</span> dsDoc <span style="color:blue;">As</span> <span style="color:#2b91af;">Document</span> = <span style="color:blue;">Nothing</span>
<span style="color:blue;">Dim</span> dsModel <span style="color:blue;">As</span> <span style="color:#2b91af;">Model</span> = <span style="color:blue;">Nothing</span>
<span style="color:green;">'Connect to DraftSight</span>
dsApp = <span style="color:blue;">DirectCast</span>(<span style="color:#2b91af;">Marshal</span>.GetActiveObject(<span style="color:#a31515;">"DraftSight.Application"</span>), DraftSight.Interop.dsAutomation.<span style="color:#2b91af;">Application</span>)
<span style="color:green;">'Abort any command currently running </span>
<span style="color:green;">'in DraftSight to avoid nested commands</span>
dsApp.<b>AbortRunningCommand</b>()
<span style="color:green;">'Open document</span>
<span style="color:blue;">Dim</span> docName <span style="color:blue;">As</span> <span style="color:blue;">String</span> = <span style="color:#a31515;">"C:\ProgramData\Dassault Systemes\DraftSight\Examples\A-54643.DWG"</span>
dsDoc = dsApp.<b>OpenDocument2</b>(docName, <span style="color:#2b91af;">dsDocumentOpenOption_e</span>.dsDocumentOpen_Default, <span style="color:#2b91af;">dsEncoding_e</span>.dsEncoding_Default)
<span style="color:green;">'Get active document</span>
dsDoc = dsApp.<b>GetActiveDocument</b>()
<span style="color:blue;">If</span> (dsDoc <span style="color:blue;">IsNot</span> <span style="color:blue;">Nothing</span>) <span style="color:blue;">Then</span>
<span style="color:green;">'Get model space</span>
dsModel = dsDoc.<b>GetModel</b>()
<span style="color:blue;">Else</span>
MsgBox(<span style="color:#a31515;">"There are no open documents in DraftSight."</span>)
<span style="color:blue;">Return</span>
<span style="color:blue;">End</span> <span style="color:blue;">If</span>
<span style="color:green;">'Insert ViewTiles</span>
<span style="color:blue;">Dim</span> viewTiles(3) <span style="color:blue;">As</span> <span style="color:blue;">Object</span>
<span style="color:blue;">Dim</span> index <span style="color:blue;">As</span> <span style="color:blue;">Long</span>
<span style="color:blue;">Dim</span> dsViewTile <span style="color:blue;">As</span> <span style="color:#2b91af;">ViewTile</span>
viewTiles = dsModel.<b>InsertViewTiles</b>(<span style="color:#2b91af;">dsViewTilesMode_e</span>.dsViewTilesMode_4_Left, <span style="color:#2b91af;">dsViewTilesApplyTo_e</span>.dsViewTilesApplyTo_ActiveViewTile)
<span style="color:blue;">If</span> IsArray(viewTiles) <span style="color:blue;">Then</span>
<span style="color:blue;">For</span> index = LBound(viewTiles) <span style="color:blue;">To</span> UBound(viewTiles)
dsViewTile = viewTiles(index)
<span style="color:green;">'Turn off displaying coordinate system icon at origin</span>
dsViewTile.<b>CSIconIsOn</b> = <span style="color:blue;">False</span>
<span style="color:blue;">If</span> <span style="color:blue;">Not</span> (dsViewTile.<b>CSIconIsOn</b>) <span style="color:blue;">Then</span>
<span style="color:green;">'Display coordinate system at origin </span>
dsViewTile.<b>CSIconAtOrigin</b> = <span style="color:blue;">True</span>
<span style="color:green;">'Turn on displaying coordinate system icon at origin</span>
dsViewTile.<b>CSIconIsOn</b> = <span style="color:blue;">True</span>
<span style="color:blue;">End</span> <span style="color:blue;">If</span>
<span style="color:blue;">Next</span>
<span style="color:blue;">End</span> <span style="color:blue;">If</span>
<span style="color:blue;">End</span> <span style="color:blue;">Sub</span>
<span style="color:blue;">End</span> <span style="color:blue;">Module</span>
</pre>
</body>
</html>