Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm having some slow-down issues with some code I've written in VB that looks thru and identifies certain sketch points in an array of sketch points. The array can vary in size from a few points to a couple of thousand points. Obviously the slowdowns increase with the size of the array.
What I'd like to know is if there is a way of finding points without having to loop through every point in the array every time. I'd like to be able to just look at one row in the array. Is it possible to just look at a small geometric area of points, like a row, using the API? The code below illustrates one of the loops that I am currently using. Any help would be greatly appreciated!
For count = 1 To oSketch.SketchPoints.Count Dim sPoint = oSketch.SketchPoints.Item(count) Dim sPointX As Double = sPoint.Geometry.X Dim sPointY As Double = sPoint.Geometry.Y Dim sPointSpot As Point2d = oTG.CreatePoint2d(sPointX, sPointY) If Math.Abs(sPointSpot.DistanceTo(oSketchPointSpot) - pitch) < 0.001 Then If UCase(checkSide) = "UPLEFT" Then 'MsgBox("Distance to sPoint is: " & sPointSpot.DistanceTo(oSketchPointSpot) - pitch & vbNewLine & vbNewLine & "Angle between vectors is: " & (sPointSpot.VectorTo(oSketchPointSpot).AngleTo(vectorY)) * 180 / Math.PI) If Math.Abs(sPointSpot.VectorTo(oSketchPointSpot).AngleTo(vectorY) - Math.PI * 120 / 180) < 0.1 Then If sPointSpot.X > oSketchPointSpot.X And sPointSpot.Y > oSketchPointSpot.Y Then Return True End If End If ElseIf UCase(checkSide) = "UPRIGHT" Then 'MsgBox("Distance to sPoint is: " & sPointSpot.DistanceTo(oSketchPointSpot) - pitch & vbNewLine & vbNewLine & "Angle between vectors is: " & (sPointSpot.VectorTo(oSketchPointSpot).AngleTo(vectorY)) * 180 / Math.PI) If Math.Abs(sPointSpot.VectorTo(oSketchPointSpot).AngleTo(vectorY) - Math.PI * 60 / 180) < 0.1 Then If sPointSpot.X > oSketchPointSpot.X And sPointSpot.Y < oSketchPointSpot.Y Then Return True End If End If ElseIf UCase(checkSide) = "LEFT" Then 'MsgBox("Distance to sPoint is: " & sPointSpot.DistanceTo(oSketchPointSpot) - pitch & vbNewLine & vbNewLine & "Angle between vectors is: " & (sPointSpot.VectorTo(oSketchPointSpot).AngleTo(vectorY)) * 180 / Math.PI) If Math.Abs(sPointSpot.VectorTo(oSketchPointSpot).AngleTo(vectorY) - Math.PI * 180 / 180) < 0.1 Then Return True End If ElseIf UCase(checkSide) = "RIGHT" Then 'MsgBox("Distance to sPoint is: " & sPointSpot.DistanceTo(oSketchPointSpot) - pitch & vbNewLine & vbNewLine & "Angle between vectors is: " & (sPointSpot.VectorTo(oSketchPointSpot).AngleTo(vectorY)) * 180 / Math.PI) If Math.Abs(sPointSpot.VectorTo(oSketchPointSpot).AngleTo(vectorY) - Math.PI * 0 / 180) < 0.1 Then Return True End If ElseIf UCase(checkSide) = "DOWNLEFT" Then 'MsgBox("Distance to sPoint is: " & sPointSpot.DistanceTo(oSketchPointSpot) - pitch & vbNewLine & vbNewLine & "Angle between vectors is: " & (sPointSpot.VectorTo(oSketchPointSpot).AngleTo(vectorY)) * 180 / Math.PI) If Math.Abs(sPointSpot.VectorTo(oSketchPointSpot).AngleTo(vectorY) - Math.PI * 240 / 180) < 0.1 Then If sPointSpot.X < oSketchPointSpot.X And sPointSpot.Y > oSketchPointSpot.Y Then Return True End If End If ElseIf UCase(checkSide) = "DOWNRIGHT" Then 'MsgBox("Distance to sPoint is: " & sPointSpot.DistanceTo(oSketchPointSpot) - pitch & vbNewLine & vbNewLine & "Angle between vectors is: " & (sPointSpot.VectorTo(oSketchPointSpot).AngleTo(vectorY)) * 180 / Math.PI) If Math.Abs(sPointSpot.VectorTo(oSketchPointSpot).AngleTo(vectorY) - Math.PI * 300 / 180) < 0.1 Then If sPointSpot.X < oSketchPointSpot.X And sPointSpot.Y < oSketchPointSpot.Y Then Return True End If End If Else Return False End If End If Next
Solved! Go to Solution.