TheSwamp
Code Red => VB(A) => Topic started by: Co.Mnstr on November 13, 2008, 01:14:21 PM
-
I thought it was easier that this. I have run into a road block and of all the examples I have found this code should work.
Basic, and I mean basic, I want to create two selection sets. I have learned that I need to check if they already exist, and if they do then delete them. Then make the selection sets again. What I want this simple code to do is look into the existing selectionsets and delete any that have the same names as the one I am about to create. Then do a simple display showing me that the selection set that I have created are in the drawing. I will then build my code off that.
Sub ChXrefGray()
Dim ASSS as acadselectionsets
Dim Ass, xxreflist, xxlayerlist as acadselectionset
Dim msg as string
Set ASSS = ThisDrawing.SelectionSets
For Each Ass In ASSS
If Ass.Name = "xreflist" Then
ASSS.Item("xreflist").Delete
Else
If Ass = "layerlist" Then
ASSS.Item("layerlist").Delete
Else
End If
Next
Set ssxreflist = ASSS.Add("XrefList")
Set sslayerlist = ASSS.Add("LayerList")
MsgBox "there are " & ThisDrawing.SelectionSets.Count & "Selection Sets in this drawing"
msg = vbCrLf & vbCrLf
For Each Ass In ASSS
AssName = Ass.Name
msg = msg & AssName
msg = msg & vbCrLf
Next
MsgBox msg
End Sub
Can't get more basic. But when I run the code, VB tells me that I have a Next statement with out a For statement. At the very beginning of the code. I hope someone can explain to me why my code does not work, but other examples of the same do.
Thanks all,
Alex
-
Try this...
For Each Ass In ASSS
If Ass.Name = "xreflist" Then
ASSS.Item("xreflist").Delete
ElseIf Ass = "layerlist" Then
ASSS.Item("layerlist").Delete
End If
Next
-
Try this...
For Each Ass In ASSS
If Ass.Name = "xreflist" Then
ASSS.Item("xreflist").Delete
ElseIf Ass = "layerlist" Then
ASSS.Item("layerlist").Delete
End If
Next
:? :-D
-
Matt,
Thank you very much. It worked like a charm. I bow down to your kind words of wisdom.
-
<Skynard> ♪♫ Ewwww ewww that smell ... cantchu smell that smell ... ♪♫ </Skynard>
-
Try this...
For Each Ass In ASSS
If Ass.Name = "xreflist" Then
ASSS.Item("xreflist").Delete
ElseIf Ass = "layerlist" Then
ASSS.Item("layerlist").Delete
End If
Next
:? :-D
:lmao: I didn't even see that!
-
Just looking around and saw this post. I can't believe no one offered this code up :-D
Sub ChXrefGray()
Dim ASSS as acadselectionsets
Dim Ass, xxreflist, xxlayerlist as acadselectionset
Dim msg as string
Set ASSS = ThisDrawing.SelectionSets
Set ssxreflist = vbdPowerSet("XrefList")
Set sslayerlist =vbdPowerSet("LayerList")
MsgBox "there are " & ThisDrawing.SelectionSets.Count & "Selection Sets in this drawing"
msg = vbCrLf & vbCrLf
For Each Ass In ASSS
AssName = Ass.Name
msg = msg & AssName
msg = msg & vbCrLf
Next
MsgBox msg
End Sub
'From The Llama Library Published November 12, 1999
Function vbdPowerSet(strName As String) As AcadSelectionSet
Dim objSelSet As AcadSelectionSet
Dim objSelCol As AcadSelectionSets
Set objSelCol = Thisdrawing.SelectionSets
For Each objSelSet In objSelCol
If objSelSet.Name = strName Then
objSelCol.Item(strName).Delete
Exit For
End If
Next
Set objSelSet = objSelCol.Add(strName)
Set vbdPowerSet = objSelSet
End Function
-
Just looking around and saw this post. I can't believe no one offered this code up :-D
Sub ChXrefGray()
Dim ASSS as acadselectionsets
Dim Ass, xxreflist, xxlayerlist as acadselectionset
Dim msg as string
Set ASSS = ThisDrawing.SelectionSets
Set ssxreflist = vbdPowerSet("XrefList")
Set sslayerlist =vbdPowerSet("LayerList")
MsgBox "there are " & ThisDrawing.SelectionSets.Count & "Selection Sets in this drawing"
msg = vbCrLf & vbCrLf
For Each Ass In ASSS
AssName = Ass.Name
msg = msg & AssName
msg = msg & vbCrLf
Next
MsgBox msg
End Sub
'From The Llama Library Published November 12, 1999
Function vbdPowerSet(strName As String) As AcadSelectionSet
Dim objSelSet As AcadSelectionSet
Dim objSelCol As AcadSelectionSets
Set objSelCol = Thisdrawing.SelectionSets
For Each objSelSet In objSelCol
If objSelSet.Name = strName Then
objSelCol.Item(strName).Delete
Exit For
End If
Next
Set objSelSet = objSelCol.Add(strName)
Set vbdPowerSet = objSelSet
End Function
Hey Chuck!
-
This isn't Se7en's Chuck is it?
-
oh dear
this was a gem!
-
Do I need to shoot Se7en now?
I guess I just leave a lasting impression.