0% found this document useful (0 votes)
30 views

Mvba

This document contains code snippets for scanning model references and elements to find elements linked to a specific database link (MSLINK). The code first defines a subroutine to scan attachments on a model reference. It then defines two subroutines to scan elements - one uses the ActiveModelReference, while the other allows passing a model reference as a parameter. The subroutine examples loop through the element enumerator returned from a scan, check if elements have database links, and highlight any element whose link matches the target MSLINK.

Uploaded by

Ramesh Kurma
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Mvba

This document contains code snippets for scanning model references and elements to find elements linked to a specific database link (MSLINK). The code first defines a subroutine to scan attachments on a model reference. It then defines two subroutines to scan elements - one uses the ActiveModelReference, while the other allows passing a model reference as a parameter. The subroutine examples loop through the element enumerator returned from a scan, check if elements have database links, and highlight any element whose link matches the target MSLINK.

Uploaded by

Ramesh Kurma
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sub ScanAttachments ()

Dim oAttachments As Attachments


Set oAttachments = ActiveModelReference.Attachments
Dim oAttachment As Attachment
For Each oAttachment In oAttachments
ScanModelReference oAttachment
Next oAttachment
End Sub
Sub ScanModelReference (ByVal oModelReference As ModelReference)
... your existing code goes here -- but substitute oModelReference for
ActiveModelReference
Set oElementEnumerator = oModelReference.Scan (oScanCriteria)
...
End Sub
===================================================================================
==================
Sub t2()
Dim ee As ElementEnumerator
Dim oel As Element
Dim oscan As ElementScanCriteria
Dim dbLinks() As DatabaseLink
Dim i As Integer

Set oscan = New ElementScanCriteria


'oscan.ExcludeAllTypes
'oscan.IncludeType msdElementTypeText
oscan.IncludeOnlyUserAttribute (24721)
Set ee = ActiveModelReference.Scan(oscan)

Do While ee.MoveNext
Debug.Print "found " & ee.Current.Type
If ee.Current.HasAnyDatabaseLinks Then
dbLinks = ee.Current.GetDatabaseLinks()
For i = 0 To UBound(dbLinks)
Debug.Print "element has mslink = " & dbLinks(i).Mslink
Next
End If
Loop
End Sub
===================================================================================
====
Dim ee As ElementEnumerator
Dim oscan As ElementScanCriteria
Dim dbLinks() As DatabaseLink
Dim i, count As Integer

Set oscan = New ElementScanCriteria


oscan.IncludeOnlyUserAttribute (24721)

Set ee = ActiveModelReference.Scan(oscan)
Do While ee.MoveNext

If ee.Current.HasAnyDatabaseLinks Then
dbLinks = ee.Current.GetDatabaseLinks()
For i = 0 To UBound(dbLinks)

if (dbLinks(i).mslink = mslink)
ee.Current.Redraw msdDrawingModeHilite
Else
End If

Next
End If
Loop
Basic==============================================================================
=======================
'MS_LIKNKTYPE must be defined for this to work
sub main
Dim lnk() as MbeDatabaseLink
Dim numLinks as Integer
Dim Mslink as long
Dim filepos as long
Dim element as NEW MbeElement
Dim origin as MbePoint
Dim Mylink as string
Dim view as integer
'load database server
MbeSendCommand "mdl l server"
'prompt for mslink value
MyLink = MbeInputBox("Enter MSLINK Number : " ,, "Find Linked Elements")
if MyLink <> "" Then
Mslink = val(Mylink)
'read each element
filePos = element.fromFile (0)
Do While filePos >= 0
'check if linkages
If element.foundDBLinkages = MBE_Success Then
If element.extractDBLinkages(lnk) = MBE_Success Then
'read origin
If element.getOrigin(origin) = MBE_Success Then
'read each linkage
For iLink = LBound(lnk) To UBound(lnk)
If lnk(iLink).mslink = MsLink Then
MbeSendCommand "win cen"
MbeSendDataPoint Origin
MbeSendDataPoint Origin, View
element.display MBE_Hilite
'prompt user to continue
button = MbeMessageBox("Highlighted Element is Linked to " & MyLink
& chr$(10) & "[Yes] For Next, [No] to Exit", Mbe_YesNobox)
if button = MBE_BUTTON_NO Then
exit do
end if
End if
Next iLink
End If 'origin
End if 'extract linkages
End If 'found linkage
filePos = element.fromFile(element.filePos + element.fileSize)
Loop 'next element
End if
end sub

You might also like