Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA selection set only sees lines if they are redrawn 2

Status
Not open for further replies.

jrice174

Civil/Environmental
Nov 8, 2004
129
I have a VBA program that selects lines on certain layers in a drawing. It almost always works correctly, but every once in a while it will not select some of the lines. If I delete the lines and redraw them, they then can be selected. Any idea what could cause a line to NOT be selected, but then to later be selected if the line is redrawn on the same layer?
 
Replies continue below

Recommended for you

Also note that VBA has a hard time selecting entities that are not shown in the current view. Does it miss the lines when you can see them in the window?
 
Here is the selection set part of the code.

For i = 1 To 8
'''''activate the proper layer
If i = 1 Then Layername = "MESA2_UX1100"
If i = 2 Then Layername = "MESA3_UX1400"
If i = 3 Then Layername = "MESA4_UX1500"
If i = 4 Then Layername = "MESA5_UX1600"
If i = 5 Then Layername = "MESA6_UX1700"
If i = 6 Then Layername = "MESA7_UX1800"
If i = 7 Then Layername = "BX1100"
If i = 8 Then Layername = "BX1200"

intCode(0) = -4: varCodeValue(0) = "<AND"
intCode(1) = 0: varCodeValue(1) = "LINE"
intCode(2) = -4: varCodeValue(2) = "<OR"
intCode(3) = 8: varCodeValue(3) = Layername
intCode(4) = -4: varCodeValue(4) = "OR>"
intCode(5) = 67: varCodeValue(5) = "0"
intCode(6) = -4: varCodeValue(6) = "AND>"

'''''select all lines on current layer above a certain line
'''''that is located at Pt1 to Pt2

On Error Resume Next
ThisDrawing.SelectionSets("TEMP").Delete
Set objSS = ThisDrawing.SelectionSets.Add("TEMP")
objSS.Select 1, Pt1, Pt2, intCode, varCodeValue

If objSS.count > 0 Then
For Each objLine In ThisDrawing.ActiveSelectionSet
LineCount = LineCount + 1
objLine.Highlight True
StPoint = objLine.EndPoint
EndPoint = objLine.StartPoint
Next objLine
End If
Next i
 
My first suspect is the type of selection you are doing. It appears to be a window. If this is so, then are all the entities within this window? Would a crossing window work better?


"The fear of the Lord is the beginning of wisdom"
 
Hi jrice174,

Borgie's right, you're using a window which won't see everything until it's regened, or if you're lucky, just redrawn. If you must have the window, you'll need to insert a regen before your selection statement if not, change your select statement from:

Code:
objSS.Select 1, Pt1, Pt2, intCode, varCodeValue

To:

Code:
objSS.Select Mode:=acSelectionSetAll, FilterType:=intCode, FilterData:=varCodeValue

and see if that doesn't help a bit.

HTH
Todd
 
I turns out that the engineer used polylines instead of lines. I was selecting lines. As you can see my filterdata is only set up to look for lines. I don't have a good grasp of the logic used in the FilterData array. Can you help?
 
It looks like you know what you are doing. This would get all polylines or lines on your layername and in your space.

intCode(0) = -4: varCodeValue(0) = "<AND"
intCode(1) = 0: varCodeValue(1) = "<OR"
intCode(2) = 0: varCodeValue(2) = "LINE"
intCode(3) = 0: varCodeValue(3) = "POLYLINE"
intCode(4) = -4: varCodeValue(4) = "OR>"
intCode(5) = 8: varCodeValue(5) = Layername
intCode(6) = 67: varCodeValue(6) = "0"
intCode(7) = -4: varCodeValue(7) = "AND>"


"The fear of the Lord is the beginning of wisdom"
 
Certain filtering values can be stacked to allow for more compact code, plus additional functionality is available with the Wildcard operator "*".

intCode(0) = -4: varCodeValue(0) = "<AND"
intCode(1) = 0: varCodeValue(1) = "LINE,LWPOLYLINE,POLYLINE"
intCode(2) = 8: varCodeValue(2) = "MESA*,BX*"
intCode(3) = -4: varCodeValue(3) = "<NOT"
intCode(4) = 8: varCodeValue(4) = "MESA_UX1200,MESA_UX1300"
intCode(5) = -4: varCodeValue(5) = "NOT>"
intCode(6) = 67: varCodeValue(6) = "0"
intCode(7) = -4: varCodeValue(7) = "AND>"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor