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!

Can't select all lines on a layer

Status
Not open for further replies.

jrice174

Civil/Environmental
Nov 8, 2004
129
I'm using VBA to select all the lines on a layer. When I select them, every once in a while, they all don't get selected. If I select the line and type LIST, it shows up as a line but I cannot select it with the program unless it is redrawn. If I delete the lines and redraw them, then I can select them. I have a feeling that maybe the lines have been copied or extended which may be causing the problem, but I don't know.

Any ideas on this?
 
Replies continue below

Recommended for you

Hi jrice174,

How are selecting the lines with your code (can you post a snippet) - it would help to answer your question.

Todd
 
I don't think it's a code problem because I can rerun the program over and over with the same settings and get the same result (not selecting). If I redraw the lines and save the file, then I can rerun the program again over and over and get the same results (it IS selecting).

Here is the code:
Private Sub cmdCheckGeogridSelect_Click()
intCodes(0) = 8
NewLayer = "MESA4_UX1500": varCodeValues(0) = NewLayer
For Each objLayer In ThisDrawing.Layers
objLayer.LayerOn = False
If objLayer.Name = "MESA2_UX1100" Then objLayer.LayerOn = True
If objLayer.Name = "MESA3_UX1400" Then objLayer.LayerOn = True: ThisDrawing.ActiveLayer = ThisDrawing.Layers("MESA3_UX1400")
If objLayer.Name = "MESA4_UX1500" Then objLayer.LayerOn = True
If objLayer.Name = "MESA5_UX1600" Then objLayer.LayerOn = True
Next objLayer

Call SelectAll
End
End Sub

and

Public Sub SelectAll()
On Error Resume Next
ThisDrawing.SelectionSets("TEMP").Delete
Set objSS = ThisDrawing.SelectionSets.Add("TEMP")
objSS.Select 5, Pt2, Pt1, intCodes, varCodeValues ' 5 = all, 1 = use Pt1 and
End Sub
 
When you select, you can leave just blank spaces where the points (Pt1,Pt2) go and make sure you int and var codes just to pick lines or lines on certain layers (using the AND in your selection list). Am I making sense?

"Everybody is ignorant, only on different subjects." — Will Rogers
 
Yes you make sense, but I don't really don't have a very good understanig of the intCodes & varCodeValues filters. Where can I find a little more on them?
 
Here is a way to select only lines on a layer named "SOMELAYERNAME"...basically

intCode(0) = -4: vntCode(0) = "<AND"
intCode(1) = 0: vntCode(1) = "LINE"
intCode(2) = 8: vntCode(2) = "SOMELAYERNAME"
intCode(3) = -4: vntCode(3) = "AND>"

acSelSet.Select 5, , , intCode, vntCode

"Everybody is ignorant, only on different subjects." — Will Rogers
 
Thanks! That helps. I do think however that the code I have works properly, any ideas why it's can't select all of the lines?
 
Are the lines you're tring to select displayed on the screen, or are they off screen?
 
Yes, the layers are turned on and none of the lines go outside of the window.
 
Hi jrice174,

I think you're missing your varCodeValues value - in other words, you've told your routine to select all entities on a particular layer - but didn't specify your layer.

HTH
Todd
 
The 3rd line of code specifies the name for NEWLAYER and the varCodeValues gets it right after that. Even if that was not specified correctly, I'm wondering why it will not see the lines time after time, but once I redraw them on the same layer, it sees the lines time after time.
 
A note:
You are specifying some things in one subrotine but are calling them from another. Are these values (intcodes, varcodevalues) global? If not, they do not get called correctly.

Are the lines you want to grab being created during these routines? The app may need to be updated during their creation so the code may "see" them.

"Everybody is ignorant, only on different subjects." — Will Rogers
 
Yes, the layers are turned on and none of the lines go outside of the window.
The layers are on... Good
What do you mean by window?
Can you see them on the screen?
Can you select them manually?
Does a regenall help?
 
They are visible in the AutoCAD window, I mean I am not zoomed in where they are not visible. I can select them manually and get 10 lines selected. If I select them with the program I may only get 2 lines selected. I highlight the lines so I can see which ones are selected. If I redraw the unhighlighted lines on the same layer and rerun the program, then I get all 10 lines selected.
 
Is the layer name by any chance case sensitive?
Are the lines true lines or are they Splines or LWPolylines or Polylines or any other type of entity? When you LIST the lines that do not get selected, is there anything different about them as compared to when they are selected by your program?
 
That's one of the things that's really maddening about this is that when I LIST the lines that won't select, they have the same exact info as the lines that do select (other than coordinates, of course).

The layer name is case sensitive but the layers that get selected and the ones that don't are all on the same layer and get selected in the same selection set command. Becasue they are all selected at the same time I would expect them all to be selected. I'm using a Select All, so I would expect them all to be selected. It's only when I redraw them that they get selected. Can copying a line cause this?

There is another line in my drawings that I always have to redraw before the program sees it. I THINK the reason is because it is brought in as part of a block that gets exploded.
 
Is it possible to see all the code? We are flying a little blind here.
Are you saying, in code, you bring in a block, explode it and then try to grab some lines from it and lines elsewhere that are all on the same layer? Have you updated the session while doing this. eg thisdrawing.update Remember, AutoCAD is a database and a screen representation of that database. Select works with the drawing screen per se and sometimes the db and screen don't jive.

"Everybody is ignorant, only on different subjects." — Will Rogers
 
I believe I’m found the problem. The way I’ve been setting up my selection set to get each layer separately.

Dim intCode(0) As Integer
Dim varCodeValue(0) As Variant

intCode(0) = 8
varCodeValue(0) = “ThisLayer”

On Error Resume Next
ThisDrawing.SelectionSets("TEMP").Delete
Set objSS = ThisDrawing.SelectionSets.Add("TEMP")
objSS.Select 5, , , intCodes, varCodeValues

But it seems to work better if I write it like this…..

Dim intCode(7) As Integer
Dim varCodeValue(7) As Variant

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

On Error Resume Next
ThisDrawing.SelectionSets("TEMP").Delete
Set objSS = ThisDrawing.SelectionSets.Add("TEMP")
objSS.Select 5, , , intCodes, varCodeValues

Does it make sense that this change could solve the problem?
 
Sure does if they are not all on the same layer. I guess I thought that you did only want to get lines from a certain layer only. Hope you got it going.

"Everybody is ignorant, only on different subjects." — Will Rogers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor