Problem with using LocateOp with in A feature numerator from a previous LocateOp

Hi

I have a problem with making a locate while running through a feature enumerator from a previos made scan, PowerMap crashes when going to the second item in the outer loop.

I have made this very simple application to show the problem (The application ans a test designfile is attached in a zip)

********* Main appication ***************
Attribute VB_Name = "modLocateTest"
Public ScanFeatureEnumerator As xft.FeatureEnumerator
Public ScanFeatureCount As Long
Public XpathFeatureEnumerator As xft.FeatureEnumerator
Public XpathFeatureCount As Long

Public Function GetFeaturesByXpathAndPoint(ByVal Xpath As String, Pkt As Point3d, ByVal SnapDist As Double) As Integer
'--------------------------------------------------------------------
' Function makes a XpathScan near Point Pkt
' Found features are in enumaerat XpathFeatureEnumerator
' Function returns number of found features
'---------------------------------------------------------------------
Dim oLocateOp As New xft.locateOp
Dim oPoint As New xft.InputPoint
Dim toleranceValue As New InputValue

toleranceValue.SetTypeAndValue ValueType_VALUE, Str(SnapDist)
oLocateOp.Tolerance = toleranceValue

oPoint.SetLocation Pkt.X, Pkt.Y, Pkt.Z, False
oLocateOp.ScanAtPoint = True
oLocateOp.ReferencePoint = oPoint

oLocateOp.Mode = LocateOpMode.locateOpModeScan
oLocateOp.Xpath = Xpath

oLocateOp.AutoAcceptScanFile = True

CmdMgr.StartLocateOperation oLocateOp, New clsLocateXpath

GetFeaturesByNameAndPoint = XpathFeatureCount
End Function

Public Function ScanFeaturesByName(ByVal FeatureNames As String) As Integer
'--------------------------------------------------------------------
' Function makes a Scan for the comma delimited featurenames
' Founf features are in enumarator ScanFeatureEnumerator
' Function returns number of found features
'---------------------------------------------------------------------
Dim oLocateOp As New xft.locateOp
Dim Features() As String
Dim i As Integer

oLocateOp.Mode = LocateOpMode.locateOpModeScan
If Trim(FeatureNames) <> "" Then
    Features() = Split(FeatureNames, ",")
    For i = 0 To UBound(Features)
        oLocateOp.IncludeFeatureName Features(i)
    Next
End If
oLocateOp.AutoAcceptScanFile = True

CmdMgr.StartLocateOperation oLocateOp, New clsScanLocate

ScanFeaturesByName = ScanFeatureCount
End Function

Public Sub main()
Dim oFeature As xft.feature
Dim Pkt As point3d


If ScanFeaturesByName("Brønd,TilslutningKn,FiktivKnude,DelLednKnude,AndenKnude") > 0 Then
    Do While ScanFeatureEnumerator.MoveNext
        Set oFeature = ScanFeatureEnumerator.Current
        'MsgBox oFeature.GetXml
        Pkt.X = oFeature.Geometry.AsCellElement.Origin.X
        Pkt.Y = oFeature.Geometry.AsCellElement.Origin.Y
        Pkt.Z = oFeature.Geometry.AsCellElement.Origin.Z

        If GetFeaturesByXpathAndPoint("Dæksel", Pkt, 5#) > 0 Then
            Do While XpathFeatureEnumerator.MoveNext
                Set oFeature = XpathFeatureEnumerator.Current
                MsgBox oFeature.GetXml
            Loop
        End If

    Loop
End If

End Sub

********************************************************

************** Two LocateOp clasees *****************

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "clsScanLocate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Implements ILocateOpEvents
    
Private Sub ILocateOpEvents_OnCleanup()

End Sub

Private Sub ILocateOpEvents_OnFinished(ByVal locateOp As xft.ILocateOp)
modLocateTest.ScanFeatureCount = locateOp.LocatedFeaturesCount

Set modLocateTest.ScanFeatureEnumerator = locateOp.GetLocatedFeatures
   
End Sub

Private Sub ILocateOpEvents_OnRejected(ByVal RejectedReasonType As xft.LocateOpRejectedReasonType, RejectedReason As String)

End Sub

Private Sub ILocateOpEvents_OnTerminate()

End Sub

Private Sub ILocateOpEvents_OnValidate(ByVal RootFeature As xft.IFeature, ByVal element As element, Point As Point3d, ByVal View As View, Accepted As Boolean, RejectReason As String)
Accepted = True
End Sub

*********************************************************

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "clsLocateXpath"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Implements ILocateOpEvents
   
Private Sub ILocateOpEvents_OnCleanup()

End Sub

Private Sub ILocateOpEvents_OnFinished(ByVal locateOp As xft.ILocateOp)
modLocateTest.XpathFeatureCount = locateOp.LocatedFeaturesCount

Set modLocateTest.XpathFeatureEnumerator = locateOp.GetLocatedFeatures
   
End Sub

Private Sub ILocateOpEvents_OnRejected(ByVal RejectedReasonType As xft.LocateOpRejectedReasonType, RejectedReason As String)

End Sub

Private Sub ILocateOpEvents_OnTerminate()

End Sub

Private Sub ILocateOpEvents_OnValidate(ByVal RootFeature As xft.IFeature, ByVal element As element, Point As Point3d, ByVal View As View, Accepted As Boolean, RejectReason As String)
Accepted = True
End Sub


Thanks in advance

Erik Wirring

LocateTest.zip
Parents
  • Hi. It is currently not supported to use the result of a locate operation directly within another locate operation (nesting). Even though you are storing the pointers to the iterators separately, internally this doesn't work. The construction of the second locate operator destroys the list owned by the first.

    For now I suggest that you first iterate on the results of your first iterator and store the list of result features in your application, and as a second step work with that local list for your second locate operation.

    Hope this helps,

       Martin

      

  • Hi Martin

    Thanks for the help. I have change the routines so they saves the found features in features arrays instead. It works fine, I was some unsure whether I would be able to update the features, but that seems to work too.

    Erik

Reply Children
No Data