I am a new MicroStation CONNECT Edition user (Version 10.13.01.01)
Can I use the Fence tool to make a selection.
I would like to use Fence and Flood to select everything in my drawing area, then use the Select tool filters to select what I want to change.
Thanks,
Koog
Hi Koog,
I might be a little late to the party, but I'll share what I have as well.
I have been in your situation before, needing to select certain elements, but within the active fence only. The ElementScanCriteria object works on the entire model , and picks everything meeting the scan requirements in the file.
My method uses what Brien Hastings also mentioned, using the fence selection [new/append/remove] keyin, which can add to an existing selection set, or create a new one entirely, depending on your choice.
My method however has an additional step where you use the SelectBy attributes dialog to set the element attributes you want, then use the fence selection new keyin as you prefer.
I have coded it such that it results in a selection set of the elements you want, located only in the active fence.
Steps to follow
1. Use Selectby dialog to set the attributes you want. Be sure to set "selectby options location" setting, as it is the one that allows selection in the active fence.
2. Use keyin "fence selection new", and you will have the elements added to the current selection set.
I will upload a MVBA macro that does the above. It sets the attribute to line, and ultimately allows you to select only lines in the active file. You can tweak this to suite your specific needs.
The procedure below selects elements in the fence based on the element type and element level.
Sub SelectElementsInFence(oType As String, oLevel As String) 'this assumes that the fence is already defined. Dim startPoint As Point3d Dim point As Point3d, point2 As Point3d Dim lngTemp As Long ' Send a keyin that can be a command string CadInputQueue.SendKeyin "mdl silentload selectby dialog" ' Start a command CadInputQueue.SendCommand "DIALOG SELECTBY" CadInputQueue.SendKeyin "selectby type none" CadInputQueue.SendKeyin "selectby level none" CadInputQueue.SendKeyin "selectby type " & oType CadInputQueue.SendKeyin "selectby level " & oLevel CadInputQueue.SendKeyin "selectby options location" CadInputQueue.SendKeyin "selectby execute" 'this keyin does the selection based on criteria above. This assumes that you want a new selection set. 'if you want to add to the existing set, then use <append> in place of <new>. CadInputQueue.SendKeyin "fence selection new" CadInputQueue.SendKeyin "mdl unload selectby" CommandState.StartDefaultCommand End Sub
You can test this using the test macro below:
Sub Test() 'logic to create or check if a fance exists may go here 'now we select only elements in the fence that are both a Line and on Level 1 SelectElementsInFence "LINE", "1" 'after the procedure, the current selected items can be assigned to an ElementEnumerator 'and futher processing done Dim oEnum As ElementEnumerator If Not ActiveModelReference.AnyElementsSelected Then MsgBox "No Elements Selected" Exit Sub End If 'if control gets here, then we have some selected elements Set oEnum = ActiveModelReference.GetSelectedElements Do While oEnum.MoveNext 'Process Elements Dim oElm As Element Set oElm = oEnum.Current Debug.Print DLongToString(oElm.ID) 'do whatever with the element ' ' Loop End Sub
I hope this is useful to you, there are probably ways to improve the criteria selection, but this was a quick and dirty way to get it done.
Regards,
Greg M