Repository URL to install this package:
|
Version:
2016.3.0.4050 ▾
|
draftsight
/
opt
/
dassault-systemes
/
DraftSight
/
APISDK
/
Create_Highlight_Selection_Set_Example_VBNET.htm
|
|---|
<html>
<head>
<title>Create Highlight Selection Set 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,highlight selection set">
</head>
<body>
<h1>Create Highlight Selection Set Example (VB.NET)</h1>
<p>This example shows how to create a highlight selection set.</p>
<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 Windows console project.</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. Add a reference to <b>System.Windows.Forms</b>.</span>
<span style="color: green">' 5. Start DraftSight.</span>
<span style="color: green">' 6. Press F5.</span>
<span style="color: green">'</span>
<span style="color: green">' Postconditions:</span>
<span style="color: green">' 1. Connects to DraftSight.</span>
<span style="color: green">' 2. Gets active document.</span>
<span style="color: green">' 3. Gets Sketch Manager.</span>
<span style="color: green">' 4. Inserts a Circle and an Arc.</span>
<span style="color: green">' 5. Creates an instance of a highlight selection set.</span>
<span style="color: green">' 6. Adds Arc to the highlight selection set.</span>
<span style="color: green">' 7. Move the pointer over both the Arc and Circle. Only the Arc</span>
<span style="color: green">' is highlighted. Press F5 to continue.</span>
<span style="color: green">' 8. Removes Arc from highlight selection set.</span>
<span style="color: green">' 9. Adds Circle to highlight selection set.</span>
<span style="color: green">' 10. Move the pointer over both the Arc and Circle. Only</span>
<span style="color: green">' the Circle is highlighted.</span>
<span style="color: green">'--------------------------------------------------------------</span>
<span style="color: blue">Imports</span> System
<span style="color: blue">Imports</span> DraftSight.Interop.dsAutomation
<span style="color: blue">Imports</span> System.Runtime.InteropServices
<span style="color: blue">Imports</span> System.Windows.Forms
<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> DraftSight.Interop.dsAutomation.<span style="color: #2b91af">Application</span>
<span style="color: green">'Connect to DraftSight application</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: blue">If</span> dsApp <span style="color: blue">Is</span> <span style="color: blue">Nothing</span> <span style="color: blue">Then</span>
<span style="color: blue">Return</span>
<span style="color: blue">End</span> <span style="color: blue">If</span>
<span style="color: green">'Abort any command currently running in DraftSight to avoid nested commands</span>
dsApp.<b>AbortRunningCommand</b>()
<span style="color: green">'Get active document</span>
<span style="color: blue">Dim</span> dsDoc <span style="color: blue">As</span> <span style="color: #2b91af">Document</span> = dsApp.<b>GetActiveDocument</b>()
<span style="color: blue">If</span> dsDoc <span style="color: blue">Is</span> <span style="color: blue">Nothing</span> <span style="color: blue">Then</span>
<span style="color: #2b91af">MessageBox</span>.Show(<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">'Get Sketch Manager</span>
<span style="color: blue">Dim</span> dsSketchMgr <span style="color: blue">As</span> <span style="color: #2b91af">SketchManager</span> = dsDoc.<b>GetModel</b>().<b>GetSketchManager</b>()
<span style="color: green">'Draw a Circle and Arc</span>
<span style="color: blue">Dim</span> dsCircle <span style="color: blue">As</span> <span style="color: #2b91af">Circle</span> = dsSketchMgr.<b>InsertCircle</b>(5.0, 5.0, 0.0, 10.0)
<span style="color: blue">Dim</span> dsCircleArc <span style="color: blue">As</span> <span style="color: #2b91af">CircleArc</span> = dsSketchMgr.<b>InsertArc</b>(7.5, 7.5, 0.0, 10.0, 2.5, 5.0)
dsApp.<b>Zoom</b>(<span style="color: #2b91af">dsZoomRange_e</span>.dsZoomRange_Bounds, <span style="color: blue">Nothing</span>, <span style="color: blue">Nothing</span>)
<span style="color: green">'Create highlight selection set</span>
<span style="color: blue">Dim</span> dsEntities <span style="color: blue">As</span> <span style="color: #2b91af">DispatchWrapper</span>() = <span style="color: blue">New</span> <span style="color: #2b91af">DispatchWrapper</span>(0) {}
dsEntities(0) = <span style="color: blue">New</span> <span style="color: #2b91af">DispatchWrapper</span>(dsCircleArc)
<span style="color: blue">Dim</span> dsHighlightSet <span style="color: blue">As</span> <span style="color: #2b91af">HighlightSet</span> = dsDoc.<b>CreateHighlightSet</b>(dsEntities)
dsHighlightSet.<b>Highlight</b> = <span style="color: blue">True</span>
dsDoc.<b>Rebuild</b>(<span style="color: #2b91af">dsRebuildType_e</span>.dsRebuildType_AllViewports)
System.Diagnostics.<span style="color: #2b91af">Debugger</span>.Break()
<span style="color: green">'Move pointer over the Arc and Circle</span>
<span style="color: green">'Only the Arc is highlighted
'Press F5 to continue</span>
<span style="color: green">'Remove entities from highlight selection set</span>
dsHighlightSet.<b>RemoveEntities</b>(dsEntities)
dsDoc.<b>Rebuild</b>(<span style="color: #2b91af">dsRebuildType_e</span>.dsRebuildType_AllViewports)
<span style="color: green">'Add Circle to highlight selection set</span>
dsEntities.<b>Initialize</b>()
dsEntities(0) = <span style="color: blue">New</span> <span style="color: #2b91af">DispatchWrapper</span>(dsCircle)
dsHighlightSet.<b>AddEntities</b>(dsEntities)
dsHighlightSet.<b>Highlight</b> = <span style="color: blue">True</span>
dsDoc.<b>Rebuild</b>(<span style="color: #2b91af">dsRebuildType_e</span>.dsRebuildType_AllViewports)
<span style="color: green">'Move pointer over the Arc and Circle</span>
<span style="color: green">'Only the Circle is highlighted</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>