Quantcast
Channel: MicroStation Programming - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 1677

Re: Scroll through named fences in a Design file

$
0
0

Hi,

I hope it will be more clear how to work with Named Fences from VBA (not sure if it's the best approach, but it should work ;-).

Named fence is stored as hidden shape file in a model, the only available information is it's a shape defining a fence and its name. It means to use Name Fence, you have to receive the fence name, to receive defining element (closed shape), use the element to create active fence and after it you can receive element enumerator.

Sub NamedFence()
    ' Obtain an array of fences' names
    Dim fences() As String
    fences = ActiveDesignFile.fence.GetFenceNames

    ' Go through the receive array of fence names
    Dim highBound As Integer
    highBound = UBound(fences)

    Dim counter As Integer
    For counter = 0 To highBound
        ProcessFence (fences(counter))
    Next
End Sub

Sub ProcessFence(fenceName As String)
    ' Receive element, which belongs to the named fence
    Dim fenceElement As Element
    Set fenceElement = ActiveDesignFile.fence.GetElementFromName(fenceName)

    ' Create the active fence from the element
    Dim lastView As View
    Set lastView = CommandState.lastView

    ActiveDesignFile.fence.DefineFromElement lastView, fenceElement

    ' Set fence mode here
    ActiveSettings.FenceClip = True

    ' Receive fence content
    Dim enumerator As ElementEnumerator
    Set enumerator = ActiveDesignFile.fence.GetContents

    ' Enumerate fence content and do what you need
    Do While enumerator.MoveNext
        enumerator.Current.IsHighlighted = True
    Loop
End Sub

With regards,

  Jan


Viewing all articles
Browse latest Browse all 1677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>