I am writing a VBA code for microstation that will allow the user to select an element, the macro will determine if it's a shape or complex shape, and return the max/min XY values for the entire element to the form to process there. I have been using the ILocateCommand Processes, and I have had some problems making sure the commands accept only shape or complex shape files, and returning the min/max XY values back to the form code is not working. I've made the information "public," and I've been on these forums for about three days now, and have found nothing that fixes my problems. Any help would be greatly appreciated.
Also, I know my code is a mess, so don't judge. (I'm still learning)
This calls the ILocateCommand class module:
Sub BtnDefine_Click()
Dim oIDele As New IDele
Dim TextXmax As Double
Dim TextYmax As Double
Dim TextXmin As Double
Dim TextYmin As Double
Dim Hpoint As Point3d
Dim Lpoint As Point3d
Dim Xmax As Double
Dim Xmin As Double
Dim Ymax As Double
Dim Ymin As Double
Me.Hide
CommandState.StartLocate oIDele
TextXmax = Hpoint.X
TextYmax = Hpoint.Y
TextXmin = Lpoint.X
TextYmin = Lpoint.Y
Xmax = TextXmax
Xmin = TextXmin
Ymax = TextYmax
Ymin = TextYmin
Debug.Print TextXmax
Debug.Print TextXmin
Debug.Print TextYmax
Debug.Print TextYmin
End Sub
Then This is the Class module:
Option Explicit
Implements ILocateCommandEvents
Private pointloc As Point3d
Public Property Let Points(ByRef Lpoint As Point3d, ByRef Hpoint As Point3d)
Lpoint = pLow
Hpoint = pHigh
End Property
Function MoreMath()
Dim Element As ShapeElement
Dim Ele As Shape
Dim pLow As Point3d
Dim Point As Point3d
Dim MyVertList As VertexList
Dim pHigh As Point3d
Ele = Element
MyVertList = Ele.AsVertexList
pLow.X = CStr(Ele.Range.Low.X)
pLow.Y = CStr(Ele.Range.Low.Y)
pHigh.X = CStr(Ele.Range.High.X)
pHigh.Y = CStr(Ele.Range.High.Y)
Debug.Print pLow.X
Debug.Print pLow.Y
Debug.Print pHigh.X
Debug.Print pHigh.Y
End Function
Private Sub ILocateCommandEvents_Start()
Dim oScanCrit As LocateCriteria
Set oScanCrit = CommandState.CreateLocateCriteria(False)
CommandState.SetLocateCriteria oScanCrit
oScanCrit.ExcludeAllTypes
oScanCrit.IncludeType msdElementTypeShape
oScanCrit.IncludeType msdElementTypeComplexShape
ShowCommand "Identify Element"
ShowPrompt "Select Element to Identify"
End Sub
Private Sub ILocateCommandEvents_LocateFilter(ByVal Element As Element, Point As Point3d, Accepted As Boolean)
End Sub
Private Sub ILocateCommandEvents_Accept(ByVal Element As Element, Point As Point3d, ByVal View As View)
Dim Ele As ShapeElement
MsgBox ("Element Accepted")
MoreMath
UserForm1.Show
End Sub
Private Sub ILocateCommandEvents_Dynamics(Point As Point3d, ByVal View As View, ByVal DrawMode As MsdDrawingMode)
End Sub
Private Sub ILocateCommandEvents_LocateFailed()
MsgBox ("Invalid Element; Element must be a shape or complex shape")
End Sub
Private Sub ILocateCommandEvents_LocateReset()
UserForm1.Show
End Sub
Private Sub ILocateCommandEvents_Cleanup()
Unload Me
End Sub
And this is what my form looks like:
![]()
I may be making this too complicated, I can't tell anymore.
Len